Skip to content

Commit

Permalink
Add a check for misbehaving -Wcomment from gcc-4.7 and add
Browse files Browse the repository at this point in the history
-Wno-comment to the compilation flags if so.

Patch by Filipe Cabecinhas, configure regenerated by me.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@221323 91177308-0d34-0410-b5e6-96231b3b80d8
  • Loading branch information
echristo committed Nov 5, 2014
1 parent cafa378 commit 4cd064b
Show file tree
Hide file tree
Showing 4 changed files with 97 additions and 9 deletions.
2 changes: 2 additions & 0 deletions Makefile.config.in
Original file line number Diff line number Diff line change
Expand Up @@ -396,6 +396,8 @@ COVERED_SWITCH_DEFAULT = @COVERED_SWITCH_DEFAULT@
NO_UNINITIALIZED = @NO_UNINITIALIZED@
# -Wno-maybe-uninitialized
NO_MAYBE_UNINITIALIZED = @NO_MAYBE_UNINITIALIZED@
# -Wno-comment
NO_COMMENT = @NO_COMMENT@

# Was polly found in tools/polly?
LLVM_HAS_POLLY = @LLVM_HAS_POLLY@
Expand Down
2 changes: 1 addition & 1 deletion Makefile.rules
Original file line number Diff line number Diff line change
Expand Up @@ -679,7 +679,7 @@ endif
CompileCommonOpts += -Wall -W -Wno-unused-parameter -Wwrite-strings \
$(EXTRA_OPTIONS) $(COVERED_SWITCH_DEFAULT) \
$(NO_UNINITIALIZED) $(NO_MAYBE_UNINITIALIZED) \
$(NO_MISSING_FIELD_INITIALIZERS)
$(NO_MISSING_FIELD_INITIALIZERS) $(NO_COMMENT)
# Enable cast-qual for C++; the workaround is to use const_cast.
CXX.Flags += -Wcast-qual

Expand Down
22 changes: 21 additions & 1 deletion autoconf/configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -1386,7 +1386,27 @@ then
CXX_FLAG_CHECK(NO_UNINITIALIZED, [-Wno-uninitialized])
fi
fi
AC_MSG_RESULT([$NO_VARIADIC_MACROS $NO_MISSING_FIELD_INITIALIZERS $COVERED_SWITCH_DEFAULT $NO_UNINITIALIZED $NO_MAYBE_UNINITIALIZED])

dnl Check for misbehaving -Wcomment (gcc-4.7 has this) and maybe add
dnl -Wno-comment to the flags.
no_comment=
llvm_cv_old_cxxflags="$CXXFLAGS"
CXXFLAGS="$CXXFLAGS -Wcomment -Werror"
AC_COMPILE_IFELSE(
[
AC_LANG_SOURCE([[// Comment \o\
// Another comment
int main() { return 0; }
]])
],
[
no_comment=-Wno-comment
],
[])
AC_SUBST(NO_COMMENT, [$no_comment])
CXXFLAGS="$llvm_cv_old_cxxflags"

AC_MSG_RESULT([$NO_VARIADIC_MACROS $NO_MISSING_FIELD_INITIALIZERS $COVERED_SWITCH_DEFAULT $NO_UNINITIALIZED $NO_MAYBE_UNINITIALIZED $NO_COMMENT])

AC_ARG_WITH([python],
[AS_HELP_STRING([--with-python], [path to python])],
Expand Down
80 changes: 73 additions & 7 deletions configure
Original file line number Diff line number Diff line change
Expand Up @@ -762,6 +762,7 @@ NO_MISSING_FIELD_INITIALIZERS
COVERED_SWITCH_DEFAULT
NO_MAYBE_UNINITIALIZED
NO_UNINITIALIZED
NO_COMMENT
PYTHON
HAVE_DLOPEN
HAVE_TERMINFO
Expand Down Expand Up @@ -8066,8 +8067,74 @@ then

fi
fi
{ echo "$as_me:$LINENO: result: $NO_VARIADIC_MACROS $NO_MISSING_FIELD_INITIALIZERS $COVERED_SWITCH_DEFAULT $NO_UNINITIALIZED $NO_MAYBE_UNINITIALIZED" >&5
echo "${ECHO_T}$NO_VARIADIC_MACROS $NO_MISSING_FIELD_INITIALIZERS $COVERED_SWITCH_DEFAULT $NO_UNINITIALIZED $NO_MAYBE_UNINITIALIZED" >&6; }

no_comment=
llvm_cv_old_cxxflags="$CXXFLAGS"
CXXFLAGS="$CXXFLAGS -Wcomment -Werror"
cat >conftest.$ac_ext <<_ACEOF

/* confdefs.h. */
_ACEOF
cat confdefs.h >>conftest.$ac_ext
cat >>conftest.$ac_ext <<_ACEOF
/* end confdefs.h. */
// Comment \o\
// Another comment
int main() { return 0; }


_ACEOF
rm -f conftest.$ac_objext
if { (ac_try="$ac_compile"
case "(($ac_try" in
*\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
*) ac_try_echo=$ac_try;;
esac
eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
(eval "$ac_compile") 2>conftest.er1
ac_status=$?
grep -v '^ *+' conftest.er1 >conftest.err
rm -f conftest.er1
cat conftest.err >&5
echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); } &&
{ ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err'
{ (case "(($ac_try" in
*\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
*) ac_try_echo=$ac_try;;
esac
eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
(eval "$ac_try") 2>&5
ac_status=$?
echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); }; } &&
{ ac_try='test -s conftest.$ac_objext'
{ (case "(($ac_try" in
*\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
*) ac_try_echo=$ac_try;;
esac
eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
(eval "$ac_try") 2>&5
ac_status=$?
echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); }; }; then

