summaryrefslogtreecommitdiffstats
path: root/config/gnu-flags
diff options
context:
space:
mode:
authorAllen Byrne <byrn@hdfgroup.org>2020-01-20 15:28:50 (GMT)
committerAllen Byrne <byrn@hdfgroup.org>2020-01-20 15:29:01 (GMT)
commit113481a8198e0f863a01e2d2cb3c43d5a5a844cd (patch)
tree24fb27b8f497313c7ef594b96e8a592a4d215fcf /config/gnu-flags
parent8eb45094683843798b86ad8c3da298ebbde02fde (diff)
downloadhdf5-113481a8198e0f863a01e2d2cb3c43d5a5a844cd.zip
hdf5-113481a8198e0f863a01e2d2cb3c43d5a5a844cd.tar.gz
hdf5-113481a8198e0f863a01e2d2cb3c43d5a5a844cd.tar.bz2
Create common warnings for build systems
Diffstat (limited to 'config/gnu-flags')
-rw-r--r--config/gnu-flags48
1 files changed, 32 insertions, 16 deletions
diff --git a/config/gnu-flags b/config/gnu-flags
index 16795d0..f23ad68 100644
--- a/config/gnu-flags
+++ b/config/gnu-flags
@@ -17,6 +17,21 @@
# if the compiler is not GNU; otherwise 'cc_flags_set' is set to 'yes'
#
+#
+# Prepend `$srcdir/config/gnu-` to the filename suffix(es) given as
+# subroutine argument(s), remove comments starting with # and ending
+# at EOL, replace spans of whitespace (including newlines) with spaces,
+# and re-emit the file(s) thus filtered on the standard output stream.
+#
+load_gcc_arguments()
+{
+ set -- $(for arg; do
+ sed 's,#.*$,,' $srcdir/config/gnu-${arg}
+ done)
+ IFS=' ' echo "$*"
+}
+
+
# Get the compiler version in a way that works for gcc
# unless a compiler version is already known
#
@@ -138,7 +153,7 @@ if test "X-gcc" = "X-$cc_vendor"; then
################
# Optimization #
################
-
+
if test $cc_vers_major -le 4; then
HIGH_OPT_CFLAGS="-O3"
DEBUG_OPT_CFLAGS=
@@ -171,12 +186,13 @@ if test "X-gcc" = "X-$cc_vendor"; then
# NOTE: Due to the divergence in the C and C++, we're dropping support for
# compiling the C library with a C++ compiler and dropping the -Wc++-compat
# warning.
- H5_CFLAGS="$H5_CFLAGS -pedantic -Wall -Wextra -Wbad-function-cast -Wno-c++-compat -Wcast-align"
- H5_CFLAGS="$H5_CFLAGS -Wcast-qual -Wconversion -Wdeclaration-after-statement -Wdisabled-optimization -Wfloat-equal"
- H5_CFLAGS="$H5_CFLAGS -Wformat=2 -Wno-format-nonliteral -Winit-self -Winvalid-pch -Wmissing-declarations -Wmissing-include-dirs"
+ H5_CFLAGS="$H5_CFLAGS $(load_gcc_arguments warnings-general)"
+ H5_CFLAGS="$H5_CFLAGS -Wbad-function-cast -Wcast-align"
+ H5_CFLAGS="$H5_CFLAGS -Wdeclaration-after-statement -Wdisabled-optimization"
+ H5_CFLAGS="$H5_CFLAGS -Wmissing-declarations"
H5_CFLAGS="$H5_CFLAGS -Wmissing-prototypes -Wnested-externs -Wold-style-definition -Wpacked"
- H5_CFLAGS="$H5_CFLAGS -Wredundant-decls -Wshadow -Wstrict-prototypes -Wswitch-enum -Wswitch-default"
- H5_CFLAGS="$H5_CFLAGS -Wundef -Wunused-macros -Wunsafe-loop-optimizations -Wwrite-strings"
+ H5_CFLAGS="$H5_CFLAGS -Wredundant-decls -Wstrict-prototypes -Wswitch-enum -Wswitch-default"
+ H5_CFLAGS="$H5_CFLAGS -Wunused-macros -Wunsafe-loop-optimizations"
######################
# Developer warnings #
@@ -184,8 +200,8 @@ if test "X-gcc" = "X-$cc_vendor"; then
# (suggestions from gcc, not code problems)
# NOTE: -Wformat-nonliteral added back in here (from being disabled in H5_CFLAGS)
- DEVELOPER_WARNING_CFLAGS="-Winline -Waggregate-return -Wmissing-format-attribute -Wmissing-noreturn -Wformat-nonliteral"
- NO_DEVELOPER_WARNING_CFLAGS="-Wno-inline -Wno-aggregate-return -Wno-missing-format-attribute -Wno-missing-noreturn"
+ NO_DEVELOPER_WARNING_CFLAGS=$(load_gcc_arguments warnings-no-developer-general)
+ DEVELOPER_WARNING_CFLAGS=$(load_gcc_arguments warnings-developer-general)
#######################
# gcc 4 special cases #
@@ -196,11 +212,11 @@ if test "X-gcc" = "X-$cc_vendor"; then
H5_CFLAGS="$H5_CFLAGS -Wno-long-long"
fi
- # -Wvolatile-register-var was later incorporated into -Wall and
- # only needs to be specified explicitly for gcc 4.2-4.3
+ # -Wvolatile-register-var was later incorporated into -Wall and
+ # only needs to be specified explicitly for gcc 4.2-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 -Wvolatile-register-var"
- fi
+ H5_CFLAGS="$H5_CFLAGS -Wvolatile-register-var"
+ fi
# -Wstrict-aliasing was later incorporated into -Wall and
# only needs to be specified explicitly for gcc 4.5-4.6
@@ -223,10 +239,10 @@ if test "X-gcc" = "X-$cc_vendor"; then
# Version-specific warnings #
#############################
- # gcc 4.3
+ # 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 -Wlogical-op -Wlarger-than=2560"
- fi
+ H5_CFLAGS="$H5_CFLAGS -Wlogical-op -Wlarger-than=2560"
+ fi
# gcc 4.4
if test $cc_vers_major -ge 5 -o $cc_vers_major -eq 4 -a $cc_vers_minor -ge 4; then
@@ -276,7 +292,7 @@ if test "X-gcc" = "X-$cc_vendor"; then
# gcc 7
if test $cc_vers_major -ge 7; then
DEVELOPER_WARNING_CFLAGS="$DEVELOPER_WARNING_CFLAGS -Wstringop-overflow=2"
- H5_CFLAGS="$H5_CFLAGS -Walloc-zero -Walloca -Wduplicated-branches -Wformat-overflow=2 -Wformat-truncation=2 -Wimplicit-fallthrough=5 -Wrestrict"
+ H5_CFLAGS="$H5_CFLAGS -Walloc-zero -Walloca -Wduplicated-branches -Wformat-overflow=2 -Wformat-truncation=1 -Wimplicit-fallthrough=5 -Wrestrict"
fi
# gcc 8