Updates for last 2 commits: use a better tactic to deal when

trying to disable warnings in pragma's that are unknown to the
compiler.

We prefer -Wno-unknown-warning-option, which does exactly what
we want. If not available then fallback to -Wno-unknown-pragmas.
That way on recent clang/gcc's we keep the useful pragma warnings,
while still being able to compile on older compiler versions.
This commit is contained in:
Bram Matthys 2021-09-12 10:08:22 +02:00
parent f8811c1f4a
commit a55f2e0c03
No known key found for this signature in database
GPG key ID: BF8116B163EAAE98
2 changed files with 26 additions and 6 deletions

16
configure vendored
View file

@ -5916,9 +5916,9 @@ fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ax_cv_check_cflags__Werror___Wunknown_pragmas" >&5
$as_echo "$ax_cv_check_cflags__Werror___Wunknown_pragmas" >&6; }
if test x"$ax_cv_check_cflags__Werror___Wunknown_pragmas" = xyes; then :
CFLAGS="$CFLAGS -Wno-unknown-pragmas"
unknown_pragmas=1
else
:
unknown_pragmas=0
fi
ac_ext=c
@ -5963,9 +5963,9 @@ fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ax_cv_check_cflags__Werror___Wunknown_warning_option" >&5
$as_echo "$ax_cv_check_cflags__Werror___Wunknown_warning_option" >&6; }
if test x"$ax_cv_check_cflags__Werror___Wunknown_warning_option" = xyes; then :
CFLAGS="$CFLAGS -Wno-unknown-warning-option"
unknown_warning_option=1
else
:
unknown_warning_option=0
fi
ac_ext=c
@ -5975,6 +5975,14 @@ ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $
ac_compiler_gnu=$ac_cv_c_compiler_gnu
if test "$unknown_warning_option" = "1"; then
CFLAGS="$CFLAGS -Wno-unknown-warning-option"
else
if test "$unknown_pragmas" = "1"; then
CFLAGS="$CFLAGS -Wno-unknown-pragmas"
fi
fi

View file

@ -256,8 +256,20 @@ dnl This one MUST be LAST!!
dnl It disables -Wsomeunknownoption being an error. Which is needed for
dnl the pragma's in individual files to selectively disable some warnings
dnl on clang/gcc (that may exist in eg gcc but not in clang or vice versa).
check_cc_flag([-Wunknown-pragmas], [CFLAGS="$CFLAGS -Wno-unknown-pragmas"])
check_cc_flag([-Wunknown-warning-option], [CFLAGS="$CFLAGS -Wno-unknown-warning-option"])
check_cc_flag([-Wunknown-pragmas], [unknown_pragmas=1],[unknown_pragmas=0])
check_cc_flag([-Wunknown-warning-option], [unknown_warning_option=1], [unknown_warning_option=0])
if test "$unknown_warning_option" = "1"; then
dnl This is the best option
CFLAGS="$CFLAGS -Wno-unknown-warning-option"
else
if test "$unknown_pragmas" = "1"; then
dnl This is a fallback needed for older gcc/clang, it also
dnl disables several other useful warnings/errors related
dnl to pragma's unfortunately.
CFLAGS="$CFLAGS -Wno-unknown-pragmas"
fi
fi
dnl End of -W... compiler checks.