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

Commit e716585

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 6b74f5e commit e716585

File tree

2 files changed

+100
-0
lines changed

2 files changed

+100
-0
lines changed

configure

Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5815,6 +5815,7 @@ fi
58155815
# We want to suppress clang's unhelpful unused-command-line-argument warnings
58165816
# but gcc won't complain about unrecognized -Wno-foo switches, so we have to
58175817
# test for the positive form and if that works, add the negative form
5818+
NOT_THE_CFLAGS=""
58185819
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether ${CC} supports -Wunused-command-line-argument, for NOT_THE_CFLAGS" >&5
58195820
$as_echo_n "checking whether ${CC} supports -Wunused-command-line-argument, for NOT_THE_CFLAGS... " >&6; }
58205821
if ${pgac_cv_prog_CC_cflags__Wunused_command_line_argument+:} false; then :
@@ -5857,6 +5858,93 @@ fi
58575858
if test -n "$NOT_THE_CFLAGS"; then
58585859
CFLAGS="$CFLAGS -Wno-unused-command-line-argument"
58595860
fi
5861+
# Similarly disable useless truncation warnings from gcc 8+
5862+
NOT_THE_CFLAGS=""
5863+
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether ${CC} supports -Wformat-truncation, for NOT_THE_CFLAGS" >&5
5864+
$as_echo_n "checking whether ${CC} supports -Wformat-truncation, for NOT_THE_CFLAGS... " >&6; }
5865+
if ${pgac_cv_prog_CC_cflags__Wformat_truncation+:} false; then :
5866+
$as_echo_n "(cached) " >&6
5867+
else
5868+
pgac_save_CFLAGS=$CFLAGS
5869+
pgac_save_CC=$CC
5870+
CC=${CC}
5871+
CFLAGS="${NOT_THE_CFLAGS} -Wformat-truncation"
5872+
ac_save_c_werror_flag=$ac_c_werror_flag
5873+
ac_c_werror_flag=yes
5874+
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
5875+
/* end confdefs.h. */
5876+
5877+
int
5878+
main ()
5879+
{
5880+
5881+
;
5882+
return 0;
5883+
}
5884+
_ACEOF
5885+
if ac_fn_c_try_compile "$LINENO"; then :
5886+
pgac_cv_prog_CC_cflags__Wformat_truncation=yes
5887+
else
5888+
pgac_cv_prog_CC_cflags__Wformat_truncation=no
5889+
fi
5890+
rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
5891+
ac_c_werror_flag=$ac_save_c_werror_flag
5892+
CFLAGS="$pgac_save_CFLAGS"
5893+
CC="$pgac_save_CC"
5894+
fi
5895+
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $pgac_cv_prog_CC_cflags__Wformat_truncation" >&5
5896+
$as_echo "$pgac_cv_prog_CC_cflags__Wformat_truncation" >&6; }
5897+
if test x"$pgac_cv_prog_CC_cflags__Wformat_truncation" = x"yes"; then
5898+
NOT_THE_CFLAGS="${NOT_THE_CFLAGS} -Wformat-truncation"
5899+
fi
5900+
5901+
5902+
if test -n "$NOT_THE_CFLAGS"; then
5903+
CFLAGS="$CFLAGS -Wno-format-truncation"
5904+
fi
5905+
NOT_THE_CFLAGS=""
5906+
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether ${CC} supports -Wstringop-truncation, for NOT_THE_CFLAGS" >&5
5907+
$as_echo_n "checking whether ${CC} supports -Wstringop-truncation, for NOT_THE_CFLAGS... " >&6; }
5908+
if ${pgac_cv_prog_CC_cflags__Wstringop_truncation+:} false; then :
5909+
$as_echo_n "(cached) " >&6
5910+
else
5911+
pgac_save_CFLAGS=$CFLAGS
5912+
pgac_save_CC=$CC
5913+
CC=${CC}
5914+
CFLAGS="${NOT_THE_CFLAGS} -Wstringop-truncation"
5915+
ac_save_c_werror_flag=$ac_c_werror_flag
5916+
ac_c_werror_flag=yes
5917+
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
5918+
/* end confdefs.h. */
5919+
5920+
int
5921+
main ()
5922+
{
5923+
5924+
;
5925+
return 0;
5926+
}
5927+
_ACEOF
5928+
if ac_fn_c_try_compile "$LINENO"; then :
5929+
pgac_cv_prog_CC_cflags__Wstringop_truncation=yes
5930+
else
5931+
pgac_cv_prog_CC_cflags__Wstringop_truncation=no
5932+
fi
5933+
rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
5934+
ac_c_werror_flag=$ac_save_c_werror_flag
5935+
CFLAGS="$pgac_save_CFLAGS"
5936+
CC="$pgac_save_CC"
5937+
fi
5938+
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $pgac_cv_prog_CC_cflags__Wstringop_truncation" >&5
5939+
$as_echo "$pgac_cv_prog_CC_cflags__Wstringop_truncation" >&6; }
5940+
if test x"$pgac_cv_prog_CC_cflags__Wstringop_truncation" = x"yes"; then
5941+
NOT_THE_CFLAGS="${NOT_THE_CFLAGS} -Wstringop-truncation"
5942+
fi
5943+
5944+
5945+
if test -n "$NOT_THE_CFLAGS"; then
5946+
CFLAGS="$CFLAGS -Wno-stringop-truncation"
5947+
fi
58605948
elif test "$ICC" = yes; then
58615949
# Intel's compiler has a bug/misoptimization in checking for
58625950
# 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
@@ -498,10 +498,22 @@ if test "$GCC" = yes -a "$ICC" = no; then
498498
# We want to suppress clang's unhelpful unused-command-line-argument warnings
499499
# but gcc won't complain about unrecognized -Wno-foo switches, so we have to
500500
# test for the positive form and if that works, add the negative form
501+
NOT_THE_CFLAGS=""
501502
PGAC_PROG_CC_VAR_OPT(NOT_THE_CFLAGS, [-Wunused-command-line-argument])
502503
if test -n "$NOT_THE_CFLAGS"; then
503504
CFLAGS="$CFLAGS -Wno-unused-command-line-argument"
504505
fi
506+
# Similarly disable useless truncation warnings from gcc 8+
507+
NOT_THE_CFLAGS=""
508+
PGAC_PROG_CC_VAR_OPT(NOT_THE_CFLAGS, [-Wformat-truncation])
509+
if test -n "$NOT_THE_CFLAGS"; then
510+
CFLAGS="$CFLAGS -Wno-format-truncation"
511+
fi
512+
NOT_THE_CFLAGS=""
513+
PGAC_PROG_CC_VAR_OPT(NOT_THE_CFLAGS, [-Wstringop-truncation])
514+
if test -n "$NOT_THE_CFLAGS"; then
515+
CFLAGS="$CFLAGS -Wno-stringop-truncation"
516+
fi
505517
elif test "$ICC" = yes; then
506518
# Intel's compiler has a bug/misoptimization in checking for
507519
# division by NAN (NaN == 0), -mp1 fixes it, so add it to the CFLAGS.

0 commit comments

Comments
 (0)