Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 119290b

Browse files
committed
Use -Wno-format-truncation and -Wno-stringop-truncation, if available.
gcc 8 has started emitting some warnings that are largely useless for our purposes, particularly since they complain about code following the project-standard coding convention that path names are assumed to be shorter than MAXPGPATH. Even if we make the effort to remove that assumption in some future release, the changes wouldn't get back-patched. Hence, just suppress these warnings, on compilers that have these switches. Backpatch to all supported branches. Discussion: https://postgr.es/m/1524563856.26306.9.camel@gunduz.org
1 parent 58065f9 commit 119290b

File tree

2 files changed

+92
-0
lines changed

2 files changed

+92
-0
lines changed

configure

Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4744,6 +4744,7 @@ fi
47444744
# We want to suppress clang's unhelpful unused-command-line-argument warnings
47454745
# but gcc won't complain about unrecognized -Wno-foo switches, so we have to
47464746
# test for the positive form and if that works, add the negative form
4747+
NOT_THE_CFLAGS=""
47474748
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CC supports -Wunused-command-line-argument" >&5
47484749
$as_echo_n "checking whether $CC supports -Wunused-command-line-argument... " >&6; }
47494750
if ${pgac_cv_prog_cc_cflags__Wunused_command_line_argument+:} false; then :
@@ -4782,6 +4783,85 @@ fi
47824783
if test -n "$NOT_THE_CFLAGS"; then
47834784
CFLAGS="$CFLAGS -Wno-unused-command-line-argument"
47844785
fi
4786+
# Similarly disable useless truncation warnings from gcc 8+
4787+
NOT_THE_CFLAGS=""
4788+
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CC supports -Wformat-truncation" >&5
4789+
$as_echo_n "checking whether $CC supports -Wformat-truncation... " >&6; }
4790+
if ${pgac_cv_prog_cc_cflags__Wformat_truncation+:} false; then :
4791+
$as_echo_n "(cached) " >&6
4792+
else
4793+
pgac_save_CFLAGS=$CFLAGS
4794+
CFLAGS="$pgac_save_CFLAGS -Wformat-truncation"
4795+
ac_save_c_werror_flag=$ac_c_werror_flag
4796+
ac_c_werror_flag=yes
4797+
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
4798+
/* end confdefs.h. */
4799+
4800+
int
4801+
main ()
4802+
{
4803+
4804+
;
4805+
return 0;
4806+
}
4807+
_ACEOF
4808+
if ac_fn_c_try_compile "$LINENO"; then :
4809+
pgac_cv_prog_cc_cflags__Wformat_truncation=yes
4810+
else
4811+
pgac_cv_prog_cc_cflags__Wformat_truncation=no
4812+
fi
4813+
rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
4814+
ac_c_werror_flag=$ac_save_c_werror_flag
4815+
CFLAGS="$pgac_save_CFLAGS"
4816+
fi
4817+
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $pgac_cv_prog_cc_cflags__Wformat_truncation" >&5
4818+
$as_echo "$pgac_cv_prog_cc_cflags__Wformat_truncation" >&6; }
4819+
if test x"$pgac_cv_prog_cc_cflags__Wformat_truncation" = x"yes"; then
4820+
NOT_THE_CFLAGS="${NOT_THE_CFLAGS} -Wformat-truncation"
4821+
fi
4822+
4823+
if test -n "$NOT_THE_CFLAGS"; then
4824+
CFLAGS="$CFLAGS -Wno-format-truncation"
4825+
fi
4826+
NOT_THE_CFLAGS=""
4827+
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CC supports -Wstringop-truncation" >&5
4828+
$as_echo_n "checking whether $CC supports -Wstringop-truncation... " >&6; }
4829+
if ${pgac_cv_prog_cc_cflags__Wstringop_truncation+:} false; then :
4830+
$as_echo_n "(cached) " >&6
4831+
else
4832+
pgac_save_CFLAGS=$CFLAGS
4833+
CFLAGS="$pgac_save_CFLAGS -Wstringop-truncation"
4834+
ac_save_c_werror_flag=$ac_c_werror_flag
4835+
ac_c_werror_flag=yes
4836+
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
4837+
/* end confdefs.h. */
4838+
4839+
int
4840+
main ()
4841+
{
4842+
4843+
;
4844+
return 0;
4845+
}
4846+
_ACEOF
4847+
if ac_fn_c_try_compile "$LINENO"; then :
4848+
pgac_cv_prog_cc_cflags__Wstringop_truncation=yes
4849+
else
4850+
pgac_cv_prog_cc_cflags__Wstringop_truncation=no
4851+
fi
4852+
rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
4853+
ac_c_werror_flag=$ac_save_c_werror_flag
4854+
CFLAGS="$pgac_save_CFLAGS"
4855+
fi
4856+
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $pgac_cv_prog_cc_cflags__Wstringop_truncation" >&5
4857+
$as_echo "$pgac_cv_prog_cc_cflags__Wstringop_truncation" >&6; }
4858+
if test x"$pgac_cv_prog_cc_cflags__Wstringop_truncation" = x"yes"; then
4859+
NOT_THE_CFLAGS="${NOT_THE_CFLAGS} -Wstringop-truncation"
4860+
fi
4861+
4862+
if test -n "$NOT_THE_CFLAGS"; then
4863+
CFLAGS="$CFLAGS -Wno-stringop-truncation"
4864+
fi
47854865
elif test "$ICC" = yes; then
47864866
# Intel's compiler has a bug/misoptimization in checking for
47874867
# division by NAN (NaN == 0), -mp1 fixes it, so add it to the CFLAGS.

configure.in

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -459,10 +459,22 @@ if test "$GCC" = yes -a "$ICC" = no; then
459459
# We want to suppress clang's unhelpful unused-command-line-argument warnings
460460
# but gcc won't complain about unrecognized -Wno-foo switches, so we have to
461461
# test for the positive form and if that works, add the negative form
462+
NOT_THE_CFLAGS=""
462463
PGAC_PROG_CC_VAR_OPT(NOT_THE_CFLAGS, [-Wunused-command-line-argument])
463464
if test -n "$NOT_THE_CFLAGS"; then
464465
CFLAGS="$CFLAGS -Wno-unused-command-line-argument"
465466
fi
467+
# Similarly disable useless truncation warnings from gcc 8+
468+
NOT_THE_CFLAGS=""
469+
PGAC_PROG_CC_VAR_OPT(NOT_THE_CFLAGS, [-Wformat-truncation])
470+
if test -n "$NOT_THE_CFLAGS"; then
471+
CFLAGS="$CFLAGS -Wno-format-truncation"
472+
fi
473+
NOT_THE_CFLAGS=""
474+
PGAC_PROG_CC_VAR_OPT(NOT_THE_CFLAGS, [-Wstringop-truncation])
475+
if test -n "$NOT_THE_CFLAGS"; then
476+
CFLAGS="$CFLAGS -Wno-stringop-truncation"
477+
fi
466478
elif test "$ICC" = yes; then
467479
# Intel's compiler has a bug/misoptimization in checking for
468480
# division by NAN (NaN == 0), -mp1 fixes it, so add it to the CFLAGS.

0 commit comments

Comments
 (0)