From a6101db6920d12c4d61f1ace19d931670b9d8141 Mon Sep 17 00:00:00 2001 From: Paul Floyd Date: Tue, 21 Feb 2023 22:05:13 +0100 Subject: [PATCH] Try to correct configure script for warning flags with values Some -W flags come with and without an = (usually for warning levels) But some only have the form -Wfoo=42 and -Wno-foo --- configure.ac | 17 ++++++++++++++++- memcheck/tests/Makefile.am | 6 +++--- 2 files changed, 19 insertions(+), 4 deletions(-) diff --git a/configure.ac b/configure.ac index 546e874b4b..696c967ee1 100755 --- a/configure.ac +++ b/configure.ac @@ -2519,6 +2519,20 @@ AC_DEFUN([AC_GCC_WARNING_SUBST_NO],[ CFLAGS=$safe_CFLAGS ]) +# A variation of the above for arguments that +# take a value +AC_DEFUN([AC_GCC_WARNING_SUBST_NO_VAL],[ + AC_MSG_CHECKING([if gcc accepts -W$1=$2]) + safe_CFLAGS=$CFLAGS + CFLAGS="-W$1=$2 -Werror" + AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[;]])], [ + AC_SUBST([$3], [-Wno-$1]) + AC_MSG_RESULT([yes])], [ + AC_SUBST([$3], []) + AC_MSG_RESULT([no])]) + CFLAGS=$safe_CFLAGS +]) + # Convenience function. Like AC_GCC_WARNING_SUBST_NO, except it substitutes # -W$1 (instead of -Wno-$1). AC_DEFUN([AC_GCC_WARNING_SUBST],[ @@ -2553,7 +2567,8 @@ AC_GCC_WARNING_SUBST_NO([stringop-truncation], [FLAG_W_NO_STRINGOP_TRUNCATION]) AC_GCC_WARNING_SUBST_NO([format-overflow], [FLAG_W_NO_FORMAT_OVERFLOW]) AC_GCC_WARNING_SUBST_NO([use-after-free], [FLAG_W_NO_USE_AFTER_FREE]) AC_GCC_WARNING_SUBST_NO([free-nonheap-object], [FLAG_W_NO_FREE_NONHEAP_OBJECT]) -AC_GCC_WARNING_SUBST_NO([alloc-size-larger-than], [FLAG_W_NO_ALOC_SIZE_LARGER_THAN]) + +AC_GCC_WARNING_SUBST_NO_VAL([alloc-size-larger-than], [1677216], [FLAG_W_NO_ALLOC_SIZE_LARGER_THAN]) AC_GCC_WARNING_SUBST([write-strings], [FLAG_W_WRITE_STRINGS]) AC_GCC_WARNING_SUBST([empty-body], [FLAG_W_EMPTY_BODY]) diff --git a/memcheck/tests/Makefile.am b/memcheck/tests/Makefile.am index 281d8f55a4..efffe7b1c2 100644 --- a/memcheck/tests/Makefile.am +++ b/memcheck/tests/Makefile.am @@ -525,11 +525,11 @@ leak_cpp_interior_SOURCES = leak_cpp_interior.cpp # Suppress various gcc warnings which are correct, but for things # we are actually testing for at runtime. -accounting_CFLAGS = $(AM_CFLAGS) @FLAG_W_NO_ALOC_SIZE_LARGER_THAN@ +accounting_CFLAGS = $(AM_CFLAGS) @FLAG_W_NO_ALLOC_SIZE_LARGER_THAN@ badfree_CFLAGS = $(AM_CFLAGS) @FLAG_W_NO_FREE_NONHEAP_OBJECT@ -bug155125_CFLAGS = $(AM_CFLAGS) -Wno-unused-result @FLAG_W_NO_ALOC_SIZE_LARGER_THAN@ +bug155125_CFLAGS = $(AM_CFLAGS) -Wno-unused-result @FLAG_W_NO_ALLOC_SIZE_LARGER_THAN@ mallinfo_CFLAGS = $(AM_CFLAGS) -Wno-deprecated-declarations -malloc3_CFLAGS = $(AM_CFLAGS) @FLAG_W_NO_ALOC_SIZE_LARGER_THAN@ +malloc3_CFLAGS = $(AM_CFLAGS) @FLAG_W_NO_ALLOC_SIZE_LARGER_THAN@ sbfragment_CFLAGS = $(AM_CFLAGS) -Wno-deprecated-declarations strchr_CFLAGS = $(AM_CFLAGS) @FLAG_W_NO_UNINITIALIZED@ -- 2.43.5