diff --git a/configure.in b/configure.in index 5f70e6db9b..321e06d2ab 100644 --- a/configure.in +++ b/configure.in @@ -419,6 +419,8 @@ AC_SUBST(LD) if test "$GCC" = yes; then linker_flag=-Wl, : ${optflags=-O3} + gcc_major=`echo =__GNUC__ | $CC -E -xc - | sed '/^=/!d;s///'` + test -n "$gcc_major" || gcc_major=0 # RUBY_APPEND_OPTIONS(XCFLAGS, ["-include ruby/config.h" "-include ruby/missing.h"]) else linker_flag= @@ -664,6 +666,11 @@ AC_ARG_ENABLE(werror, rb_cv_warnflags="$warnflags" if test "$GCC:${warnflags+set}:no" = yes::no; then + if test $gcc_major -ge 4; then + extra_warning=-Werror=extra-tokens + else + extra_warning= + fi for wflag in -Wno-unused-parameter -Wno-parentheses -Wno-long-long \ -Wno-missing-field-initializers \ -Wunused-variable \ @@ -672,7 +679,7 @@ if test "$GCC:${warnflags+set}:no" = yes::no; then -Werror=declaration-after-statement \ -Werror=shorten-64-to-32 \ -Werror=implicit-function-declaration \ - -Werror=extra-tokens \ + $extra_warning \ ; do if test "$particular_werror_flags" != yes; then wflag=`echo x$wflag | sed 's/^x-Werror=/-W/;s/^x//'`