Merge pull request #242 in HDFFV/hdf5 from ~DEROBINS/hdf5_der:dev_warnings01 to develop

* commit 'e6a12a3feaa3a111510d899102af77f61950b8bf':
  Added an --enable-developer-warnings option to configure so users can ignore -Wsuggest-attribute warnings and other noise that doesn't indicate poor code quality.
This commit is contained in:
Dana Robinson 2017-01-11 09:14:52 -06:00
commit 8b4c9f848d
2 changed files with 58 additions and 24 deletions

View File

@ -94,7 +94,7 @@ case "$cc_vendor-$cc_version" in
esac
# General
H5_CFLAGS="$H5_CFLAGS $arch -std=c99 -pedantic -Wall -W -Wundef -Wshadow -Wpointer-arith -Wbad-function-cast -Wcast-qual -Wcast-align -Wwrite-strings -Wconversion -Waggregate-return -Wstrict-prototypes -Wmissing-prototypes -Wmissing-declarations -Wredundant-decls -Wnested-externs -Winline"
H5_CFLAGS="$H5_CFLAGS $arch -std=c99 -pedantic -Wall -W -Wundef -Wshadow -Wpointer-arith -Wbad-function-cast -Wcast-qual -Wcast-align -Wwrite-strings -Wconversion -Waggregate-return -Wstrict-prototypes -Wmissing-prototypes -Wmissing-declarations -Wredundant-decls -Wnested-externs"
# Production
# NDEBUG is handled explicitly by the configure script
@ -125,6 +125,10 @@ case "$cc_vendor-$cc_version" in
esac
#DEBUG_CFLAGS="-fsanitize=undefined"
# Developer warnings (suggestions from gcc, not code problems)
NO_DEVELOPER_WARNING_CFLAGS="-Wno-suggest-attribute=const -Wno-suggest-attribute=pure -Wno-suggest-attribute=noreturn -Wno-suggest-attribute=format -Wno-inline"
DEVELOPER_WARNING_CFLAGS="-Wsuggest-attribute=const -Wsuggest-attribute=pure -Wsuggest-attribute=noreturn -Wsuggest-attribute=format -Winline"
# Symbols
NO_SYMBOLS_CFLAGS="-s"
SYMBOLS_CFLAGS="-g"
@ -223,13 +227,10 @@ case "$cc_vendor-$cc_version" in
H5_CFLAGS="$H5_CFLAGS -Wstrict-overflow=5 -Wjump-misses-init -Wunsuffixed-float-constants"
# Append more extra warning flags that only gcc 4.6+ know about
H5_CFLAGS="$H5_CFLAGS -Wdouble-promotion -Wsuggest-attribute=const -Wtrampolines"
H5_CFLAGS="$H5_CFLAGS -Wdouble-promotion -Wtrampolines"
# Append more extra warning flags that only gcc 4.7+ know about
H5_CFLAGS="$H5_CFLAGS -Wstack-usage=8192 -Wvector-operation-performance -Wsuggest-attribute=pure -Wsuggest-attribute=noreturn"
# Append more extra warning flags that only gcc 4.8+ know about
H5_CFLAGS="$H5_CFLAGS -Wsuggest-attribute=format"
H5_CFLAGS="$H5_CFLAGS -Wstack-usage=8192 -Wvector-operation-performance"
# Append more extra warning flags that only gcc 4.9+ know about
H5_CFLAGS="$H5_CFLAGS -Wdate-time"
@ -297,13 +298,10 @@ case "$cc_vendor-$cc_version" in
H5_CFLAGS="$H5_CFLAGS -Wstrict-overflow=5 -Wjump-misses-init -Wunsuffixed-float-constants"
# Append more extra warning flags that only gcc 4.6+ know about
H5_CFLAGS="$H5_CFLAGS -Wdouble-promotion -Wsuggest-attribute=const -Wtrampolines"
H5_CFLAGS="$H5_CFLAGS -Wdouble-promotion -Wtrampolines"
# Append more extra warning flags that only gcc 4.7+ know about
H5_CFLAGS="$H5_CFLAGS -Wstack-usage=8192 -Wvector-operation-performance -Wsuggest-attribute=pure -Wsuggest-attribute=noreturn"
# Append more extra warning flags that only gcc 4.8+ know about
H5_CFLAGS="$H5_CFLAGS -Wsuggest-attribute=format"
H5_CFLAGS="$H5_CFLAGS -Wstack-usage=8192 -Wvector-operation-performance"
# Append more extra warning flags that only gcc 4.9+ know about
H5_CFLAGS="$H5_CFLAGS -Wdate-time"
@ -368,13 +366,10 @@ case "$cc_vendor-$cc_version" in
H5_CFLAGS="$H5_CFLAGS -Wstrict-overflow=5 -Wjump-misses-init -Wunsuffixed-float-constants"
# Append more extra warning flags that only gcc 4.6+ know about
H5_CFLAGS="$H5_CFLAGS -Wdouble-promotion -Wsuggest-attribute=const -Wtrampolines"
H5_CFLAGS="$H5_CFLAGS -Wdouble-promotion -Wtrampolines"
# Append more extra warning flags that only gcc 4.7+ know about
H5_CFLAGS="$H5_CFLAGS -Wstack-usage=8192 -Wvector-operation-performance -Wsuggest-attribute=pure -Wsuggest-attribute=noreturn"
# Append more extra warning flags that only gcc 4.8+ know about
H5_CFLAGS="$H5_CFLAGS -Wsuggest-attribute=format"
H5_CFLAGS="$H5_CFLAGS -Wstack-usage=8192 -Wvector-operation-performance"
# Append more extra warning flags that only gcc 4.9+ know about
H5_CFLAGS="$H5_CFLAGS -Wdate-time"
@ -436,13 +431,10 @@ case "$cc_vendor-$cc_version" in
H5_CFLAGS="$H5_CFLAGS -Wstrict-overflow=5 -Wjump-misses-init"
# Append more extra warning flags that only gcc 4.6+ know about
H5_CFLAGS="$H5_CFLAGS -Wdouble-promotion -Wsuggest-attribute=const -Wtrampolines"
H5_CFLAGS="$H5_CFLAGS -Wdouble-promotion -Wtrampolines"
# Append more extra warning flags that only gcc 4.7+ know about
H5_CFLAGS="$H5_CFLAGS -Wstack-usage=8192 -Wvector-operation-performance -Wsuggest-attribute=pure -Wsuggest-attribute=noreturn"
# Append more extra warning flags that only gcc 4.8+ know about
H5_CFLAGS="$H5_CFLAGS -Wsuggest-attribute=format"
H5_CFLAGS="$H5_CFLAGS -Wstack-usage=8192 -Wvector-operation-performance"
;;
gcc-4.7*)
@ -502,10 +494,10 @@ case "$cc_vendor-$cc_version" in
H5_CFLAGS="$H5_CFLAGS -Wstrict-overflow=5 -Wjump-misses-init -Wunsuffixed-float-constants"
# Append more extra warning flags that only gcc 4.6+ know about
H5_CFLAGS="$H5_CFLAGS -Wdouble-promotion -Wsuggest-attribute=const -Wtrampolines"
H5_CFLAGS="$H5_CFLAGS -Wdouble-promotion -Wtrampolines"
# Append more extra warning flags that only gcc 4.7+ know about
H5_CFLAGS="$H5_CFLAGS -Wstack-usage=8192 -Wvector-operation-performance -Wsuggest-attribute=pure -Wsuggest-attribute=noreturn"
H5_CFLAGS="$H5_CFLAGS -Wstack-usage=8192 -Wvector-operation-performance"
;;
gcc-4.6*)
@ -561,7 +553,7 @@ case "$cc_vendor-$cc_version" in
H5_CFLAGS="$H5_CFLAGS -Wstrict-aliasing -Wstrict-overflow=5 -Wjump-misses-init -Wunsuffixed-float-constants"
# Append more extra warning flags that only gcc 4.6+ know about
H5_CFLAGS="$H5_CFLAGS -Wdouble-promotion -Wsuggest-attribute=const -Wtrampolines"
H5_CFLAGS="$H5_CFLAGS -Wdouble-promotion -Wtrampolines"
;;
gcc-4.5*)

View File

@ -2054,6 +2054,48 @@ case "X-$ASSERTS" in
;;
esac
## ----------------------------------------------------------------------
## Check if developer warnings should be turned on
## These are warnings that provide suggestions like gcc's -Wsuggest-attribute.
## They do not indicate code problems.
##
## Note that developers don't need to build with these regularly. They
## are just handy to check once in a while (before releases, etc.).
##
AC_MSG_CHECKING([enable developer warnings])
AC_ARG_ENABLE([developer-warnings],
[AS_HELP_STRING([--enable-developer-warnings],
[Determines whether developer warnings will be
emitted. These are usually performance suggestions
(e.g. -Wsuggest-attribute) and do not flag poor code
quality.
[default=no]
])],
[DEV_WARNINGS=$enableval])
## Set default
if test "X-$DEV_WARNINGS" = X- ; then
DEV_WARNINGS=no
fi
## Allow this variable to be substituted in
## other files (src/libhdf5.settings.in, etc.)
AC_SUBST([DEV_WARNINGS])
case "X-$DEV_WARNINGS" in
X-yes)
H5_CFLAGS="$H5_CFLAGS $DEVELOPER_WARNING_CFLAGS"
AC_MSG_RESULT([yes])
;;
X-no)
H5_CFLAGS="$H5_CFLAGS $NO_DEVELOPER_WARNING_CFLAGS"
AC_MSG_RESULT([no])
;;
*)
AC_MSG_ERROR([Unrecognized value: $DEV_WARNINGS])
;;
esac
## ----------------------------------------------------------------------
## Check if the compiler should use profiling flags/settings
##