From 1862abdd0512d4f2505b3807fedd20f6ccedb31f Mon Sep 17 00:00:00 2001 From: Larry Knox Date: Mon, 20 Apr 2020 16:03:08 -0500 Subject: Don't add general warnings flags for unsupported old versions of gcc and g++ (older than gcc/g++ 4.2). Correct gnu-cxxflags to determine warnings flags to be added based on C++ compiler version instead of C compiler version. --- config/cmake/HDFCXXCompilerFlags.cmake | 19 +++++++------ config/cmake/HDFCompilerFlags.cmake | 19 ++++++++----- config/gnu-cxxflags | 50 ++++++++++++++++++---------------- config/gnu-flags | 6 ++-- 4 files changed, 53 insertions(+), 41 deletions(-) diff --git a/config/cmake/HDFCXXCompilerFlags.cmake b/config/cmake/HDFCXXCompilerFlags.cmake index 6aa8784..721fca4 100644 --- a/config/cmake/HDFCXXCompilerFlags.cmake +++ b/config/cmake/HDFCXXCompilerFlags.cmake @@ -103,8 +103,10 @@ if (NOT MSVC) list (APPEND H5_CXXFLAGS0 "-Wsign-compare -Wtrigraphs -Wwrite-strings") endif() elseif (CMAKE_CXX_COMPILER_ID STREQUAL "GNU") - if (CMAKE_COMPILER_IS_GNUCXX AND CMAKE_CXX_COMPILER_LOADED) - # autotools always add the C flags with the CXX flags + if (CMAKE_COMPILER_IS_GNUCXX AND CMAKE_CXX_COMPILER_LOADED + AND NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 4.2) + # autotools always add the C flags with the CXX flags, except for + # with older versions that are no longer supported ADD_H5_FLAGS (HDF5_CMAKE_CXX_FLAGS "${HDF5_SOURCE_DIR}/config/gnu-warnings/general") ADD_H5_FLAGS (HDF5_CMAKE_CXX_FLAGS "${HDF5_SOURCE_DIR}/config/gnu-warnings/cxx-general") endif () @@ -141,16 +143,17 @@ if (NOT MSVC) endif () if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU") - # Append warning flags that only gcc 4.3+ knows about - # autotools always add the C flags with the CXX flags - ADD_H5_FLAGS (H5_CXXFLAGS1 "${HDF5_SOURCE_DIR}/config/gnu-warnings/4.3") - # # Technically, variable-length arrays are part of the C99 standard, but # we should approach them a bit cautiously... Only needed for gcc 4.X - if (CMAKE_CXX_COMPILER_VERSION VERSION_LESS 5.0) + if (CMAKE_CXX_COMPILER_VERSION VERSION_LESS 5.0 AND NOT CMAKE_C_COMPILER_VERSION VERSION_LESS 4.2) # autotools always add the C flags with the CXX flags ADD_H5_FLAGS (H5_CXXFLAGS1 "${HDF5_SOURCE_DIR}/config/gnu-warnings/4.2-4.last") endif () + # Append warning flags that only gcc 4.3+ knows about + # autotools always add the C flags with the CXX flags + if (CMAKE_C_COMPILER_VERSION VERSION_LESS 4.3 AND NOT CMAKE_C_COMPILER_VERSION VERSION_LESS 4.2) + ADD_H5_FLAGS (H5_CXXFLAGS1 "${HDF5_SOURCE_DIR}/config/gnu-warnings/4.3") + endif() # Append more extra warning flags that only gcc 4.4+ know about if (NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 4.4) @@ -172,7 +175,7 @@ if (NOT MSVC) endif () # Append more extra warning flags that only gcc 4.6 and less know about - if (CMAKE_CXX_COMPILER_VERSION VERSION_LESS 4.7) + if (CMAKE_CXX_COMPILER_VERSION VERSION_LESS 4.7 AND NOT CMAKE_C_COMPILER_VERSION VERSION_LESS 4.2) # autotools always add the C flags with the CXX flags ADD_H5_FLAGS (H5_CXXFLAGS1 "${HDF5_SOURCE_DIR}/config/gnu-warnings/4.2-4.6") endif () diff --git a/config/cmake/HDFCompilerFlags.cmake b/config/cmake/HDFCompilerFlags.cmake index 72141c0..a40b525 100644 --- a/config/cmake/HDFCompilerFlags.cmake +++ b/config/cmake/HDFCompilerFlags.cmake @@ -111,8 +111,11 @@ if (NOT MSVC) list (APPEND H5_CFLAGS0 "-Wsign-compare -Wtrigraphs -Wwrite-strings") endif() elseif (CMAKE_C_COMPILER_ID STREQUAL "GNU") - ADD_H5_FLAGS (HDF5_CMAKE_C_FLAGS "${HDF5_SOURCE_DIR}/config/gnu-warnings/general") - ADD_H5_FLAGS (H5_CFLAGS0 "${HDF5_SOURCE_DIR}/config/gnu-warnings/error-general") + # Add general CFlags except for older versions that are no longer supported + if (NOT CMAKE_C_COMPILER_VERSION VERSION_LESS 4.2) + ADD_H5_FLAGS (HDF5_CMAKE_C_FLAGS "${HDF5_SOURCE_DIR}/config/gnu-warnings/general") + ADD_H5_FLAGS (H5_CFLAGS0 "${HDF5_SOURCE_DIR}/config/gnu-warnings/error-general") + endif () # gcc automatically inlines based on the optimization level # this is just a failsafe list (APPEND H5_CFLAGS0 "-finline-functions") @@ -149,14 +152,16 @@ if (NOT MSVC) if (CMAKE_C_COMPILER_ID STREQUAL "GNU") - # Append warning flags that only gcc 4.3+ knows about - ADD_H5_FLAGS (H5_CFLAGS1 "${HDF5_SOURCE_DIR}/config/gnu-warnings/4.3") - # # Technically, variable-length arrays are part of the C99 standard, but # we should approach them a bit cautiously... Only needed for gcc 4.X - if (CMAKE_C_COMPILER_VERSION VERSION_LESS 5.0) + if (CMAKE_C_COMPILER_VERSION VERSION_LESS 5.0 AND NOT CMAKE_C_COMPILER_VERSION VERSION_LESS 4.2) ADD_H5_FLAGS (H5_CFLAGS1 "${HDF5_SOURCE_DIR}/config/gnu-warnings/4.2-4.last") endif () + # Append warning flags that only gcc 4.3+ knows about + if (CMAKE_C_COMPILER_VERSION VERSION_LESS 4.3 AND NOT CMAKE_C_COMPILER_VERSION VERSION_LESS 4.2) + ADD_H5_FLAGS (H5_CFLAGS1 "${HDF5_SOURCE_DIR}/config/gnu-warnings/4.3") + endif () + # Append more extra warning flags that only gcc 4.4+ know about if (NOT CMAKE_C_COMPILER_VERSION VERSION_LESS 4.4) @@ -174,7 +179,7 @@ if (NOT MSVC) endif () # Append more extra warning flags that only gcc 4.6 and less know about - if (CMAKE_C_COMPILER_VERSION VERSION_LESS 4.7) + if (CMAKE_C_COMPILER_VERSION VERSION_LESS 4.7 AND NOT CMAKE_C_COMPILER_VERSION VERSION_LESS 4.2) ADD_H5_FLAGS (H5_CFLAGS1 "${HDF5_SOURCE_DIR}/config/gnu-warnings/4.2-4.6") endif () diff --git a/config/gnu-cxxflags b/config/gnu-cxxflags index e177aef..b3b082d 100644 --- a/config/gnu-cxxflags +++ b/config/gnu-cxxflags @@ -79,9 +79,9 @@ if test "X-" = "X-$cxx_flags_set"; then cxx_vers_major=`echo $cxx_version | cut -f1 -d.` cxx_vers_minor=`echo $cxx_version | cut -f2 -d.` cxx_vers_patch=`echo $cxx_version | cut -f3 -d.` - test -n "$cc_vers_major" || cxx_vers_major=0 - test -n "$cc_vers_minor" || cxx_vers_minor=0 - test -n "$cc_vers_patch" || cxx_vers_patch=0 + test -n "$cxx_vers_major" || cxx_vers_major=0 + test -n "$cxx_vers_minor" || cxx_vers_minor=0 + test -n "$cxx_vers_patch" || cxx_vers_patch=0 cxx_vers_all=`expr $cxx_vers_major '*' 1000000 + $cxx_vers_minor '*' 1000 + $cxx_vers_patch` fi @@ -180,10 +180,12 @@ if test "X-g++" = "X-$cxx_vendor"; then # General # ########### - H5_CXXFLAGS="$H5_CXXFLAGS $(load_gnu_arguments general)" - H5_ECXXFLAGS="$H5_ECXXFLAGS $(load_gnu_arguments error-general)" - H5_CXXFLAGS="$H5_CXXFLAGS $(load_gnu_arguments cxx-general)" - #H5_ECXXFLAGS="$H5_ECXXFLAGS $(load_gnu_arguments error-cxx-general)" + if test $cxx_vers_major -eq 4 -a $cxx_vers_minor -ge 2 -o $cxx_vers_major -gt 4; then + H5_CXXFLAGS="$H5_CXXFLAGS $(load_gnu_arguments general)" + H5_ECXXFLAGS="$H5_ECXXFLAGS $(load_gnu_arguments error-general)" + H5_CXXFLAGS="$H5_CXXFLAGS $(load_gnu_arguments cxx-general)" + #H5_ECXXFLAGS="$H5_ECXXFLAGS $(load_gnu_arguments error-cxx-general)" + fi ###################### # Developer warnings # @@ -197,27 +199,27 @@ if test "X-g++" = "X-$cxx_vendor"; then ####################### # GCC 4.2 through 4.6 - if test $cc_vers_major -eq 4 -a $cc_vers_minor -ge 2 -o $cc_vers_major -eq 4 -a $cc_vers_minor -le 6; then + if test $cxx_vers_major -eq 4 -a $cxx_vers_minor -ge 2 -o $cxx_vers_major -eq 4 -a $cxx_vers_minor -le 6; then H5_CXXFLAGS="$H5_CXXFLAGS $(load_gnu_arguments 4.2-4.6)" fi # GCC 4.2 through 4.3 - if test $cc_vers_major -eq 4 -a $cc_vers_minor -ge 2 -o $cc_vers_major -eq 4 -a $cc_vers_minor -le 3; then + if test $cxx_vers_major -eq 4 -a $cxx_vers_minor -ge 2 -o $cxx_vers_major -eq 4 -a $cxx_vers_minor -le 3; then H5_CXXFLAGS="$H5_CXXFLAGS $(load_gnu_arguments 4.2-4.3)" fi # GCC 4.5 through 4.6 - if test $cc_vers_major -eq 4 -a $cc_vers_minor -ge 5 -o $cc_vers_major -eq 4 -a $cc_vers_minor -le 6; then + if test $cxx_vers_major -eq 4 -a $cxx_vers_minor -ge 5 -o $cxx_vers_major -eq 4 -a $cxx_vers_minor -le 6; then H5_CXXFLAGS="$H5_CXXFLAGS $(load_gnu_arguments 4.5-4.6)" fi # GCC 4.2 through 4.4 - if test $cc_vers_major -eq 4 -a $cc_vers_minor -ge 2 -a $cc_vers_major -eq 4 -a $cc_vers_minor -le 4; then + if test $cxx_vers_major -eq 4 -a $cxx_vers_minor -ge 2 -a $cxx_vers_major -eq 4 -a $cxx_vers_minor -le 4; then H5_CXXFLAGS="$H5_CXXFLAGS $(load_gnu_arguments 4.2-4.4)" fi # GCC 4.2 through the end of GCC 4 series - if test $cc_vers_major -eq 4 -a $cc_vers_minor -ge 2; then + if test $cxx_vers_major -eq 4 -a $cxx_vers_minor -ge 2; then H5_CXXFLAGS="$H5_CXXFLAGS $(load_gnu_arguments 4.2-4.last)" fi @@ -226,68 +228,68 @@ if test "X-g++" = "X-$cxx_vendor"; then ############################# # gcc >= 4.3 - if test $cc_vers_major -ge 5 -o $cc_vers_major -eq 4 -a $cc_vers_minor -ge 3; then + if test $cxx_vers_major -ge 5 -o $cxx_vers_major -eq 4 -a $cxx_vers_minor -ge 3; then H5_CXXFLAGS="$H5_CXXFLAGS $(load_gnu_arguments 4.3)" fi # gcc >= 4.4 - if test $cc_vers_major -ge 5 -o $cc_vers_major -eq 4 -a $cc_vers_minor -ge 4; then + if test $cxx_vers_major -ge 5 -o $cxx_vers_major -eq 4 -a $cxx_vers_minor -ge 4; then H5_CXXFLAGS="$H5_CXXFLAGS $(load_gnu_arguments 4.4)" fi # gcc >= 4.5 - if test $cc_vers_major -ge 5 -o $cc_vers_major -eq 4 -a $cc_vers_minor -ge 5; then + if test $cxx_vers_major -ge 5 -o $cxx_vers_major -eq 4 -a $cxx_vers_minor -ge 5; then H5_CXXFLAGS="$H5_CXXFLAGS $(load_gnu_arguments 4.5)" DEVELOPER_WARNING_CXXFLAGS="$DEVELOPER_WARNING_CXXFLAGS $(load_gnu_arguments developer-4.5)" NO_DEVELOPER_WARNING_CXXFLAGS="$NO_DEVELOPER_WARNING_CXXFLAGS $(load_gnu_arguments no-developer-4.5)" fi # gcc >= 4.6 - if test $cc_vers_major -ge 5 -o $cc_vers_major -eq 4 -a $cc_vers_minor -ge 6; then + if test $cxx_vers_major -ge 5 -o $cxx_vers_major -eq 4 -a $cxx_vers_minor -ge 6; then H5_CXXFLAGS="$H5_CXXFLAGS $(load_gnu_arguments 4.6)" DEVELOPER_WARNING_CXXFLAGS="$DEVELOPER_WARNING_CXXFLAGS $(load_gnu_arguments developer-4.6)" NO_DEVELOPER_WARNING_CXXFLAGS="$NO_DEVELOPER_WARNING_CXXFLAGS $(load_gnu_arguments no-developer-4.6)" fi # gcc >= 4.7 - if test $cc_vers_major -ge 5 -o $cc_vers_major -eq 4 -a $cc_vers_minor -ge 7; then + if test $cxx_vers_major -ge 5 -o $cxx_vers_major -eq 4 -a $cxx_vers_minor -ge 7; then H5_CXXFLAGS="$H5_CXXFLAGS $(load_gnu_arguments 4.7)" DEVELOPER_WARNING_CXXFLAGS="$DEVELOPER_WARNING_CXXFLAGS $(load_gnu_arguments developer-4.7)" NO_DEVELOPER_WARNING_CXXFLAGS="$NO_DEVELOPER_WARNING_CXXFLAGS $(load_gnu_arguments no-developer-4.7)" fi # gcc >= 4.8 - if test $cc_vers_major -ge 5 -o $cc_vers_major -eq 4 -a $cc_vers_minor -ge 8; then + if test $cxx_vers_major -ge 5 -o $cxx_vers_major -eq 4 -a $cxx_vers_minor -ge 8; then H5_CXXFLAGS="$H5_CXXFLAGS $(load_gnu_arguments 4.8)" DEVELOPER_WARNING_CXXFLAGS="$DEVELOPER_WARNING_CXXFLAGS $(load_gnu_arguments developer-4.8)" NO_DEVELOPER_WARNING_CXXFLAGS="$NO_DEVELOPER_WARNING_CXXFLAGS $(load_gnu_arguments no-developer-4.8)" fi # gcc >= 4.9 - if test $cc_vers_major -ge 5 -o $cc_vers_major -eq 4 -a $cc_vers_minor -ge 9; then + if test $cxx_vers_major -ge 5 -o $cxx_vers_major -eq 4 -a $cxx_vers_minor -ge 9; then H5_CXXFLAGS="$H5_CXXFLAGS $(load_gnu_arguments 4.9)" H5_CXXFLAGS="$H5_CXXFLAGS $(load_gnu_arguments cxx-4.9)" fi # gcc >= 5 - if test $cc_vers_major -ge 5; then + if test $cxx_vers_major -ge 5; then H5_CXXFLAGS="$H5_CXXFLAGS $(load_gnu_arguments 5)" H5_ECXXFLAGS="$H5_ECXXFLAGS $(load_gnu_arguments error-5)" fi # gcc >= 6 - if test $cc_vers_major -ge 6; then + if test $cxx_vers_major -ge 6; then H5_CXXFLAGS="$H5_CXXFLAGS $(load_gnu_arguments 6)" fi # gcc >= 7 - if test $cc_vers_major -ge 7; then + if test $cxx_vers_major -ge 7; then H5_CXXFLAGS="$H5_CXXFLAGS $(load_gnu_arguments 7)" DEVELOPER_WARNING_CXXFLAGS="$DEVELOPER_WARNING_CXXFLAGS $(load_gnu_arguments developer-7)" fi # gcc 8 - if test $cc_vers_major -ge 8; then + if test $cxx_vers_major -ge 8; then H5_CXXFLAGS="$H5_CXXFLAGS $(load_gnu_arguments 8)" H5_ECXXFLAGS="$H5_ECXXFLAGS $(load_gnu_arguments error-8)" DEVELOPER_WARNING_CXXFLAGS="$DEVELOPER_WARNING_CXXFLAGS $(load_gnu_arguments developer-8)" @@ -295,7 +297,7 @@ if test "X-g++" = "X-$cxx_vendor"; then fi # gcc 9 - if test $cc_vers_major -ge 9; then + if test $cxx_vers_major -ge 9; then H5_CXXFLAGS="$H5_CXXFLAGS $(load_gnu_arguments 9)" fi diff --git a/config/gnu-flags b/config/gnu-flags index ad07552..dba9324 100644 --- a/config/gnu-flags +++ b/config/gnu-flags @@ -188,8 +188,10 @@ if test "X-gcc" = "X-$cc_vendor"; then # General # ########### - H5_CFLAGS="$H5_CFLAGS $(load_gnu_arguments general)" - H5_ECFLAGS="$H5_ECFLAGS $(load_gnu_arguments error-general)" + if test $cc_vers_major -eq 4 -a $cc_vers_minor -ge 2 -o $cc_vers_major -gt 4; then + H5_CFLAGS="$H5_CFLAGS $(load_gnu_arguments general)" + H5_ECFLAGS="$H5_ECFLAGS $(load_gnu_arguments error-general)" + fi ###################### # Developer warnings # -- cgit v0.12 From f965a24db12e6eee42e214742ddc7eb374eee06c Mon Sep 17 00:00:00 2001 From: Allen Byrne Date: Thu, 23 Apr 2020 14:32:29 -0500 Subject: TRILAB-244 separate CXX warnings and errors from C --- MANIFEST | 3 +++ c++/test/tarray.cpp | 1 - c++/test/tobject.cpp | 2 +- c++/test/ttypes.cpp | 6 +++--- config/cmake/HDFCXXCompilerFlags.cmake | 17 ++++++++------- config/gnu-cxxflags | 34 ++++++++++++++---------------- config/gnu-fflags | 2 +- config/gnu-flags | 38 +++++++++++++++++----------------- config/gnu-warnings/cxx-5 | 1 + config/gnu-warnings/cxx-error-5 | 11 ++++++++++ config/gnu-warnings/cxx-error-general | 32 ++++++++++++++++++++++++++++ config/gnu-warnings/cxx-general | 16 ++++++++++++-- config/gnu-warnings/error-8 | 20 ++++++++++++++++-- 13 files changed, 128 insertions(+), 55 deletions(-) create mode 100644 config/gnu-warnings/cxx-5 create mode 100644 config/gnu-warnings/cxx-error-5 create mode 100644 config/gnu-warnings/cxx-error-general diff --git a/MANIFEST b/MANIFEST index 97e5277..152fb1c 100644 --- a/MANIFEST +++ b/MANIFEST @@ -165,6 +165,9 @@ ./config/gnu-warnings/9 ./config/gnu-warnings/cxx-general ./config/gnu-warnings/cxx-4.9 +./config/gnu-warnings/cxx-5 +./config/gnu-warnings/cxx-error-5 +./config/gnu-warnings/cxx-error-general ./config/gnu-warnings/developer-4.5 ./config/gnu-warnings/developer-4.6 ./config/gnu-warnings/developer-4.7 diff --git a/c++/test/tarray.cpp b/c++/test/tarray.cpp index fccc556..69c58f8 100644 --- a/c++/test/tarray.cpp +++ b/c++/test/tarray.cpp @@ -368,7 +368,6 @@ static void test_array_info() float f[ARRAY1_DIM1]; } s1_t; s1_t wdata[SPACE1_DIM1][ARRAY1_DIM1]; // Information to write - s1_t rdata[SPACE1_DIM1][ARRAY1_DIM1]; // Information read in hsize_t sdims1[] = {SPACE1_DIM1}; hsize_t tdims1[] = {ARRAY1_DIM1}; int ii; // counting variables diff --git a/c++/test/tobject.cpp b/c++/test/tobject.cpp index 232ece2..138c4ca 100644 --- a/c++/test/tobject.cpp +++ b/c++/test/tobject.cpp @@ -430,7 +430,6 @@ const H5std_string DSETNAME("dataset"); static void test_open_object_header() { hsize_t dims[2]; - H5G_info_t ginfo; /* Group info struct */ // Output message about test being performed SUBTEST("Group::getObjId"); @@ -485,6 +484,7 @@ static void test_open_object_header() dset.setId(obj_dset); dspace = dset.getSpace(); bool is_simple = dspace.isSimple(); + verify_val(is_simple, true, "isSimple", __LINE__, __FILE__); dspace.close(); // Open datatype object from the group diff --git a/c++/test/ttypes.cpp b/c++/test/ttypes.cpp index 0de66d7..81ad983 100644 --- a/c++/test/ttypes.cpp +++ b/c++/test/ttypes.cpp @@ -403,7 +403,7 @@ static void test_vltype() // Verify that the copied type has a valid id bool is_valid = IdComponent::isValid(vltype2.getId()); - verify_val(in_class, true, "isValid on vltype2", __LINE__, __FILE__); + verify_val(is_valid, true, "isValid on vltype2", __LINE__, __FILE__); in_class = vltype2.detectClass(H5T_VLEN); verify_val(in_class, true, "VarLenType::detectClass() with H5T_VLEN for vltype2", __LINE__, __FILE__); @@ -1010,8 +1010,8 @@ static void test_encode_decode() FloatType decoded_flttyp(decoded_flt_ptr->getId()); verify_val(flttyp == decoded_flttyp, true, "DataType::decode", __LINE__, __FILE__); - H5std_string norm_string; - H5T_norm_t mant_norm = decoded_flttyp.getNorm(norm_string); + //H5std_string norm_string; + //H5T_norm_t mant_norm = decoded_flttyp.getNorm(norm_string); //verify_val(decoded_flttyp.isVariableStr(), true, "DataType::decode", __LINE__, __FILE__); delete decoded_flt_ptr; diff --git a/config/cmake/HDFCXXCompilerFlags.cmake b/config/cmake/HDFCXXCompilerFlags.cmake index 721fca4..400ba8c 100644 --- a/config/cmake/HDFCXXCompilerFlags.cmake +++ b/config/cmake/HDFCXXCompilerFlags.cmake @@ -104,11 +104,11 @@ if (NOT MSVC) endif() elseif (CMAKE_CXX_COMPILER_ID STREQUAL "GNU") if (CMAKE_COMPILER_IS_GNUCXX AND CMAKE_CXX_COMPILER_LOADED - AND NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 4.2) - # autotools always add the C flags with the CXX flags, except for - # with older versions that are no longer supported - ADD_H5_FLAGS (HDF5_CMAKE_CXX_FLAGS "${HDF5_SOURCE_DIR}/config/gnu-warnings/general") + AND CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 4.2) + # autotools adds the C flags with the CXX flags for g++ compiler + # versions 4.2 and above. ADD_H5_FLAGS (HDF5_CMAKE_CXX_FLAGS "${HDF5_SOURCE_DIR}/config/gnu-warnings/cxx-general") + ADD_H5_FLAGS (H5_CXXFLAGS0 "${HDF5_SOURCE_DIR}/config/gnu-warnings/cxx-error-general") endif () elseif (CMAKE_CXX_COMPILER_ID STREQUAL "Clang") ADD_H5_FLAGS (HDF5_CMAKE_CXX_FLAGS "${HDF5_SOURCE_DIR}/config/clang-warnings/general") @@ -167,10 +167,10 @@ if (NOT MSVC) ADD_H5_FLAGS (H5_CXXFLAGS1 "${HDF5_SOURCE_DIR}/config/gnu-warnings/4.5") if (HDF5_ENABLE_DEV_WARNINGS) # autotools always add the C flags with the CXX flags - ADD_H5_FLAGS (H5_CXXFLAGS1 "${HDF5_SOURCE_DIR}/config/gnu-warnings/developer-4.5") + #ADD_H5_FLAGS (H5_CXXFLAGS1 "${HDF5_SOURCE_DIR}/config/gnu-warnings/developer-4.5") else () # autotools always add the C flags with the CXX flags - ADD_H5_FLAGS (H5_CXXFLAGS1 "${HDF5_SOURCE_DIR}/config/gnu-warnings/no-developer-4.5") + #ADD_H5_FLAGS (H5_CXXFLAGS1 "${HDF5_SOURCE_DIR}/config/gnu-warnings/no-developer-4.5") endif () endif () @@ -232,8 +232,8 @@ if (NOT MSVC) # Append more extra warning flags that only gcc 5.1+ know about if (NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 5.0) # autotools always add the C flags with the CXX flags - ADD_H5_FLAGS (H5_CXXFLAGS1 "${HDF5_SOURCE_DIR}/config/gnu-warnings/5") - ADD_H5_FLAGS (H5_CXXFLAGS1 "${HDF5_SOURCE_DIR}/config/gnu-warnings/error-5") + ADD_H5_FLAGS (H5_CXXFLAGS1 "${HDF5_SOURCE_DIR}/config/gnu-warnings/cxx-5") + ADD_H5_FLAGS (H5_CXXFLAGS1 "${HDF5_SOURCE_DIR}/config/gnu-warnings/cxx-error-5") endif () # Append more extra warning flags that only gcc 6.x+ know about @@ -258,6 +258,7 @@ if (NOT MSVC) if (NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 8.0) # autotools always add the C flags with the CXX flags ADD_H5_FLAGS (H5_CXXFLAGS3 "${HDF5_SOURCE_DIR}/config/gnu-warnings/8") + #ADD_H5_FLAGS (H5_CXXFLAGS3 "${HDF5_SOURCE_DIR}/config/gnu-warnings/error-8") if (HDF5_ENABLE_DEV_WARNINGS) # autotools always add the C flags with the CXX flags ADD_H5_FLAGS (H5_CXXFLAGS3 "${HDF5_SOURCE_DIR}/config/gnu-warnings/developer-8") diff --git a/config/gnu-cxxflags b/config/gnu-cxxflags index b3b082d..b2ef36d 100644 --- a/config/gnu-cxxflags +++ b/config/gnu-cxxflags @@ -44,7 +44,7 @@ demote_errors() load_gnu_arguments() { set -- $(for arg; do - sed 's,#.*$,,' $srcdir/config/gnu-warnings/${arg} | demote_errors + sed 's,#.*$,,' $srcdir/config/gnu-warnings/${arg} done) IFS=' ' echo "$*" } @@ -181,10 +181,8 @@ if test "X-g++" = "X-$cxx_vendor"; then ########### if test $cxx_vers_major -eq 4 -a $cxx_vers_minor -ge 2 -o $cxx_vers_major -gt 4; then - H5_CXXFLAGS="$H5_CXXFLAGS $(load_gnu_arguments general)" - H5_ECXXFLAGS="$H5_ECXXFLAGS $(load_gnu_arguments error-general)" H5_CXXFLAGS="$H5_CXXFLAGS $(load_gnu_arguments cxx-general)" - #H5_ECXXFLAGS="$H5_ECXXFLAGS $(load_gnu_arguments error-cxx-general)" + H5_ECXXFLAGS="$H5_ECXXFLAGS $(load_gnu_arguments cxx-error-general)" fi ###################### @@ -240,29 +238,29 @@ if test "X-g++" = "X-$cxx_vendor"; then # gcc >= 4.5 if test $cxx_vers_major -ge 5 -o $cxx_vers_major -eq 4 -a $cxx_vers_minor -ge 5; then H5_CXXFLAGS="$H5_CXXFLAGS $(load_gnu_arguments 4.5)" - DEVELOPER_WARNING_CXXFLAGS="$DEVELOPER_WARNING_CXXFLAGS $(load_gnu_arguments developer-4.5)" - NO_DEVELOPER_WARNING_CXXFLAGS="$NO_DEVELOPER_WARNING_CXXFLAGS $(load_gnu_arguments no-developer-4.5)" + #DEVELOPER_WARNING_CXXFLAGS="$DEVELOPER_WARNING_CXXFLAGS $(load_gnu_arguments developer-4.5)" + #NO_DEVELOPER_WARNING_CXXFLAGS="$NO_DEVELOPER_WARNING_CXXFLAGS $(load_gnu_arguments no-developer-4.5)" fi # gcc >= 4.6 if test $cxx_vers_major -ge 5 -o $cxx_vers_major -eq 4 -a $cxx_vers_minor -ge 6; then H5_CXXFLAGS="$H5_CXXFLAGS $(load_gnu_arguments 4.6)" - DEVELOPER_WARNING_CXXFLAGS="$DEVELOPER_WARNING_CXXFLAGS $(load_gnu_arguments developer-4.6)" - NO_DEVELOPER_WARNING_CXXFLAGS="$NO_DEVELOPER_WARNING_CXXFLAGS $(load_gnu_arguments no-developer-4.6)" + DEVELOPER_WARNING_CXXFLAGS="$DEVELOPER_WARNING_CXXFLAGS $(load_gnu_arguments developer-4.6)" + NO_DEVELOPER_WARNING_CXXFLAGS="$NO_DEVELOPER_WARNING_CXXFLAGS $(load_gnu_arguments no-developer-4.6)" fi # gcc >= 4.7 if test $cxx_vers_major -ge 5 -o $cxx_vers_major -eq 4 -a $cxx_vers_minor -ge 7; then H5_CXXFLAGS="$H5_CXXFLAGS $(load_gnu_arguments 4.7)" - DEVELOPER_WARNING_CXXFLAGS="$DEVELOPER_WARNING_CXXFLAGS $(load_gnu_arguments developer-4.7)" - NO_DEVELOPER_WARNING_CXXFLAGS="$NO_DEVELOPER_WARNING_CXXFLAGS $(load_gnu_arguments no-developer-4.7)" + DEVELOPER_WARNING_CXXFLAGS="$DEVELOPER_WARNING_CXXFLAGS $(load_gnu_arguments developer-4.7)" + NO_DEVELOPER_WARNING_CXXFLAGS="$NO_DEVELOPER_WARNING_CXXFLAGS $(load_gnu_arguments no-developer-4.7)" fi # gcc >= 4.8 if test $cxx_vers_major -ge 5 -o $cxx_vers_major -eq 4 -a $cxx_vers_minor -ge 8; then H5_CXXFLAGS="$H5_CXXFLAGS $(load_gnu_arguments 4.8)" - DEVELOPER_WARNING_CXXFLAGS="$DEVELOPER_WARNING_CXXFLAGS $(load_gnu_arguments developer-4.8)" - NO_DEVELOPER_WARNING_CXXFLAGS="$NO_DEVELOPER_WARNING_CXXFLAGS $(load_gnu_arguments no-developer-4.8)" + DEVELOPER_WARNING_CXXFLAGS="$DEVELOPER_WARNING_CXXFLAGS $(load_gnu_arguments developer-4.8)" + NO_DEVELOPER_WARNING_CXXFLAGS="$NO_DEVELOPER_WARNING_CXXFLAGS $(load_gnu_arguments no-developer-4.8)" fi # gcc >= 4.9 @@ -273,8 +271,8 @@ if test "X-g++" = "X-$cxx_vendor"; then # gcc >= 5 if test $cxx_vers_major -ge 5; then - H5_CXXFLAGS="$H5_CXXFLAGS $(load_gnu_arguments 5)" - H5_ECXXFLAGS="$H5_ECXXFLAGS $(load_gnu_arguments error-5)" + H5_CXXFLAGS="$H5_CXXFLAGS $(load_gnu_arguments cxx-5)" + H5_ECXXFLAGS="$H5_ECXXFLAGS $(load_gnu_arguments cxx-error-5)" fi # gcc >= 6 @@ -285,15 +283,15 @@ if test "X-g++" = "X-$cxx_vendor"; then # gcc >= 7 if test $cxx_vers_major -ge 7; then H5_CXXFLAGS="$H5_CXXFLAGS $(load_gnu_arguments 7)" - DEVELOPER_WARNING_CXXFLAGS="$DEVELOPER_WARNING_CXXFLAGS $(load_gnu_arguments developer-7)" + DEVELOPER_WARNING_CXXFLAGS="$DEVELOPER_WARNING_CXXFLAGS $(load_gnu_arguments developer-7)" fi # gcc 8 if test $cxx_vers_major -ge 8; then H5_CXXFLAGS="$H5_CXXFLAGS $(load_gnu_arguments 8)" - H5_ECXXFLAGS="$H5_ECXXFLAGS $(load_gnu_arguments error-8)" - DEVELOPER_WARNING_CXXFLAGS="$DEVELOPER_WARNING_CXXFLAGS $(load_gnu_arguments developer-8)" - NO_DEVELOPER_WARNING_CXXFLAGS="$NO_DEVELOPER_WARNING_CXXFLAGS $(load_gnu_arguments no-developer-8)" + #H5_ECXXFLAGS="$H5_ECXXFLAGS $(load_gnu_arguments error-8)" + DEVELOPER_WARNING_CXXFLAGS="$DEVELOPER_WARNING_CXXFLAGS $(load_gnu_arguments developer-8)" + NO_DEVELOPER_WARNING_CXXFLAGS="$NO_DEVELOPER_WARNING_CXXFLAGS $(load_gnu_arguments no-developer-8)" fi # gcc 9 diff --git a/config/gnu-fflags b/config/gnu-fflags index f58f10c..eb3519c 100644 --- a/config/gnu-fflags +++ b/config/gnu-fflags @@ -26,7 +26,7 @@ load_gnu_arguments() { set -- $(for arg; do - sed 's,#.*$,,' $srcdir/config/gnu-warnings/${arg} | demote_errors + sed 's,#.*$,,' $srcdir/config/gnu-warnings/${arg} done) IFS=' ' echo "$*" } diff --git a/config/gnu-flags b/config/gnu-flags index dba9324..f391d7b 100644 --- a/config/gnu-flags +++ b/config/gnu-flags @@ -28,11 +28,11 @@ PROMOTE_ERRORS_DFLT=no # demote_errors() { - if [ ${PROMOTE_ERRORS:-${PROMOTE_ERRORS_DFLT}} = no ]; then - sed 's,-Werror=,-W,g' - else - cat - fi + if [ ${PROMOTE_ERRORS:-${PROMOTE_ERRORS_DFLT}} = no ]; then + sed 's,-Werror=,-W,g' + else + cat + fi } # @@ -44,7 +44,7 @@ demote_errors() load_gnu_arguments() { set -- $(for arg; do - sed 's,#.*$,,' $srcdir/config/gnu-warnings/${arg} | demote_errors + sed 's,#.*$,,' $srcdir/config/gnu-warnings/${arg} done) IFS=' ' echo "$*" } @@ -212,7 +212,7 @@ if test "X-gcc" = "X-$cc_vendor"; then # GCC 4.2 through 4.3 if test $cc_vers_major -eq 4 -a $cc_vers_minor -ge 2 -o $cc_vers_major -eq 4 -a $cc_vers_minor -le 3; then H5_CFLAGS="$H5_CFLAGS $(load_gnu_arguments 4.2-4.3)" - fi + fi # GCC 4.5 through 4.6 if test $cc_vers_major -eq 4 -a $cc_vers_minor -ge 5 -o $cc_vers_major -eq 4 -a $cc_vers_minor -le 6; then @@ -236,7 +236,7 @@ if test "X-gcc" = "X-$cc_vendor"; then # gcc >= 4.3 if test $cc_vers_major -ge 5 -o $cc_vers_major -eq 4 -a $cc_vers_minor -ge 3; then H5_CFLAGS="$H5_CFLAGS $(load_gnu_arguments 4.3)" - fi + fi # gcc >= 4.4 if test $cc_vers_major -ge 5 -o $cc_vers_major -eq 4 -a $cc_vers_minor -ge 4; then @@ -246,29 +246,29 @@ if test "X-gcc" = "X-$cc_vendor"; then # gcc >= 4.5 if test $cc_vers_major -ge 5 -o $cc_vers_major -eq 4 -a $cc_vers_minor -ge 5; then H5_CFLAGS="$H5_CFLAGS $(load_gnu_arguments 4.5)" - DEVELOPER_WARNING_CFLAGS="$DEVELOPER_WARNING_CFLAGS $(load_gnu_arguments developer-4.5)" - NO_DEVELOPER_WARNING_CFLAGS="$NO_DEVELOPER_WARNING_CFLAGS $(load_gnu_arguments no-developer-4.5)" + DEVELOPER_WARNING_CFLAGS="$DEVELOPER_WARNING_CFLAGS $(load_gnu_arguments developer-4.5)" + NO_DEVELOPER_WARNING_CFLAGS="$NO_DEVELOPER_WARNING_CFLAGS $(load_gnu_arguments no-developer-4.5)" fi # gcc >= 4.6 if test $cc_vers_major -ge 5 -o $cc_vers_major -eq 4 -a $cc_vers_minor -ge 6; then H5_CFLAGS="$H5_CFLAGS $(load_gnu_arguments 4.6)" - DEVELOPER_WARNING_CFLAGS="$DEVELOPER_WARNING_CFLAGS $(load_gnu_arguments developer-4.6)" - NO_DEVELOPER_WARNING_CFLAGS="$NO_DEVELOPER_WARNING_CFLAGS $(load_gnu_arguments no-developer-4.6)" + DEVELOPER_WARNING_CFLAGS="$DEVELOPER_WARNING_CFLAGS $(load_gnu_arguments developer-4.6)" + NO_DEVELOPER_WARNING_CFLAGS="$NO_DEVELOPER_WARNING_CFLAGS $(load_gnu_arguments no-developer-4.6)" fi # gcc >= 4.7 if test $cc_vers_major -ge 5 -o $cc_vers_major -eq 4 -a $cc_vers_minor -ge 7; then H5_CFLAGS="$H5_CFLAGS $(load_gnu_arguments 4.7)" - DEVELOPER_WARNING_CFLAGS="$DEVELOPER_WARNING_CFLAGS $(load_gnu_arguments developer-4.7)" - NO_DEVELOPER_WARNING_CFLAGS="$NO_DEVELOPER_WARNING_CFLAGS $(load_gnu_arguments no-developer-4.7)" + DEVELOPER_WARNING_CFLAGS="$DEVELOPER_WARNING_CFLAGS $(load_gnu_arguments developer-4.7)" + NO_DEVELOPER_WARNING_CFLAGS="$NO_DEVELOPER_WARNING_CFLAGS $(load_gnu_arguments no-developer-4.7)" fi # gcc >= 4.8 if test $cc_vers_major -ge 5 -o $cc_vers_major -eq 4 -a $cc_vers_minor -ge 8; then H5_CFLAGS="$H5_CFLAGS $(load_gnu_arguments 4.8)" - DEVELOPER_WARNING_CFLAGS="$DEVELOPER_WARNING_CFLAGS $(load_gnu_arguments developer-4.8)" - NO_DEVELOPER_WARNING_CFLAGS="$NO_DEVELOPER_WARNING_CFLAGS $(load_gnu_arguments no-developer-4.8)" + DEVELOPER_WARNING_CFLAGS="$DEVELOPER_WARNING_CFLAGS $(load_gnu_arguments developer-4.8)" + NO_DEVELOPER_WARNING_CFLAGS="$NO_DEVELOPER_WARNING_CFLAGS $(load_gnu_arguments no-developer-4.8)" fi # gcc >= 4.9 @@ -290,15 +290,15 @@ if test "X-gcc" = "X-$cc_vendor"; then # gcc >= 7 if test $cc_vers_major -ge 7; then H5_CFLAGS="$H5_CFLAGS $(load_gnu_arguments 7)" - DEVELOPER_WARNING_CFLAGS="$DEVELOPER_WARNING_CFLAGS $(load_gnu_arguments developer-7)" + DEVELOPER_WARNING_CFLAGS="$DEVELOPER_WARNING_CFLAGS $(load_gnu_arguments developer-7)" fi # gcc 8 if test $cc_vers_major -ge 8; then H5_CFLAGS="$H5_CFLAGS $(load_gnu_arguments 8)" H5_ECFLAGS="$H5_ECFLAGS $(load_gnu_arguments error-8)" - DEVELOPER_WARNING_CFLAGS="$DEVELOPER_WARNING_CFLAGS $(load_gnu_arguments developer-8)" - NO_DEVELOPER_WARNING_CFLAGS="$NO_DEVELOPER_WARNING_CFLAGS $(load_gnu_arguments no-developer-8)" + DEVELOPER_WARNING_CFLAGS="$DEVELOPER_WARNING_CFLAGS $(load_gnu_arguments developer-8)" + NO_DEVELOPER_WARNING_CFLAGS="$NO_DEVELOPER_WARNING_CFLAGS $(load_gnu_arguments no-developer-8)" fi # gcc 9 diff --git a/config/gnu-warnings/cxx-5 b/config/gnu-warnings/cxx-5 new file mode 100644 index 0000000..723e448 --- /dev/null +++ b/config/gnu-warnings/cxx-5 @@ -0,0 +1 @@ +-Warray-bounds=2 diff --git a/config/gnu-warnings/cxx-error-5 b/config/gnu-warnings/cxx-error-5 new file mode 100644 index 0000000..8cc8c9d --- /dev/null +++ b/config/gnu-warnings/cxx-error-5 @@ -0,0 +1,11 @@ +# +# In GCC 4.4.7, the compiler gripes about shadowed global +# declarations when a local variable uses the name of a +# function that's in a system header file. For some reason, +# later versions of GCC (e.g., 5.2.0) don't complain about +# the shadowed globals. Maybe later versions are less fussy? +# Anyway, the shadowing seems to be harmless, and GCC 4.4.7 +# is not a supported compiler, so let us promote shadowed globals +# warnings to errors only for GCC 5 and later. +# +-Werror=shadow diff --git a/config/gnu-warnings/cxx-error-general b/config/gnu-warnings/cxx-error-general new file mode 100644 index 0000000..85cd9a3 --- /dev/null +++ b/config/gnu-warnings/cxx-error-general @@ -0,0 +1,32 @@ +# +# HDF5 code should not trigger the following warnings under any +# circumstances, so ask the compiler to treat them as errors: +# +# NOTE: c++/test files are not compatible with these warnings as errors +# c++/test/tcompound.cpp +# -Werror=cast-align +-Wcast-align +# NOTE: c++/src files are not compatible with these warnings as errors +# c++/src/H5Object.cpp +# -Werror=missing-declarations +-Wmissing-declarations +-Werror=packed +-Werror=redundant-decls +-Werror=switch +# NOTE: c++/test files are not compatible with these warnings as errors +# c++/test/tattr.cpp +# -Werror=unused-but-set-variable +-Wunused-but-set-variable +-Werror=unused-function +-Werror=unused-variable +# NOTE: c++/src files are not compatible with these warnings as errors +# c++/src/H5Object.cpp,c++/src/H5StrType.cpp,c++/src/H5PredType.cpp +# -Werror=unused-parameter +-Wunused-parameter +# +# Other files not compatible +# NOTE: c++/test files are not compatible with these warnings as errors +# c++/test/titerate.cpp,c++/test/tarray.cpp +# -Werror=missing-declarations +# c++/test/titerate.cpp,c++/test/tarray.cpp,c++/test/tlinks.cpp,c++/test/ttypes.cpp,c++/test/dsets.cpp +# -Werror=unused-parameter diff --git a/config/gnu-warnings/cxx-general b/config/gnu-warnings/cxx-general index ee7ee22..9548cc0 100644 --- a/config/gnu-warnings/cxx-general +++ b/config/gnu-warnings/cxx-general @@ -6,14 +6,26 @@ # NOTE: Don't add -Wpadded here since we can't/won't fix the (many) # warnings that are emitted. If you need it, add it from the # environment variable at configure time. --Wabi +-Wall +-Wcast-qual +-Wconversion -Wctor-dtor-privacy -Weffc++ -##-Wendif-labels +-Wextra +-Wfloat-equal +-Wformat=2 +-Winit-self +-Winvalid-pch +-Wmissing-include-dirs +-Wno-format-nonliteral -Wnon-virtual-dtor -Wold-style-cast -Woverloaded-virtual -Wreorder +-Wshadow -Wsign-promo ##-Wunreachable-code +-Wundef ##-Wvariadic-macros +-Wwrite-strings +-pedantic diff --git a/config/gnu-warnings/error-8 b/config/gnu-warnings/error-8 index 36c1414..2f54a4d 100644 --- a/config/gnu-warnings/error-8 +++ b/config/gnu-warnings/error-8 @@ -1,4 +1,7 @@ --Werror=cast-function-type +# NOTE: src/ files are not compatible with these warnings as errors +# src/H5Dchunk.c +# -Werror=cast-function-type +-Wcast-function-type # # For GCC 8, promote maybe-initialized warnings to an error. GCC 8 # reports 0 maybe-uninitialized warnings where earlier versions @@ -6,4 +9,17 @@ # in order to detect initializations that occur there. It's possible # that GCC 8 only performs that analysis at -O3, though. # --Werror=maybe-uninitialized +# +# NOTE: File Driver files are not compatible with these warnings as errors +# H5FDlog.c, +# -Werror=maybe-uninitialized +-Wmaybe-uninitialized +# NOTE: src/ files are not compatible with these warnings as errors +# src/H5Shyper.c,src/H5SL.c,src/H5Shyper.c +# -Werror=maybe-uninitialized +# NOTE: Test files are not compatible with these warnings as errors +# test/cache_common.c, +# -Werror=maybe-uninitialized +# NOTE: hl/src/ files are not compatible with these warnings as errors +# hl/src/H5DS.c, +# -Werror=maybe-uninitialized -- cgit v0.12 From 2956151239dba57386b4fc25c659933f42688e4b Mon Sep 17 00:00:00 2001 From: Allen Byrne Date: Fri, 24 Apr 2020 07:49:39 -0500 Subject: Fix NoFilter build --- hl/c++/test/ptableTest.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hl/c++/test/ptableTest.cpp b/hl/c++/test/ptableTest.cpp index fd85828..52f3a6b 100644 --- a/hl/c++/test/ptableTest.cpp +++ b/hl/c++/test/ptableTest.cpp @@ -267,13 +267,13 @@ error: const char* COMPRESS_PT("/compressTest"); int TestCompress() { +#ifdef H5_HAVE_FILTER_DEFLATE unsigned int flags = 0; unsigned int config = 0; size_t cd_nelemts = 0; printf("Testing %-62s", "compression"); HDfflush(stdout); -#ifdef H5_HAVE_FILTER_DEFLATE try { /* Prepare property list to set compression, randomly use deflate */ DSetCreatPropList dscreatplist; -- cgit v0.12 From 7491ba03f9a6bc4d45bd50b2de9806d853da81eb Mon Sep 17 00:00:00 2001 From: Allen Byrne Date: Fri, 24 Apr 2020 16:25:51 -0500 Subject: Restrict errors to gcc 4.8 and above. --- config/cmake/HDFCompilerFlags.cmake | 13 +++++++++++++ config/gnu-flags | 2 ++ 2 files changed, 15 insertions(+) diff --git a/config/cmake/HDFCompilerFlags.cmake b/config/cmake/HDFCompilerFlags.cmake index a40b525..b8eef97 100644 --- a/config/cmake/HDFCompilerFlags.cmake +++ b/config/cmake/HDFCompilerFlags.cmake @@ -114,6 +114,8 @@ if (NOT MSVC) # Add general CFlags except for older versions that are no longer supported if (NOT CMAKE_C_COMPILER_VERSION VERSION_LESS 4.2) ADD_H5_FLAGS (HDF5_CMAKE_C_FLAGS "${HDF5_SOURCE_DIR}/config/gnu-warnings/general") + endif () + if (CMAKE_C_COMPILER_VERSION VERSION_GREATER_EQUAL 4.8) ADD_H5_FLAGS (H5_CFLAGS0 "${HDF5_SOURCE_DIR}/config/gnu-warnings/error-general") endif () # gcc automatically inlines based on the optimization level @@ -157,6 +159,17 @@ if (NOT MSVC) if (CMAKE_C_COMPILER_VERSION VERSION_LESS 5.0 AND NOT CMAKE_C_COMPILER_VERSION VERSION_LESS 4.2) ADD_H5_FLAGS (H5_CFLAGS1 "${HDF5_SOURCE_DIR}/config/gnu-warnings/4.2-4.last") endif () + + # Append warning flags for gcc 4.2-4.3 + if (CMAKE_C_COMPILER_VERSION VERSION_LESS_EQUAL 4.3 AND CMAKE_C_COMPILER_VERSION VERSION_GREATER_EQUAL 4.2) + ADD_H5_FLAGS (H5_CFLAGS1 "${HDF5_SOURCE_DIR}/config/gnu-warnings/4.2-4.3") + endif () + + # Append warning flags for gcc 4.2-4.4 + if (CMAKE_C_COMPILER_VERSION VERSION_LESS_EQUAL 4.4 AND CMAKE_C_COMPILER_VERSION VERSION_GREATER_EQUAL 4.2) + ADD_H5_FLAGS (H5_CFLAGS1 "${HDF5_SOURCE_DIR}/config/gnu-warnings/4.2-4.4") + endif () + # Append warning flags that only gcc 4.3+ knows about if (CMAKE_C_COMPILER_VERSION VERSION_LESS 4.3 AND NOT CMAKE_C_COMPILER_VERSION VERSION_LESS 4.2) ADD_H5_FLAGS (H5_CFLAGS1 "${HDF5_SOURCE_DIR}/config/gnu-warnings/4.3") diff --git a/config/gnu-flags b/config/gnu-flags index f391d7b..7e69ede 100644 --- a/config/gnu-flags +++ b/config/gnu-flags @@ -190,6 +190,8 @@ if test "X-gcc" = "X-$cc_vendor"; then if test $cc_vers_major -eq 4 -a $cc_vers_minor -ge 2 -o $cc_vers_major -gt 4; then H5_CFLAGS="$H5_CFLAGS $(load_gnu_arguments general)" + fi + if test $cc_vers_major -eq 4 -a $cc_vers_minor -ge 8 -o $cc_vers_major -gt 4; then H5_ECFLAGS="$H5_ECFLAGS $(load_gnu_arguments error-general)" fi -- cgit v0.12 From 295d7ec69bdd1bb6f662cee1fe8ff70fe50f55c5 Mon Sep 17 00:00:00 2001 From: Larry Knox Date: Mon, 27 Apr 2020 11:14:31 -0500 Subject: Move ADD_H5_FLAGS macro from *CompilerFlags.cmake files to config/cmake_ext_mod/HDFMacros.cmake for common use. --- config/cmake/HDFCXXCompilerFlags.cmake | 18 ------------------ config/cmake/HDFCompilerFlags.cmake | 18 ------------------ config/cmake/HDFFortranCompilerFlags.cmake | 18 ------------------ config/cmake_ext_mod/HDFMacros.cmake | 18 ++++++++++++++++++ 4 files changed, 18 insertions(+), 54 deletions(-) diff --git a/config/cmake/HDFCXXCompilerFlags.cmake b/config/cmake/HDFCXXCompilerFlags.cmake index 400ba8c..1c95266 100644 --- a/config/cmake/HDFCXXCompilerFlags.cmake +++ b/config/cmake/HDFCXXCompilerFlags.cmake @@ -13,24 +13,6 @@ set(CMAKE_CXX_STANDARD 98) set(CMAKE_CXX_STANDARD_REQUIRED TRUE) set(CMAKE_CXX_EXTENSIONS OFF) -macro (ADD_H5_FLAGS h5_flag_var infile) - file (STRINGS ${infile} TEST_FLAG_STREAM) - #message (STATUS "TEST_FLAG_STREAM=${TEST_FLAG_STREAM}") - list (LENGTH TEST_FLAG_STREAM len_flag) - if (len_flag GREATER 0) - math (EXPR _FP_LEN "${len_flag} - 1") - foreach (line RANGE 0 ${_FP_LEN}) - list (GET TEST_FLAG_STREAM ${line} str_flag) - string (REGEX REPLACE "^#.*" "" str_flag "${str_flag}") - #message (STATUS "str_flag=${str_flag}") - if (str_flag) - list (APPEND ${h5_flag_var} "${str_flag}") - endif () - endforeach () - endif () - #message (STATUS "h5_flag_var=${${h5_flag_var}}") -endmacro () - set (CMAKE_CXX_FLAGS "${CMAKE_CXX_SANITIZER_FLAGS} ${CMAKE_CXX_FLAGS}") message (STATUS "Warnings Configuration: CXX default: ${CMAKE_CXX_FLAGS}") #----------------------------------------------------------------------------- diff --git a/config/cmake/HDFCompilerFlags.cmake b/config/cmake/HDFCompilerFlags.cmake index b8eef97..ddd3703 100644 --- a/config/cmake/HDFCompilerFlags.cmake +++ b/config/cmake/HDFCompilerFlags.cmake @@ -12,24 +12,6 @@ set(CMAKE_C_STANDARD 99) set(CMAKE_C_STANDARD_REQUIRED TRUE) -macro (ADD_H5_FLAGS h5_flag_var infile) - file (STRINGS ${infile} TEST_FLAG_STREAM) - #message (STATUS "TEST_FLAG_STREAM=${TEST_FLAG_STREAM}") - list (LENGTH TEST_FLAG_STREAM len_flag) - if (len_flag GREATER 0) - math (EXPR _FP_LEN "${len_flag} - 1") - foreach (line RANGE 0 ${_FP_LEN}) - list (GET TEST_FLAG_STREAM ${line} str_flag) - string (REGEX REPLACE "^#.*" "" str_flag "${str_flag}") - #message (STATUS "str_flag=${str_flag}") - if (str_flag) - list (APPEND ${h5_flag_var} "${str_flag}") - endif () - endforeach () - endif () - #message (STATUS "h5_flag_var=${${h5_flag_var}}") -endmacro () - set (CMAKE_C_FLAGS "${CMAKE_C99_STANDARD_COMPILE_OPTION} ${CMAKE_C_FLAGS}") set (CMAKE_C_FLAGS "${CMAKE_C_SANITIZER_FLAGS} ${CMAKE_C_FLAGS}") set (CMAKE_CXX_FLAGS "${CMAKE_CXX_SANITIZER_FLAGS} ${CMAKE_CXX_FLAGS}") diff --git a/config/cmake/HDFFortranCompilerFlags.cmake b/config/cmake/HDFFortranCompilerFlags.cmake index a56ef28..495a0ca 100644 --- a/config/cmake/HDFFortranCompilerFlags.cmake +++ b/config/cmake/HDFFortranCompilerFlags.cmake @@ -10,24 +10,6 @@ # help@hdfgroup.org. # -macro (ADD_H5_FFLAGS h5_fflag_var infile) - file (STRINGS ${infile} TEST_FLAG_STREAM) - #message (STATUS "TEST_FLAG_STREAM=${TEST_FLAG_STREAM}") - list (LENGTH TEST_FLAG_STREAM len_flag) - if (len_flag GREATER 0) - math (EXPR _FP_LEN "${len_flag} - 1") - foreach (line RANGE 0 ${_FP_LEN}) - list (GET TEST_FLAG_STREAM ${line} str_flag) - string (REGEX REPLACE "^#.*" "" str_flag "${str_flag}") - #message (STATUS "str_flag=${str_flag}") - if (str_flag) - list (APPEND ${h5_fflag_var} "${str_flag}") - endif () - endforeach () - endif () - #message (STATUS "h5_fflag_var=${${h5_fflag_var}}") -endmacro () - message (STATUS "Warnings Configuration: default Fortran: ${CMAKE_Fortran_FLAGS}") #----------------------------------------------------------------------------- diff --git a/config/cmake_ext_mod/HDFMacros.cmake b/config/cmake_ext_mod/HDFMacros.cmake index fee6def..5740740 100644 --- a/config/cmake_ext_mod/HDFMacros.cmake +++ b/config/cmake_ext_mod/HDFMacros.cmake @@ -429,3 +429,21 @@ macro (HDF_DIR_PATHS package_prefix) endif () endmacro () +macro (ADD_H5_FLAGS h5_flag_var infile) + file (STRINGS ${infile} TEST_FLAG_STREAM) + #message (STATUS "TEST_FLAG_STREAM=${TEST_FLAG_STREAM}") + list (LENGTH TEST_FLAG_STREAM len_flag) + if (len_flag GREATER 0) + math (EXPR _FP_LEN "${len_flag} - 1") + foreach (line RANGE 0 ${_FP_LEN}) + list (GET TEST_FLAG_STREAM ${line} str_flag) + string (REGEX REPLACE "^#.*" "" str_flag "${str_flag}") + #message (STATUS "str_flag=${str_flag}") + if (str_flag) + list (APPEND ${h5_flag_var} "${str_flag}") + endif () + endforeach () + endif () + #message (STATUS "h5_flag_var=${${h5_flag_var}}") +endmacro () + -- cgit v0.12 From 68adfb86d056af222ab80c349c56e0bd1d183f09 Mon Sep 17 00:00:00 2001 From: David Young Date: Fri, 24 Apr 2020 21:09:14 -0500 Subject: Merge pull request #2537 in HDFFV/hdf5 from ~DYOUNG/werror:fix-werrors to develop * commit 'd16eb45d536bd13ca3cf1b0bdc76c58d95d13f17': For compatibility with non-C99 Visual Studio versions, use "%" PRIuMAX instead of "%ju". Fix `test/swmr_sparse_reader.c:118:77: error: cast from pointer to integer of different size [-Werror=pointer-to-int-cast]` and `test/snapshots-hdf5/current/test/swmr_sparse_reader.c:129:100: error: cast from pointer to integer of different size [-Werror=pointer-to-int-cast]`. Fix `src/H5FDdirect.c:1346:5: error: ISO C90 forbids mixed declarations and code [-Werror=declaration-after-statement]`. --- src/H5FDdirect.c | 5 +---- test/swmr_sparse_reader.c | 4 ++-- 2 files changed, 3 insertions(+), 6 deletions(-) diff --git a/src/H5FDdirect.c b/src/H5FDdirect.c index 906ec28..4a41403 100644 --- a/src/H5FDdirect.c +++ b/src/H5FDdirect.c @@ -1337,16 +1337,13 @@ static herr_t H5FD_direct_lock(H5FD_t *_file, hbool_t rw) { H5FD_direct_t *file = (H5FD_direct_t*)_file; /* VFD file struct */ - int lock; /* The type of lock */ + const int lock = rw ? LOCK_EX : LOCK_SH; herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI_NOINIT HDassert(file); - /* Determine the type of lock */ - int lock = rw ? LOCK_EX : LOCK_SH; - /* Place the lock with non-blocking */ if(HDflock(file->fd, lock | LOCK_NB) < 0) HSYS_GOTO_ERROR(H5E_FILE, H5E_BADFILE, FAIL, "unable to flock file") diff --git a/test/swmr_sparse_reader.c b/test/swmr_sparse_reader.c index 6adc6c5..f190777 100644 --- a/test/swmr_sparse_reader.c +++ b/test/swmr_sparse_reader.c @@ -115,7 +115,7 @@ check_dataset(hid_t fid, unsigned verbose, const symbol_info_t *symbol, symbol_t /* Emit informational message */ if(verbose) - HDfprintf(stderr, "Symbol = '%s', location = %lld\n", symbol->name, (long long)start); + HDfprintf(stderr, "Symbol = '%s', location = %" PRIuMAX ",%" PRIuMAX "\n", symbol->name, (uintmax_t)start[0], (uintmax_t)start[1]); /* Read record from dataset */ record->rec_id = (uint64_t)ULLONG_MAX; @@ -126,7 +126,7 @@ check_dataset(hid_t fid, unsigned verbose, const symbol_info_t *symbol, symbol_t if(record->rec_id != start[1]) { HDfprintf(stderr, "*** ERROR ***\n"); HDfprintf(stderr, "Incorrect record value!\n"); - HDfprintf(stderr, "Symbol = '%s', location = %lld, record->rec_id = %llu\n", symbol->name, (long long)start, (unsigned long long)record->rec_id); + HDfprintf(stderr, "Symbol = '%s', location = %" PRIuMAX ",%" PRIuMAX ", record->rec_id = %" PRIu64 "\n", symbol->name, (uintmax_t)start[0], (uintmax_t)start[1], record->rec_id); return -1; } /* end if */ -- cgit v0.12