]> git.ipfire.org Git - thirdparty/gettext.git/commitdiff
build: Silence most warnings from gcc 11.
authorBruno Haible <bruno@clisp.org>
Mon, 19 Jun 2023 13:05:34 +0000 (15:05 +0200)
committerBruno Haible <bruno@clisp.org>
Mon, 19 Jun 2023 13:05:34 +0000 (15:05 +0200)
* m4/more-warnings.m4 (gt_MORE_WARNINGS): With gcc 11 or older, silence three
more types of warnings.

m4/more-warnings.m4

index 42c168b10ecfca3b4c5f1d3fdee0ab2e0c3b9d7a..d0ebdf34870dba905ddd14c5b7f3d4f1eff4fe81 100644 (file)
@@ -1,4 +1,4 @@
-# more-warnings.m4 serial 1 (gettext-0.21.2)
+# more-warnings.m4 serial 2 (gettext-0.23)
 dnl Copyright (C) 2023 Free Software Foundation, Inc.
 dnl This file is free software, distributed under the terms of the GNU
 dnl General Public License.  As a special exception to the GNU General
@@ -135,6 +135,18 @@ AS_HELP_STRING([[--disable-more-warnings]], [obey exactly the warning options sp
     dnl that the compiler could often infer and which have little effect on the
     dnl performance of the generated code.
     nw="$nw -Wsuggest-attribute=cold"
+    dnl With GCC 11 and older, there warnings are pointless:
+    dnl "warning: stack protector not protecting local variables: variable
+    dnl length buffer [-Wstack-protector]", "[-Wanalyzer-use-after-free],
+    dnl "[-Wanalyzer-free-of-non-heap]".
+    AC_PREPROC_IFELSE([AC_LANG_PROGRAM([[
+      #if __GNUC__ > 11
+      #error "You are lucky"
+      #endif
+      ]])],
+      [nw="$nw -Wstack-protector"
+       nw="$nw -Wanalyzer-use-after-free -Wanalyzer-free-of-non-heap"
+      ])
 
     dnl Setup the list of meaningful warning options for the C compiler.
     dnl The list comes from manywarnings.m4. Warning options that are not