Commit 033b3c15 authored by GILLES Sebastien's avatar GILLES Sebastien

#1273 Fix LLVM warnings.

parent 7730e223
......@@ -36,7 +36,7 @@ namespace MoReFEM
Coords::SetCreateDomainListForCoords();
// current date and time system
time_t now = std::time(0);
time_t now = std::time(nullptr);
char* date_time = ctime(&now);
namespace IPL = Utilities::InputParameterListNS;
......@@ -148,7 +148,7 @@ namespace MoReFEM
mpi, __FILE__, __LINE__, DerivedT::ClassName().c_str());
// current date and time system
time_t now = time(0);
time_t now = time(nullptr);
char* date_time = ctime(&now);
Wrappers::Petsc::PrintMessageOnFirstProcessor("%s==============================================================\n",
......
......@@ -17,8 +17,8 @@ target_sources(MoReFEM_test_tools
)
target_link_libraries(MoReFEM_test_tools
${ALL_LOAD_BEGIN_FLAG}
${MOREFEM_MODEL}
${ALL_LOAD_END_FLAG})
${ALL_LOAD_BEGIN_FLAG}
${MOREFEM_MODEL}
${ALL_LOAD_END_FLAG})
morefem_install(MoReFEM_test_tools)
......@@ -23,6 +23,11 @@ PRAGMA_DIAGNOSTIC(ignored "-Wdeprecated")
PRAGMA_DIAGNOSTIC(ignored "-Wreserved-id-macro")
PRAGMA_DIAGNOSTIC(ignored "-Wweak-vtables")
PRAGMA_DIAGNOSTIC(ignored "-Wundef")
# ifdef MOREFEM_LLVM_CLANG
// These pragma is required for most recent clang; current Apple clang doesn't know it yet.
PRAGMA_DIAGNOSTIC(ignored "-Wzero-as-null-pointer-constant")
PRAGMA_DIAGNOSTIC(ignored "-Wcast-qual")
# endif // MOREFEM_LLVM_CLANG
# endif // __clang__
#include "boost/exception/diagnostic_information.hpp"
......
......@@ -21,6 +21,10 @@ PRAGMA_DIAGNOSTIC(push)
PRAGMA_DIAGNOSTIC(ignored "-Wweak-vtables")
PRAGMA_DIAGNOSTIC(ignored "-Wdisabled-macro-expansion")
PRAGMA_DIAGNOSTIC(ignored "-Wreserved-id-macro")
# ifdef MOREFEM_LLVM_CLANG
// These pragma is required for most recent clang; current Apple clang doesn't know it yet.
PRAGMA_DIAGNOSTIC(ignored "-Wzero-as-null-pointer-constant")
# endif // MOREFEM_LLVM_CLANG
# endif // __clang__
PRAGMA_DIAGNOSTIC(ignored "-Wconversion")
......
......@@ -23,6 +23,11 @@ PRAGMA_DIAGNOSTIC(ignored "-Wcast-align")
PRAGMA_DIAGNOSTIC(ignored "-Wweak-vtables")
PRAGMA_DIAGNOSTIC(ignored "-Wdeprecated")
PRAGMA_DIAGNOSTIC(ignored "-Wreserved-id-macro")
# ifdef MOREFEM_LLVM_CLANG
// These pragma is required for most recent clang; current Apple clang doesn't know it yet.
PRAGMA_DIAGNOSTIC(ignored "-Wzero-as-null-pointer-constant")
# endif // MOREFEM_LLVM_CLANG
# endif // __clang__
PRAGMA_DIAGNOSTIC(ignored "-Wold-style-cast")
......
......@@ -21,6 +21,11 @@ PRAGMA_DIAGNOSTIC(ignored "-Wold-style-cast")
# ifdef __clang__
PRAGMA_DIAGNOSTIC(ignored "-Wreserved-id-macro")
# ifdef MOREFEM_LLVM_CLANG
// These pragma is required for most recent clang; current Apple clang doesn't know it yet.
PRAGMA_DIAGNOSTIC(ignored "-Wzero-as-null-pointer-constant")
PRAGMA_DIAGNOSTIC(ignored "-Wcast-qual")
# endif // MOREFEM_LLVM_CLANG
# endif // __clang__
#ifdef MOREFEM_GCC
......
......@@ -21,6 +21,11 @@ PRAGMA_DIAGNOSTIC(ignored "-Wunused-parameter")
# ifdef __clang__
PRAGMA_DIAGNOSTIC(ignored "-Wcomma")
PRAGMA_DIAGNOSTIC(ignored "-Wreserved-id-macro")
# ifdef MOREFEM_LLVM_CLANG
// These pragma is required for most recent clang; current Apple clang doesn't know it yet.
PRAGMA_DIAGNOSTIC(ignored "-Wzero-as-null-pointer-constant")
PRAGMA_DIAGNOSTIC(ignored "-Wcast-qual")
# endif // MOREFEM_LLVM_CLANG
# endif // __clang__
#ifdef MOREFEM_GCC
......
......@@ -24,6 +24,11 @@ PRAGMA_DIAGNOSTIC(ignored "-Wredundant-decls")
# ifdef __clang__
PRAGMA_DIAGNOSTIC(ignored "-Wcomma")
PRAGMA_DIAGNOSTIC(ignored "-Wreserved-id-macro")
# ifdef MOREFEM_LLVM_CLANG
// These pragma is required for most recent clang; current Apple clang doesn't know it yet.
PRAGMA_DIAGNOSTIC(ignored "-Wzero-as-null-pointer-constant")
# endif // MOREFEM_LLVM_CLANG
# endif // __clang__
#include "petscsnes.h"
......
......@@ -22,6 +22,12 @@ PRAGMA_DIAGNOSTIC(ignored "-Wold-style-cast")
# ifdef __clang__
PRAGMA_DIAGNOSTIC(ignored "-Wreserved-id-macro")
PRAGMA_DIAGNOSTIC(ignored "-Wcomma")
# ifdef MOREFEM_LLVM_CLANG
// These pragma is required for most recent clang; current Apple clang doesn't know it yet.
PRAGMA_DIAGNOSTIC(ignored "-Wzero-as-null-pointer-constant")
PRAGMA_DIAGNOSTIC(ignored "-Wcast-qual")
# endif // MOREFEM_LLVM_CLANG
# endif // __clang__
#ifdef MOREFEM_GCC
......
......@@ -22,6 +22,12 @@ PRAGMA_DIAGNOSTIC(ignored "-Wold-style-cast")
# ifdef __clang__
PRAGMA_DIAGNOSTIC(ignored "-Wcomma")
PRAGMA_DIAGNOSTIC(ignored "-Wreserved-id-macro")
# ifdef MOREFEM_LLVM_CLANG
// These pragma is required for most recent clang; current Apple clang doesn't know it yet.
PRAGMA_DIAGNOSTIC(ignored "-Wzero-as-null-pointer-constant")
PRAGMA_DIAGNOSTIC(ignored "-Wcast-qual")
# endif // MOREFEM_LLVM_CLANG
# endif // __clang__
#ifdef MOREFEM_GCC
......
......@@ -23,6 +23,12 @@ PRAGMA_DIAGNOSTIC(ignored "-Wold-style-cast")
# ifdef __clang__
PRAGMA_DIAGNOSTIC(ignored "-Wcomma")
PRAGMA_DIAGNOSTIC(ignored "-Wreserved-id-macro")
# ifdef MOREFEM_LLVM_CLANG
// These pragma is required for most recent clang; current Apple clang doesn't know it yet.
PRAGMA_DIAGNOSTIC(ignored "-Wzero-as-null-pointer-constant")
PRAGMA_DIAGNOSTIC(ignored "-Wcast-qual")
# endif // MOREFEM_LLVM_CLANG
# endif // __clang__
#include "petscviewer.h"
......
......@@ -26,6 +26,11 @@ PRAGMA_DIAGNOSTIC(ignored "-Wfloat-equal")
PRAGMA_DIAGNOSTIC(ignored "-Wdocumentation-unknown-command")
PRAGMA_DIAGNOSTIC(ignored "-Wshorten-64-to-32")
PRAGMA_DIAGNOSTIC(ignored "-Wreserved-id-macro")
# ifdef MOREFEM_LLVM_CLANG
// These pragma is required for most recent clang; current Apple clang doesn't know it yet.
PRAGMA_DIAGNOSTIC(ignored "-Wzero-as-null-pointer-constant")
# endif // MOREFEM_LLVM_CLANG
# endif // __clang__
# ifdef MOREFEM_GCC
......
......@@ -20,7 +20,10 @@ PRAGMA_DIAGNOSTIC(push)
PRAGMA_DIAGNOSTIC(ignored "-Wweak-vtables")
PRAGMA_DIAGNOSTIC(ignored "-Wdeprecated")
# ifdef MOREFEM_LLVM_CLANG
PRAGMA_DIAGNOSTIC(ignored "-Wshadow-field") // This pragma is required for most recent clang; current Apple clang doesn't know it yet.
// These pragma is required for most recent clang; current Apple clang doesn't know it yet.
PRAGMA_DIAGNOSTIC(ignored "-Wshadow-field")
PRAGMA_DIAGNOSTIC(ignored "-Wzero-as-null-pointer-constant")
# endif // MOREFEM_LLVM_CLANG
# endif // __clang__
......
......@@ -597,7 +597,7 @@ namespace MoReFEM
static_cast<int>(source),
AnyTag(),
GetCommunicator(),
MPI_STATUS_IGNORE);
nullptr); // MPI_STATUS_IGNORE is a 0 macro and triggers a warning!
PRAGMA_DIAGNOSTIC(pop)
......
......@@ -189,7 +189,7 @@ namespace MoReFEM
error_code = SNESSetConvergenceTest(snes_,
GetSnesConvergenceTestFunction(),
context,
NULL);
nullptr);
if (error_code)
throw ExceptionNS::Exception(error_code, "SNESSetConvergenceTest", invoking_file, invoking_line);
......@@ -199,7 +199,7 @@ namespace MoReFEM
if (error_code)
throw ExceptionNS::Exception(error_code, "SNESMonitorSet", invoking_file, invoking_line);
error_code = SNESSolve(snes_, NULL, solution.Internal());
error_code = SNESSolve(snes_, nullptr, solution.Internal());
if (error_code)
throw ExceptionNS::Exception(error_code, "SNESSolve", invoking_file, invoking_line);
......@@ -516,7 +516,7 @@ namespace MoReFEM
double Snes::GetAbsoluteTolerance(const char* invoking_file, int invoking_line) const
{
PetscReal value;
int error_code = SNESGetTolerances(snes_, &value, NULL, NULL, NULL, NULL);
int error_code = SNESGetTolerances(snes_, &value, nullptr, nullptr, nullptr, nullptr);
if (error_code)
throw ExceptionNS::Exception(error_code, "SNESGetTolerances", invoking_file, invoking_line);
......@@ -529,7 +529,7 @@ namespace MoReFEM
double Snes::GetRelativeTolerance(const char* invoking_file, int invoking_line) const
{
PetscReal value;
int error_code = SNESGetTolerances(snes_, NULL, &value, NULL, NULL, NULL);
int error_code = SNESGetTolerances(snes_, nullptr, &value, nullptr, nullptr, nullptr);
if (error_code)
throw ExceptionNS::Exception(error_code, "SNESGetTolerances", invoking_file, invoking_line);
......@@ -543,7 +543,7 @@ namespace MoReFEM
unsigned int Snes::NmaxIteration(const char* invoking_file, int invoking_line) const
{
PetscInt value;
int error_code = SNESGetTolerances(snes_, NULL, NULL, NULL, &value, NULL);
int error_code = SNESGetTolerances(snes_, nullptr, nullptr, nullptr, &value, nullptr);
if (error_code)
throw ExceptionNS::Exception(error_code, "SNESGetTolerances", invoking_file, invoking_line);
......
......@@ -275,10 +275,21 @@ namespace MoReFEM
{
if constexpr (Utilities::IsSpecializationOf<std::tuple, T>())
{
# ifdef MOREFEM_LLVM_CLANG
PRAGMA_DIAGNOSTIC(push)
PRAGMA_DIAGNOSTIC(ignored "-Wunused-lambda-capture")
//< because LLVM clang issues an erroneous warning with 'this' capture below.
# endif // MOREFEM_LLVM_CLANG
// See https://stackoverflow.com/questions/16387354/template-tuple-calling-a-function-on-each-element.
std::apply([this](auto ...x)
{ (..., PushOnStack(x)); },
value);
# ifdef MOREFEM_LLVM_CLANG
PRAGMA_DIAGNOSTIC(pop)
# endif // MOREFEM_LLVM_CLANG
}
else
{
......
......@@ -57,6 +57,7 @@ if(${CMAKE_C_COMPILER_ID} STREQUAL "AppleClang" OR ${CMAKE_C_COMPILER_ID} STREQU
add_cxx_compiler_flag("-Wno-documentation-unknown-command")
add_cxx_compiler_flag("-Wno-undefined-func-template")
add_cxx_compiler_flag("-Wno-c++1z-extensions")
# add_cxx_compiler_flag("-stdlib=libc++")
......@@ -67,6 +68,7 @@ if(${CMAKE_C_COMPILER_ID} STREQUAL "AppleClang" OR ${CMAKE_C_COMPILER_ID} STREQU
# Convenient macro to tag LLVM clang; useful as some warnings needs to be suppressed only for this more recent version of clang.
if (${CMAKE_C_COMPILER_ID} STREQUAL "Clang")
add_cxx_compiler_flag("-Wno-unused-template")
add_definitions(-DMOREFEM_LLVM_CLANG)
endif()
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment