Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit0fe954c

Browse files
committed
Add -Wshadow=compatible-local to the standard compilation flags
Sincecd4e8ca, we've been able to build the source tree with-Wshadow=compatible-local without any warnings. Lots of work was done byJustin Pryzby and I (David) to get all our code to compile warning freewith that flag. In that process, 2 bugs (16d69ec andaf7d270) werediscovered and fixed. Additionally, "git log --grep=shadow" shows thatthere is no shortage of other bugs that have been fixed over the yearswhich were caused by variable shadowing.In light of the above, it seems very much worthwhile to add at least-Wshadow=compatible-local to our standard compilation flags. We *may*want to go further and take this to -Wshadow=local in the future, butwe're not ready for that today, so let's add -Wshadow=compatible-local nowto help make sure we don't introduce further local variable shadowing.Author: Andres FreundDiscussion:https://postgr.es/m/20221006003920.6xlqaoccxwisza5k@awork3.anarazel.de
1 parent80ef926 commit0fe954c

File tree

3 files changed

+94
-0
lines changed

3 files changed

+94
-0
lines changed

‎configure

Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5852,6 +5852,97 @@ if test x"$pgac_cv_prog_CXX_cxxflags__Wcast_function_type" = x"yes"; then
58525852
fi
58535853

58545854

5855+
5856+
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether ${CC} supports -Wshadow=compatible-local, for CFLAGS" >&5
5857+
$as_echo_n "checking whether ${CC} supports -Wshadow=compatible-local, for CFLAGS... " >&6; }
5858+
if ${pgac_cv_prog_CC_cflags__Wshadow_compatible_local+:} false; then :
5859+
$as_echo_n "(cached) " >&6
5860+
else
5861+
pgac_save_CFLAGS=$CFLAGS
5862+
pgac_save_CC=$CC
5863+
CC=${CC}
5864+
CFLAGS="${CFLAGS} -Wshadow=compatible-local"
5865+
ac_save_c_werror_flag=$ac_c_werror_flag
5866+
ac_c_werror_flag=yes
5867+
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
5868+
/* end confdefs.h. */
5869+
5870+
int
5871+
main ()
5872+
{
5873+
5874+
;
5875+
return 0;
5876+
}
5877+
_ACEOF
5878+
if ac_fn_c_try_compile "$LINENO"; then :
5879+
pgac_cv_prog_CC_cflags__Wshadow_compatible_local=yes
5880+
else
5881+
pgac_cv_prog_CC_cflags__Wshadow_compatible_local=no
5882+
fi
5883+
rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
5884+
ac_c_werror_flag=$ac_save_c_werror_flag
5885+
CFLAGS="$pgac_save_CFLAGS"
5886+
CC="$pgac_save_CC"
5887+
fi
5888+
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $pgac_cv_prog_CC_cflags__Wshadow_compatible_local" >&5
5889+
$as_echo "$pgac_cv_prog_CC_cflags__Wshadow_compatible_local" >&6; }
5890+
if test x"$pgac_cv_prog_CC_cflags__Wshadow_compatible_local" = x"yes"; then
5891+
CFLAGS="${CFLAGS} -Wshadow=compatible-local"
5892+
fi
5893+
5894+
5895+
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether ${CXX} supports -Wshadow=compatible-local, for CXXFLAGS" >&5
5896+
$as_echo_n "checking whether ${CXX} supports -Wshadow=compatible-local, for CXXFLAGS... " >&6; }
5897+
if ${pgac_cv_prog_CXX_cxxflags__Wshadow_compatible_local+:} false; then :
5898+
$as_echo_n "(cached) " >&6
5899+
else
5900+
pgac_save_CXXFLAGS=$CXXFLAGS
5901+
pgac_save_CXX=$CXX
5902+
CXX=${CXX}
5903+
CXXFLAGS="${CXXFLAGS} -Wshadow=compatible-local"
5904+
ac_save_cxx_werror_flag=$ac_cxx_werror_flag
5905+
ac_cxx_werror_flag=yes
5906+
ac_ext=cpp
5907+
ac_cpp='$CXXCPP $CPPFLAGS'
5908+
ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5'
5909+
ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
5910+
ac_compiler_gnu=$ac_cv_cxx_compiler_gnu
5911+
5912+
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
5913+
/* end confdefs.h. */
5914+
5915+
int
5916+
main ()
5917+
{
5918+
5919+
;
5920+
return 0;
5921+
}
5922+
_ACEOF
5923+
if ac_fn_cxx_try_compile "$LINENO"; then :
5924+
pgac_cv_prog_CXX_cxxflags__Wshadow_compatible_local=yes
5925+
else
5926+
pgac_cv_prog_CXX_cxxflags__Wshadow_compatible_local=no
5927+
fi
5928+
rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
5929+
ac_ext=c
5930+
ac_cpp='$CPP $CPPFLAGS'
5931+
ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
5932+
ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
5933+
ac_compiler_gnu=$ac_cv_c_compiler_gnu
5934+
5935+
ac_cxx_werror_flag=$ac_save_cxx_werror_flag
5936+
CXXFLAGS="$pgac_save_CXXFLAGS"
5937+
CXX="$pgac_save_CXX"
5938+
fi
5939+
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $pgac_cv_prog_CXX_cxxflags__Wshadow_compatible_local" >&5
5940+
$as_echo "$pgac_cv_prog_CXX_cxxflags__Wshadow_compatible_local" >&6; }
5941+
if test x"$pgac_cv_prog_CXX_cxxflags__Wshadow_compatible_local" = x"yes"; then
5942+
CXXFLAGS="${CXXFLAGS} -Wshadow=compatible-local"
5943+
fi
5944+
5945+
58555946
# This was included in -Wall/-Wformat in older GCC versions
58565947

58575948
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether ${CC} supports -Wformat-security, for CFLAGS" >&5

‎configure.ac

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -508,6 +508,8 @@ if test "$GCC" = yes -a "$ICC" = no; then
508508
PGAC_PROG_CXX_CFLAGS_OPT([-Wimplicit-fallthrough=3])
509509
PGAC_PROG_CC_CFLAGS_OPT([-Wcast-function-type])
510510
PGAC_PROG_CXX_CFLAGS_OPT([-Wcast-function-type])
511+
PGAC_PROG_CC_CFLAGS_OPT([-Wshadow=compatible-local])
512+
PGAC_PROG_CXX_CFLAGS_OPT([-Wshadow=compatible-local])
511513
# This was included in -Wall/-Wformat in older GCC versions
512514
PGAC_PROG_CC_CFLAGS_OPT([-Wformat-security])
513515
PGAC_PROG_CXX_CFLAGS_OPT([-Wformat-security])

‎meson.build

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1709,6 +1709,7 @@ common_warning_flags = [
17091709
'-Wmissing-format-attribute',
17101710
'-Wimplicit-fallthrough=3',
17111711
'-Wcast-function-type',
1712+
'-Wshadow=compatible-local',
17121713
# This was included in -Wall/-Wformat in older GCC versions
17131714
'-Wformat-security',
17141715
]

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp