[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[lmi-commits] [lmi] master 01aa1fd4 9/9: Factor out gcc warnings
From: |
Greg Chicares |
Subject: |
[lmi-commits] [lmi] master 01aa1fd4 9/9: Factor out gcc warnings |
Date: |
Tue, 28 Jun 2022 22:26:46 -0400 (EDT) |
branch: master
commit 01aa1fd4b1420162cffe606204aba9d24021cc97
Author: Gregory W. Chicares <gchicares@sbcglobal.net>
Commit: Gregory W. Chicares <gchicares@sbcglobal.net>
Factor out gcc warnings
$(tutelary_flag) is used for '-f' and occasionally '-O' flags, but not
for '-W' flags, so it remains in the principal gcc makefile. Thus, this
commit does not purpose to move all gcc-version-dependent options into
a submakefile.
---
compiler_gcc.make | 280 +++------------------------------------------
compiler_gcc_warnings.make | 249 ++++++++++++++++++++++++++++++++++++++++
2 files changed, 266 insertions(+), 263 deletions(-)
diff --git a/compiler_gcc.make b/compiler_gcc.make
index 0951ad4a..229ff196 100644
--- a/compiler_gcc.make
+++ b/compiler_gcc.make
@@ -85,269 +85,6 @@ tutelary_flag :=
c_standard := -fno-ms-extensions -frounding-math -fsignaling-nans -std=c99
cxx_standard := -fno-ms-extensions -frounding-math -fsignaling-nans -std=c++20
-# Warnings for gcc.
-
-gcc_version_specific_c_warnings :=
-gcc_version_specific_cxx_warnings :=
-
-ifneq (,$(filter $(gcc_version), 10 10.0))
-
- ifeq (x86_64-w64-mingw32,$(findstring x86_64-w64-mingw32,$(LMI_TRIPLET)))
-# See:
-# https://lists.nongnu.org/archive/html/lmi/2019-03/msg00026.html
-# https://lists.nongnu.org/archive/html/lmi/2020-12/msg00000.html
-# https://lists.nongnu.org/archive/html/lmi/2020-12/msg00002.html
-# https://lists.nongnu.org/archive/html/lmi/2021-03/msg00000.html
-# https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99234
-# Fixed in gcc-10.2.1, but this makefile doesn't detect the last
-# component of major.minor.patchlevel reliably.
- tutelary_flag := -fomit-frame-pointer
- ifneq (,$(filter $(gcc_version), 10 10.2.1))
- tutelary_flag := -fno-omit-frame-pointer
- endif
- endif
-
-else ifneq (,$(filter $(gcc_version), 11 11.0))
-
-# g++-11 warnings not recognized by g++-10
-#
-# The gcc manual says that '-Wenum-conversion' is for C only,
-# but `make show_overlooked_cxx_warnings` disagreed.
-
- gcc_version_specific_cxx_warnings := \
- -Wctad-maybe-unsupported \
- -Wdeprecated-enum-enum-conversion \
- -Wdeprecated-enum-float-conversion \
- -Wenum-conversion \
- -Winvalid-imported-macros \
-
-endif
-
-# Write '-Wno' options at the end, with a rationale here.
-#
-# -Wabi: useful only for a special purpose
-# -Wanalyzer-too-complex: not actually helpful
-# -Wdate-time: only for "bit-wise-identical reproducible compilations"
-# -Wfloat-equal: too many warnings on correct code, e.g.,
-# exact comparison to zero
-# -Winline: 'inline' now refers to linkage, not inlining
-# -Wmissing-declarations: for C++, this flags valid functions that
-# arguably belong in an unnamed namespace
-# -Wpadded: useful only for low-level work
-# -Wparentheses: its diagnostics are beyond pedantic
-# -Wpsabi: undocumented--ARM only?
-# -Wsign-conversion: [see note elsewhere in this file]
-# -Wsuggest-attribute: too gcc-specific
-# -Wsystem-headers: not generally useful
-# -Wswitch-default: false positives for switches on enums that
-# include all cases (verified by -Wswitch-enum)
-
-treat_warnings_as_errors := -pedantic-errors -Werror
-
-gcc_common_warnings := \
- $(treat_warnings_as_errors) \
- -Waggregate-return \
- -Wall \
- -Walloc-zero \
- -Walloca \
- -Warith-conversion \
- -Wcast-align=strict \
- -Wcast-function-type \
- -Wconversion \
- -Wdangling-else \
- -Wdeprecated-declarations \
- -Wdisabled-optimization \
- -Wdouble-promotion \
- -Wduplicated-branches \
- -Wduplicated-cond \
- -Wextra \
- -Wformat=2 \
- -Wformat-nonliteral \
- -Wformat-overflow=2 \
- -Wformat-security \
- -Wformat-signedness \
- -Wformat-truncation \
- -Wformat-y2k \
- -Wimport \
- -Winit-self \
- -Winvalid-pch \
- -Wlogical-op \
- -Wmissing-include-dirs \
- -Wmultichar \
- -Wnull-dereference \
- -Wpacked \
- -Wpointer-arith \
- -Wredundant-decls \
- -Wrestrict \
- -Wshadow \
- -Wshift-overflow=2 \
- -Wsign-compare \
- -Wstack-protector \
- -Wstrict-overflow \
- -Wstringop-overflow=4 \
- -Wswitch-enum \
- -Wtrampolines \
- -Wundef \
- -Wunreachable-code \
- -Wunsafe-loop-optimizations \
- -Wunused-macros \
- -Wvector-operation-performance \
- -Wvla \
- -Wno-abi \
- -Wno-analyzer-too-complex \
- -Wno-date-time \
- -Wno-float-equal \
- -Wno-inline \
- -Wno-missing-declarations \
- -Wno-padded \
- -Wno-parentheses \
- -Wno-psabi \
- -Wno-sign-conversion \
- -Wno-suggest-attribute=pure \
- -Wno-suggest-attribute=const \
- -Wno-suggest-attribute=noreturn \
- -Wno-suggest-attribute=malloc \
- -Wno-suggest-attribute=format \
- -Wno-suggest-attribute=cold \
- -Wno-system-headers \
- -Wno-switch-default \
-
-# Consider these later:
-postponed_gcc_common_warnings := \
-
-# Write '-Wno' options at the end, with a rationale here.
-#
-# -Wunsuffixed-float-constants: a migration aid to support an eventual
-# FLOAT_CONST_DECIMAL64 pragma, but only a nuisance for now
-
-gcc_c_warnings := \
- $(gcc_common_warnings) \
- -Wbad-function-cast \
- -Wc++-compat \
- -Wjump-misses-init \
- -Wmissing-braces \
- -Wmissing-prototypes \
- -Wnested-externs \
- -Wold-style-definition \
- -Wstrict-prototypes \
- -Wtraditional-conversion \
- -Wwrite-strings \
- -Wno-unsuffixed-float-constants \
-
-# Write '-Wno' options at the end, with a rationale here.
-#
-# -Wabi-tag: useful only for a special purpose
-# -Waggregate-return: generally incompatible with C++
-# -Weffc++: obsolescent
-# -Wmismatched-tags: not helpful--see:
-# https://lists.nongnu.org/archive/html/lmi/2016-05/msg00075.html
-# -Wmultiple-inheritance: forbids a useful feature
-# -Wnamespaces: forbids a useful feature
-# -Wsign-promo: too many false positives--see:
-# https://lists.nongnu.org/archive/html/lmi/2019-03/msg00016.html
-# -Wsuggest-final-methods, and
-# -Wsuggest-final-types: use these only occasionally, like -Weffc++;
-# work with '-Wsuggest-final-types' first, because making a class
-# final may resolve '-Wsuggest-final-methods' suggestions for its
-# members; but expect many false positives
-# -Wtemplates: forbids a useful feature
-# -Wvirtual-inheritance: forbids a useful feature
-
-gcc_cxx_warnings := \
- $(gcc_common_warnings) \
- -Wc++11-compat \
- -Wc++14-compat \
- -Wc++1z-compat \
- -Wcatch-value=3 \
- -Wcomma-subscript \
- -Wconditionally-supported \
- -Wctor-dtor-privacy \
- -Wdelete-non-virtual-dtor \
- -Wdeprecated \
- -Wdeprecated-copy-dtor \
- -Wextra-semi \
- -Wnoexcept \
- -Wnoexcept-type \
- -Wnon-template-friend \
- -Wnon-virtual-dtor \
- -Wold-style-cast \
- -Woverloaded-virtual \
- -Wplacement-new=2 \
- -Wpmf-conversions \
- -Wredundant-tags \
- -Wregister \
- -Wreorder \
- -Wstrict-null-sentinel \
- -Wsuggest-override \
- -Wsynth \
- -Wuseless-cast \
- -Wvolatile \
- -Wzero-as-null-pointer-constant \
- -Wno-abi-tag \
- -Wno-aggregate-return \
- -Wno-effc++ \
- -Wno-mismatched-tags \
- -Wno-multiple-inheritance \
- -Wno-namespaces \
- -Wno-sign-promo \
- -Wno-suggest-final-methods \
- -Wno-suggest-final-types \
- -Wno-templates \
- -Wno-virtual-inheritance \
-
-# Consider these later:
-postponed_gcc_cxx_warnings := \
-
-gcc_common_extra_warnings := \
- -Wcast-qual \
-
-bourn_cast_test.o: gcc_common_extra_warnings += \
- -Wno-double-promotion \
-
-$(cgicc_objects): gcc_common_extra_warnings += \
- -Wno-conversion \
- -Wno-zero-as-null-pointer-constant \
-
-# XMLWRAPP !! Remove these workarounds after updating xmlwrapp. See:
-# https://lists.nongnu.org/archive/html/lmi/2019-03/msg00018.html
-# et seqq.:
-$(xmlwrapp_objects): gcc_common_extra_warnings += \
- -Wno-conversion \
-
-# SOMEDAY !! Address some of these '-Wconversion' issues.
-
-wno_conv_objects := \
- rate_table.o \
- round_glibc.o \
-
-$(wno_conv_objects): gcc_common_extra_warnings += -Wno-conversion
-Wfloat-conversion
-
-wno_sign_conv_objects := \
- $(wx_dependent_objects) \
- crc32.o \
- getopt.o \
- md5.o \
- round_glibc.o \
-
-# '-Wsign-conversion' is generally unusable with C++ because the STL
-# defectively uses unsigned types. It is useful to enable it from
-# time to time and filter the output thus:
-# grep 'error:' | sed -e '/size_type/d'
-
-$(wno_sign_conv_objects): gcc_common_extra_warnings += -Wno-sign-conversion
-
-# Keep version-specific warnings last, so that they override others.
-
-C_WARNINGS = \
- $(gcc_c_warnings) \
- $(gcc_common_extra_warnings) \
- $(gcc_version_specific_c_warnings) \
-
-CXX_WARNINGS = \
- $(gcc_cxx_warnings) \
- $(gcc_common_extra_warnings) \
- $(gcc_version_specific_cxx_warnings) \
-
################################################################################
# Build type governs
@@ -387,6 +124,23 @@ else
optimization_flag := -O2 -fno-omit-frame-pointer
endif
+ifneq (,$(filter $(gcc_version), 10 10.0))
+ ifeq (x86_64-w64-mingw32,$(findstring x86_64-w64-mingw32,$(LMI_TRIPLET)))
+# See:
+# https://lists.nongnu.org/archive/html/lmi/2019-03/msg00026.html
+# https://lists.nongnu.org/archive/html/lmi/2020-12/msg00000.html
+# https://lists.nongnu.org/archive/html/lmi/2020-12/msg00002.html
+# https://lists.nongnu.org/archive/html/lmi/2021-03/msg00000.html
+# https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99234
+# Fixed in gcc-10.2.1, but this makefile doesn't detect the last
+# component of major.minor.patchlevel reliably.
+ tutelary_flag := -fomit-frame-pointer
+ ifneq (,$(filter $(gcc_version), 10 10.2.1))
+ tutelary_flag := -fno-omit-frame-pointer
+ endif
+ endif
+endif
+
# An overriding version of 'my_prod.cpp', which is used to create a
# nondistributable binary, contains so many large strings that, after
# consuming more than one CPU minute and 1 MiB of RAM, MinGW gcc-3.4.5
diff --git a/compiler_gcc_warnings.make b/compiler_gcc_warnings.make
index abc90f14..6417827e 100644
--- a/compiler_gcc_warnings.make
+++ b/compiler_gcc_warnings.make
@@ -22,3 +22,252 @@
# Don't remake this makefile.
$(srcdir)/compiler_gcc_warnings.make:: ;
+
+# Warnings for gcc.
+
+gcc_version_specific_c_warnings :=
+gcc_version_specific_cxx_warnings :=
+
+ifneq (,$(filter $(gcc_version), 10 10.0))
+# Nothing to do here.
+else ifneq (,$(filter $(gcc_version), 11 11.0))
+
+# g++-11 warnings not recognized by g++-10
+#
+# The gcc manual says that '-Wenum-conversion' is for C only,
+# but `make show_overlooked_cxx_warnings` disagreed.
+
+ gcc_version_specific_cxx_warnings := \
+ -Wctad-maybe-unsupported \
+ -Wdeprecated-enum-enum-conversion \
+ -Wdeprecated-enum-float-conversion \
+ -Wenum-conversion \
+ -Winvalid-imported-macros \
+
+endif
+
+# Write '-Wno' options at the end, with a rationale here.
+#
+# -Wabi: useful only for a special purpose
+# -Wanalyzer-too-complex: not actually helpful
+# -Wdate-time: only for "bit-wise-identical reproducible compilations"
+# -Wfloat-equal: too many warnings on correct code, e.g.,
+# exact comparison to zero
+# -Winline: 'inline' now refers to linkage, not inlining
+# -Wmissing-declarations: for C++, this flags valid functions that
+# arguably belong in an unnamed namespace
+# -Wpadded: useful only for low-level work
+# -Wparentheses: its diagnostics are beyond pedantic
+# -Wpsabi: undocumented--ARM only?
+# -Wsign-conversion: [see note elsewhere in this file]
+# -Wsuggest-attribute: too gcc-specific
+# -Wsystem-headers: not generally useful
+# -Wswitch-default: false positives for switches on enums that
+# include all cases (verified by -Wswitch-enum)
+
+treat_warnings_as_errors := -pedantic-errors -Werror
+
+gcc_common_warnings := \
+ $(treat_warnings_as_errors) \
+ -Waggregate-return \
+ -Wall \
+ -Walloc-zero \
+ -Walloca \
+ -Warith-conversion \
+ -Wcast-align=strict \
+ -Wcast-function-type \
+ -Wconversion \
+ -Wdangling-else \
+ -Wdeprecated-declarations \
+ -Wdisabled-optimization \
+ -Wdouble-promotion \
+ -Wduplicated-branches \
+ -Wduplicated-cond \
+ -Wextra \
+ -Wformat=2 \
+ -Wformat-nonliteral \
+ -Wformat-overflow=2 \
+ -Wformat-security \
+ -Wformat-signedness \
+ -Wformat-truncation \
+ -Wformat-y2k \
+ -Wimport \
+ -Winit-self \
+ -Winvalid-pch \
+ -Wlogical-op \
+ -Wmissing-include-dirs \
+ -Wmultichar \
+ -Wnull-dereference \
+ -Wpacked \
+ -Wpointer-arith \
+ -Wredundant-decls \
+ -Wrestrict \
+ -Wshadow \
+ -Wshift-overflow=2 \
+ -Wsign-compare \
+ -Wstack-protector \
+ -Wstrict-overflow \
+ -Wstringop-overflow=4 \
+ -Wswitch-enum \
+ -Wtrampolines \
+ -Wundef \
+ -Wunreachable-code \
+ -Wunsafe-loop-optimizations \
+ -Wunused-macros \
+ -Wvector-operation-performance \
+ -Wvla \
+ -Wno-abi \
+ -Wno-analyzer-too-complex \
+ -Wno-date-time \
+ -Wno-float-equal \
+ -Wno-inline \
+ -Wno-missing-declarations \
+ -Wno-padded \
+ -Wno-parentheses \
+ -Wno-psabi \
+ -Wno-sign-conversion \
+ -Wno-suggest-attribute=pure \
+ -Wno-suggest-attribute=const \
+ -Wno-suggest-attribute=noreturn \
+ -Wno-suggest-attribute=malloc \
+ -Wno-suggest-attribute=format \
+ -Wno-suggest-attribute=cold \
+ -Wno-system-headers \
+ -Wno-switch-default \
+
+# Consider these later:
+postponed_gcc_common_warnings := \
+
+# Write '-Wno' options at the end, with a rationale here.
+#
+# -Wunsuffixed-float-constants: a migration aid to support an eventual
+# FLOAT_CONST_DECIMAL64 pragma, but only a nuisance for now
+
+gcc_c_warnings := \
+ $(gcc_common_warnings) \
+ -Wbad-function-cast \
+ -Wc++-compat \
+ -Wjump-misses-init \
+ -Wmissing-braces \
+ -Wmissing-prototypes \
+ -Wnested-externs \
+ -Wold-style-definition \
+ -Wstrict-prototypes \
+ -Wtraditional-conversion \
+ -Wwrite-strings \
+ -Wno-unsuffixed-float-constants \
+
+# Write '-Wno' options at the end, with a rationale here.
+#
+# -Wabi-tag: useful only for a special purpose
+# -Waggregate-return: generally incompatible with C++
+# -Weffc++: obsolescent
+# -Wmismatched-tags: not helpful--see:
+# https://lists.nongnu.org/archive/html/lmi/2016-05/msg00075.html
+# -Wmultiple-inheritance: forbids a useful feature
+# -Wnamespaces: forbids a useful feature
+# -Wsign-promo: too many false positives--see:
+# https://lists.nongnu.org/archive/html/lmi/2019-03/msg00016.html
+# -Wsuggest-final-methods, and
+# -Wsuggest-final-types: use these only occasionally, like -Weffc++;
+# work with '-Wsuggest-final-types' first, because making a class
+# final may resolve '-Wsuggest-final-methods' suggestions for its
+# members; but expect many false positives
+# -Wtemplates: forbids a useful feature
+# -Wvirtual-inheritance: forbids a useful feature
+
+gcc_cxx_warnings := \
+ $(gcc_common_warnings) \
+ -Wc++11-compat \
+ -Wc++14-compat \
+ -Wc++1z-compat \
+ -Wcatch-value=3 \
+ -Wcomma-subscript \
+ -Wconditionally-supported \
+ -Wctor-dtor-privacy \
+ -Wdelete-non-virtual-dtor \
+ -Wdeprecated \
+ -Wdeprecated-copy-dtor \
+ -Wextra-semi \
+ -Wnoexcept \
+ -Wnoexcept-type \
+ -Wnon-template-friend \
+ -Wnon-virtual-dtor \
+ -Wold-style-cast \
+ -Woverloaded-virtual \
+ -Wplacement-new=2 \
+ -Wpmf-conversions \
+ -Wredundant-tags \
+ -Wregister \
+ -Wreorder \
+ -Wstrict-null-sentinel \
+ -Wsuggest-override \
+ -Wsynth \
+ -Wuseless-cast \
+ -Wvolatile \
+ -Wzero-as-null-pointer-constant \
+ -Wno-abi-tag \
+ -Wno-aggregate-return \
+ -Wno-effc++ \
+ -Wno-mismatched-tags \
+ -Wno-multiple-inheritance \
+ -Wno-namespaces \
+ -Wno-sign-promo \
+ -Wno-suggest-final-methods \
+ -Wno-suggest-final-types \
+ -Wno-templates \
+ -Wno-virtual-inheritance \
+
+# Consider these later:
+postponed_gcc_cxx_warnings := \
+
+gcc_common_extra_warnings := \
+ -Wcast-qual \
+
+bourn_cast_test.o: gcc_common_extra_warnings += \
+ -Wno-double-promotion \
+
+$(cgicc_objects): gcc_common_extra_warnings += \
+ -Wno-conversion \
+ -Wno-zero-as-null-pointer-constant \
+
+# XMLWRAPP !! Remove these workarounds after updating xmlwrapp. See:
+# https://lists.nongnu.org/archive/html/lmi/2019-03/msg00018.html
+# et seqq.:
+$(xmlwrapp_objects): gcc_common_extra_warnings += \
+ -Wno-conversion \
+
+# SOMEDAY !! Address some of these '-Wconversion' issues.
+
+wno_conv_objects := \
+ rate_table.o \
+ round_glibc.o \
+
+$(wno_conv_objects): gcc_common_extra_warnings += -Wno-conversion
-Wfloat-conversion
+
+wno_sign_conv_objects := \
+ $(wx_dependent_objects) \
+ crc32.o \
+ getopt.o \
+ md5.o \
+ round_glibc.o \
+
+# '-Wsign-conversion' is generally unusable with C++ because the STL
+# defectively uses unsigned types. It is useful to enable it from
+# time to time and filter the output thus:
+# grep 'error:' | sed -e '/size_type/d'
+
+$(wno_sign_conv_objects): gcc_common_extra_warnings += -Wno-sign-conversion
+
+# Keep version-specific warnings last, so that they override others.
+
+C_WARNINGS = \
+ $(gcc_c_warnings) \
+ $(gcc_common_extra_warnings) \
+ $(gcc_version_specific_c_warnings) \
+
+CXX_WARNINGS = \
+ $(gcc_cxx_warnings) \
+ $(gcc_common_extra_warnings) \
+ $(gcc_version_specific_cxx_warnings) \
+
- [lmi-commits] [lmi] master updated (ceb0ac3b -> 01aa1fd4), Greg Chicares, 2022/06/28
- [lmi-commits] [lmi] master 984ccf07 3/9: Expunge useless history, Greg Chicares, 2022/06/28
- [lmi-commits] [lmi] master a3571e5d 4/9: Remove a dependency on an ancient gcc version, Greg Chicares, 2022/06/28
- [lmi-commits] [lmi] master d20268b2 5/9: Remove another dependency on an ancient gcc version, Greg Chicares, 2022/06/28
- [lmi-commits] [lmi] master 2f9d615f 8/9: Move a definition, Greg Chicares, 2022/06/28
- [lmi-commits] [lmi] master 9f2184d3 1/9: Record some handy commands, Greg Chicares, 2022/06/28
- [lmi-commits] [lmi] master 7947ec4e 2/9: Distinguish dialect options from warnings, Greg Chicares, 2022/06/28
- [lmi-commits] [lmi] master 01aa1fd4 9/9: Factor out gcc warnings,
Greg Chicares <=
- [lmi-commits] [lmi] master be9c647f 6/9: Prepare for more transplantation, Greg Chicares, 2022/06/28
- [lmi-commits] [lmi] master 0e74982c 7/9: Transplant ascertainment of compiler version, Greg Chicares, 2022/06/28