Skip to content

Commit 99a1cfe

Browse files
committed
print warnings for conditional-uninitialized
This compiler flag is available for clang but not gcc. Test plan: ``` autogen.sh ./configure make check CC=clang ./configure make check ``` If a variable is used uninitialized, the warning should look something like: ``` CC src/tests-tests.o src/tests.c:4336:15: warning: variable 'recid' may be uninitialized when used here [-Wconditional-uninitialized] CHECK(recid >= 0 && recid < 4); ^~~~~ ./src/util.h:54:18: note: expanded from macro 'CHECK' if (EXPECT(!(cond), 0)) { \ ^~~~ ./src/util.h:41:39: note: expanded from macro 'EXPECT' ^ src/tests.c:4327:14: note: initialize the variable 'recid' to silence this warning int recid; ^ = 0 1 warning generated. ```
1 parent 3d2cf6c commit 99a1cfe

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

configure.ac

+9
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,15 @@ AC_COMPILE_IFELSE([AC_LANG_SOURCE([[char foo;]])],
7979
CFLAGS="$saved_CFLAGS"
8080
])
8181

82+
saved_CFLAGS="$CFLAGS"
83+
CFLAGS="-Wconditional-uninitialized $CFLAGS"
84+
AC_MSG_CHECKING([if ${CC} supports -Wconditional-uninitialized])
85+
AC_COMPILE_IFELSE([AC_LANG_SOURCE([[char foo;]])],
86+
[ AC_MSG_RESULT([yes]) ],
87+
[ AC_MSG_RESULT([no])
88+
CFLAGS="$saved_CFLAGS"
89+
])
90+
8291
saved_CFLAGS="$CFLAGS"
8392
CFLAGS="-fvisibility=hidden $CFLAGS"
8493
AC_MSG_CHECKING([if ${CC} supports -fvisibility=hidden])

0 commit comments

Comments
 (0)