From f020d129b2ed173c8d0075d670214440013d7daf Mon Sep 17 00:00:00 2001 From: Dana Robinson <43805+derobins@users.noreply.github.com> Date: Tue, 23 Aug 2022 08:48:14 -0700 Subject: Corrects more Fortran warnings (#2059) * Moves -Wunused-dummy-arguments to the developer warnings since this generates a lot of spurious, unfixable noise due to things like callback wrappers * Changes the return cast in h5fget_fileno_c, fixes a comment, and comment on potential badness * Initializes a variable in tH5L_F03.F90 to quiet a 'maybe uninitialized' warning --- config/cmake/HDFFortranCompilerFlags.cmake | 11 ++++++----- config/gnu-fflags | 5 ++++- config/gnu-warnings/developer-gfort-5 | 1 - config/gnu-warnings/gfort-developer-5 | 1 + config/gnu-warnings/gfort-developer-general | 3 +++ config/gnu-warnings/gfort-no-developer-general | 3 +++ configure.ac | 1 + fortran/src/H5Ff.c | 8 ++++++-- fortran/test/tH5L_F03.F90 | 3 ++- 9 files changed, 26 insertions(+), 10 deletions(-) delete mode 100644 config/gnu-warnings/developer-gfort-5 create mode 100644 config/gnu-warnings/gfort-developer-5 create mode 100644 config/gnu-warnings/gfort-developer-general create mode 100644 config/gnu-warnings/gfort-no-developer-general diff --git a/config/cmake/HDFFortranCompilerFlags.cmake b/config/cmake/HDFFortranCompilerFlags.cmake index 13e9902..7fdc3f8 100644 --- a/config/cmake/HDFFortranCompilerFlags.cmake +++ b/config/cmake/HDFFortranCompilerFlags.cmake @@ -54,10 +54,6 @@ if (CMAKE_Fortran_COMPILER_ID STREQUAL "GNU" AND NOT CMAKE_Fortran_COMPILER_VERS endif () endif () -#----------------------------------------------------------------------------- -# CDash is configured to only allow 3000 warnings, so -# break into groups (from the config/gnu-flags file) -#----------------------------------------------------------------------------- if (NOT MSVC AND NOT MINGW) # General flags if (CMAKE_Fortran_COMPILER_ID STREQUAL "Intel") @@ -65,6 +61,11 @@ if (NOT MSVC AND NOT MINGW) list (APPEND HDF5_CMAKE_Fortran_FLAGS "-free") elseif (CMAKE_Fortran_COMPILER_ID STREQUAL "GNU") ADD_H5_FLAGS (HDF5_CMAKE_Fortran_FLAGS "${HDF5_SOURCE_DIR}/config/gnu-warnings/gfort-general") + if (HDF5_ENABLE_DEV_WARNINGS) + ADD_H5_FLAGS (HDF5_CMAKE_Fortran_FLAGS "${HDF5_SOURCE_DIR}/config/gnu-warnings/gfort-developer-general") + else () + ADD_H5_FLAGS (HDF5_CMAKE_Fortran_FLAGS "${HDF5_SOURCE_DIR}/config/gnu-warnings/gfort-no-developer-general") + endif () list (APPEND HDF5_CMAKE_Fortran_FLAGS "-ffree-form" "-fimplicit-none") if (CMAKE_Fortran_COMPILER_VERSION VERSION_LESS 8.0 AND NOT CMAKE_Fortran_COMPILER_VERSION VERSION_LESS 4.6) list (APPEND HDF5_CMAKE_Fortran_FLAGS "-std=f2008ts") @@ -92,7 +93,7 @@ if (NOT MSVC AND NOT MINGW) # Append more extra warning flags that only gcc 5.x+ knows about if (NOT CMAKE_Fortran_COMPILER_VERSION VERSION_LESS 5.0) if (HDF5_ENABLE_DEV_WARNINGS) - ADD_H5_FLAGS (HDF5_CMAKE_Fortran_FLAGS "${HDF5_SOURCE_DIR}/config/gnu-warnings/developer-gfort-5") + ADD_H5_FLAGS (HDF5_CMAKE_Fortran_FLAGS "${HDF5_SOURCE_DIR}/config/gnu-warnings/gfort-developer-5") endif () endif () diff --git a/config/gnu-fflags b/config/gnu-fflags index 1333ce5..0230e5c 100644 --- a/config/gnu-fflags +++ b/config/gnu-fflags @@ -150,6 +150,9 @@ if test "X-gfortran" = "X-$f9x_vendor"; then H5_FCFLAGS="$H5_FCFLAGS $(load_gnu_arguments gfort-general)" + NO_DEVELOPER_WARNING_FCFLAGS="$NO_DEVELOPER_WARNING_FCFLAGS $(load_gnu_arguments gfort-no-developer-general)" + DEVELOPER_WARNING_FCFLAGS="$DEVELOPER_WARNING_FCFLAGS $(load_gnu_arguments gfort-developer-general)" + ############################# # Version-specific warnings # ############################# @@ -163,7 +166,7 @@ if test "X-gfortran" = "X-$f9x_vendor"; then # gfortran >= 5 if test $f9x_vers_major -ge 5; then - DEVELOPER_WARNING_FCFLAGS="$DEVELOPER_WARNING_FCFLAGS $(load_gnu_arguments developer-gfort-5)" + DEVELOPER_WARNING_FCFLAGS="$DEVELOPER_WARNING_FCFLAGS $(load_gnu_arguments gfort-developer-5)" fi # gfortran >= 6 diff --git a/config/gnu-warnings/developer-gfort-5 b/config/gnu-warnings/developer-gfort-5 deleted file mode 100644 index c5d3850..0000000 --- a/config/gnu-warnings/developer-gfort-5 +++ /dev/null @@ -1 +0,0 @@ --Wuse-without-only diff --git a/config/gnu-warnings/gfort-developer-5 b/config/gnu-warnings/gfort-developer-5 new file mode 100644 index 0000000..c5d3850 --- /dev/null +++ b/config/gnu-warnings/gfort-developer-5 @@ -0,0 +1 @@ +-Wuse-without-only diff --git a/config/gnu-warnings/gfort-developer-general b/config/gnu-warnings/gfort-developer-general new file mode 100644 index 0000000..dde15fe --- /dev/null +++ b/config/gnu-warnings/gfort-developer-general @@ -0,0 +1,3 @@ +# There is no easy way in Fortran to indicate parameters are intentionally +# unused and many callbacks will have these, generating a lot of noise. +-Wunused-dummy-argument diff --git a/config/gnu-warnings/gfort-no-developer-general b/config/gnu-warnings/gfort-no-developer-general new file mode 100644 index 0000000..bfcba22 --- /dev/null +++ b/config/gnu-warnings/gfort-no-developer-general @@ -0,0 +1,3 @@ +# There is no easy way in Fortran to indicate parameters are intentionally +# unused and many callbacks will have these, generating a lot of noise. +-Wno-unused-dummy-argument diff --git a/configure.ac b/configure.ac index 340decb..e2fbf04 100644 --- a/configure.ac +++ b/configure.ac @@ -2336,6 +2336,7 @@ case "X-$DEV_WARNINGS" in ;; X-no) H5_CFLAGS="$H5_CFLAGS $NO_DEVELOPER_WARNING_CFLAGS" + H5_FCFLAGS="$H5_FCFLAGS $NO_DEVELOPER_WARNING_FCFLAGS" AC_MSG_RESULT([no]) ;; *) diff --git a/fortran/src/H5Ff.c b/fortran/src/H5Ff.c index 2cb8654..189d2da 100644 --- a/fortran/src/H5Ff.c +++ b/fortran/src/H5Ff.c @@ -664,11 +664,15 @@ h5fget_fileno_c(hid_t_f *file_id, int_f *fileno) herr_t ret_value = 0; /* Return value */ /* - * Call H5Fget_filesize function + * Call H5Fget_fileno function */ if ((ret_value = H5Fget_fileno((hid_t)*file_id, &fileno_c)) < 0) HGOTO_DONE(FAIL); - *fileno = (hsize_t_f)fileno_c; + + /* XXX: This will have problems if the library fileno value doesn't fit + * into an int_f. + */ + *fileno = (int_f)fileno_c; done: return ret_value; diff --git a/fortran/test/tH5L_F03.F90 b/fortran/test/tH5L_F03.F90 index a4e960b..a02a540 100644 --- a/fortran/test/tH5L_F03.F90 +++ b/fortran/test/tH5L_F03.F90 @@ -73,7 +73,8 @@ CONTAINS INTEGER, SAVE :: count INTEGER, SAVE :: count2 -!!$ + liter_cb = 0 + !!$ iter_info *info = (iter_info *)op_data; !!$ static int count = 0; !!$ static int count2 = 0; -- cgit v0.12