no_comment=-Wno-comment

else
echo "$as_me: failed program was:" >&5
sed 's/^/| /' conftest.$ac_ext >&5


fi

rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
NO_COMMENT=$no_comment

CXXFLAGS="$llvm_cv_old_cxxflags"

{ echo "$as_me:$LINENO: result: $NO_VARIADIC_MACROS $NO_MISSING_FIELD_INITIALIZERS $COVERED_SWITCH_DEFAULT $NO_UNINITIALIZED $NO_MAYBE_UNINITIALIZED $NO_COMMENT" >&5
echo "${ECHO_T}$NO_VARIADIC_MACROS $NO_MISSING_FIELD_INITIALIZERS $COVERED_SWITCH_DEFAULT $NO_UNINITIALIZED $NO_MAYBE_UNINITIALIZED $NO_COMMENT" >&6; }


# Check whether --with-python was given.
Expand Down Expand Up @@ -19278,6 +19345,7 @@ NO_MISSING_FIELD_INITIALIZERS!$NO_MISSING_FIELD_INITIALIZERS$ac_delim
COVERED_SWITCH_DEFAULT!$COVERED_SWITCH_DEFAULT$ac_delim
NO_MAYBE_UNINITIALIZED!$NO_MAYBE_UNINITIALIZED$ac_delim
NO_UNINITIALIZED!$NO_UNINITIALIZED$ac_delim
NO_COMMENT!$NO_COMMENT$ac_delim
PYTHON!$PYTHON$ac_delim
HAVE_DLOPEN!$HAVE_DLOPEN$ac_delim
HAVE_TERMINFO!$HAVE_TERMINFO$ac_delim
Expand Down Expand Up @@ -19312,7 +19380,7 @@ LIBOBJS!$LIBOBJS$ac_delim
LTLIBOBJS!$LTLIBOBJS$ac_delim
_ACEOF

if test `sed -n "s/.*$ac_delim\$/X/p" conf$$subs.sed | grep -c X` = 95; then
if test `sed -n "s/.*$ac_delim\$/X/p" conf$$subs.sed | grep -c X` = 96; then
break
elif $ac_last_try; then
{ { echo "$as_me:$LINENO: error: could not make $CONFIG_STATUS" >&5
Expand All @@ -19331,7 +19399,7 @@ fi

cat >>$CONFIG_STATUS <<_ACEOF
cat >"\$tmp/subs-2.sed" <<\CEOF$ac_eof
/@[a-zA-Z_][a-zA-Z_0-9]*@/!b end
/@[a-zA-Z_][a-zA-Z_0-9]*@/!b
_ACEOF
sed '
s/[,\\&]/\\&/g; s/@/@|#_!!_#|/g
Expand All @@ -19344,8 +19412,6 @@ N; s/^.*\n//; s/[,\\&]/\\&/g; s/@/@|#_!!_#|/g; b n
' >>$CONFIG_STATUS <conf$$subs.sed
rm -f conf$$subs.sed
cat >>$CONFIG_STATUS <<_ACEOF
:end
s/|#_!!_#|//g
CEOF$ac_eof
_ACEOF

Expand Down Expand Up @@ -19593,7 +19659,7 @@ s&@abs_builddir@&$ac_abs_builddir&;t t
s&@abs_top_builddir@&$ac_abs_top_builddir&;t t
s&@INSTALL@&$ac_INSTALL&;t t
$ac_datarootdir_hack
" $ac_file_inputs | sed -f "$tmp/subs-1.sed" | sed -f "$tmp/subs-2.sed" >$tmp/out
" $ac_file_inputs | sed -f "$tmp/subs-1.sed" | sed -f "$tmp/subs-2.sed" | sed 's/|#_!!_#|//g' >$tmp/out

test -z "$ac_datarootdir_hack$ac_datarootdir_seen" &&
{ ac_out=`sed -n '/\${datarootdir}/p' "$tmp/out"`; test -n "$ac_out"; } &&
Expand Down

0 comments on commit 4cd064b

Please sign in to comment.