public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* Add configure check for -Wimplicit-fallthrough
@ 2016-09-27 13:09 Marek Polacek
  2016-09-27 13:13 ` Richard Biener
  2016-09-27 13:14 ` Jakub Jelinek
  0 siblings, 2 replies; 6+ messages in thread
From: Marek Polacek @ 2016-09-27 13:09 UTC (permalink / raw)
  To: GCC Patches; +Cc: Jakub Jelinek

Using -Wno-error where only -Wno-implicit-fallthrough was meant was deemed
to coarse, so this patch attempts to add a configure check for this warnign
and only use -Wno-implicit-fallthrough when appropriate.

Bootstrapped on x86_64-linux and ppc64-linux, ok for trunk?

2016-09-27  Marek Polacek  <polacek@redhat.com>

	* Makefile.in (insn-attrtab.o-warn, insn-dfatab.o-warn,
	insn-latencytab.o-warn, insn-output.o-warn, insn-emit.o-warn): Use
	@W_NO_IMPLICIT_FALLTHROUGH@ instead of -Wno-error.
	* configure.ac: Add check for -Wimplicit-fallthrough.
	* configure: Regenerate.

diff --git a/gcc/Makefile.in b/gcc/Makefile.in
index ff12908..5871a47 100644
--- a/gcc/Makefile.in
+++ b/gcc/Makefile.in
@@ -218,11 +218,11 @@ libgcov-merge-tool.o-warn = -Wno-error
 gimple-match.o-warn = -Wno-unused
 generic-match.o-warn = -Wno-unused
 dfp.o-warn = -Wno-strict-aliasing
-insn-attrtab.o-warn = -Wno-error
-insn-dfatab.o-warn = -Wno-error
-insn-latencytab.o-warn = -Wno-error
-insn-output.o-warn = -Wno-error
-insn-emit.o-warn = -Wno-error
+insn-attrtab.o-warn = @W_NO_IMPLICIT_FALLTHROUGH@
+insn-dfatab.o-warn = @W_NO_IMPLICIT_FALLTHROUGH@
+insn-latencytab.o-warn = @W_NO_IMPLICIT_FALLTHROUGH@
+insn-output.o-warn = @W_NO_IMPLICIT_FALLTHROUGH@
+insn-emit.o-warn = @W_NO_IMPLICIT_FALLTHROUGH@
 
 # All warnings have to be shut off in stage1 if the compiler used then
 # isn't gcc; configure determines that.  WARN_CFLAGS will be either
diff --git a/gcc/configure b/gcc/configure
index 96eba9e..459f513 100755
--- a/gcc/configure
+++ b/gcc/configure
@@ -789,6 +789,7 @@ valgrind_path
 TREECHECKING
 nocommon_flag
 noexception_flags
+W_NO_IMPLICIT_FALLTHROUGH
 warn_cxxflags
 warn_cflags
 c_strict_warn
@@ -7006,6 +7007,34 @@ fi
 
 
 
+# Check whether -Wimplicit-fallthrough works.
+W_NO_IMPLICIT_FALLTHROUGH=
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for -Wimplicit-fallthrough option" >&5
+$as_echo_n "checking for -Wimplicit-fallthrough option... " >&6; }
+if test "${gcc_cv_implicit_fallthrough+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  saved_CXXFLAGS="$CXXFLAGS"
+   CXXFLAGS="$CXXFLAGS -Wimplicit-fallthrough"
+   cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+int main(void) {return 0;}
+_ACEOF
+if ac_fn_cxx_try_compile "$LINENO"; then :
+  gcc_cv_implicit_fallthrough=yes
+else
+  gcc_cv_implicit_fallthrough=no
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+   CXXFLAGS="$saved_CXXFLAGS"
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $gcc_cv_implicit_fallthrough" >&5
+$as_echo "$gcc_cv_implicit_fallthrough" >&6; }
+if test "$gcc_cv_implicit_fallthrough" = "yes"; then
+  W_NO_IMPLICIT_FALLTHROUGH="-Wno-implicit-fallthrough"
+fi
+
+
 # Disable exceptions and RTTI if building with g++
 ac_ext=c
 ac_cpp='$CPP $CPPFLAGS'
@@ -18476,7 +18505,7 @@ else
   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
   lt_status=$lt_dlunknown
   cat > conftest.$ac_ext <<_LT_EOF
-#line 18479 "configure"
+#line 18508 "configure"
 #include "confdefs.h"
 
 #if HAVE_DLFCN_H
@@ -18582,7 +18611,7 @@ else
   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
   lt_status=$lt_dlunknown
   cat > conftest.$ac_ext <<_LT_EOF
-#line 18585 "configure"
+#line 18614 "configure"
 #include "confdefs.h"
 
 #if HAVE_DLFCN_H
diff --git a/gcc/configure.ac b/gcc/configure.ac
index 534f22e..b72e52a 100644
--- a/gcc/configure.ac
+++ b/gcc/configure.ac
@@ -503,6 +503,21 @@ fi
 AC_SUBST(warn_cflags)
 AC_SUBST(warn_cxxflags)
 
+# Check whether -Wimplicit-fallthrough works.
+W_NO_IMPLICIT_FALLTHROUGH=
+AC_CACHE_CHECK([for -Wimplicit-fallthrough option],
+  [gcc_cv_implicit_fallthrough],
+  [saved_CXXFLAGS="$CXXFLAGS"
+   CXXFLAGS="$CXXFLAGS -Wimplicit-fallthrough"
+   AC_COMPILE_IFELSE([int main(void) {return 0;}],
+     [gcc_cv_implicit_fallthrough=yes],
+     [gcc_cv_implicit_fallthrough=no])
+   CXXFLAGS="$saved_CXXFLAGS"])
+if test "$gcc_cv_implicit_fallthrough" = "yes"; then
+  W_NO_IMPLICIT_FALLTHROUGH="-Wno-implicit-fallthrough"
+fi
+AC_SUBST([W_NO_IMPLICIT_FALLTHROUGH])
+
 # Disable exceptions and RTTI if building with g++
 ACX_PROG_CC_WARNING_OPTS(
 	m4_quote(m4_do([-fno-exceptions -fno-rtti -fasynchronous-unwind-tables])),

	Marek

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Add configure check for -Wimplicit-fallthrough
  2016-09-27 13:09 Add configure check for -Wimplicit-fallthrough Marek Polacek
@ 2016-09-27 13:13 ` Richard Biener
  2016-09-27 13:21   ` Jakub Jelinek
  2016-09-27 13:14 ` Jakub Jelinek
  1 sibling, 1 reply; 6+ messages in thread
From: Richard Biener @ 2016-09-27 13:13 UTC (permalink / raw)
  To: Marek Polacek; +Cc: GCC Patches, Jakub Jelinek

On Tue, Sep 27, 2016 at 3:05 PM, Marek Polacek <polacek@redhat.com> wrote:
> Using -Wno-error where only -Wno-implicit-fallthrough was meant was deemed
> to coarse, so this patch attempts to add a configure check for this warnign
> and only use -Wno-implicit-fallthrough when appropriate.
>
> Bootstrapped on x86_64-linux and ppc64-linux, ok for trunk?

It looks to me this would hide eventual bugs in .md files by not
issueing the warning?

Richard.

> 2016-09-27  Marek Polacek  <polacek@redhat.com>
>
>         * Makefile.in (insn-attrtab.o-warn, insn-dfatab.o-warn,
>         insn-latencytab.o-warn, insn-output.o-warn, insn-emit.o-warn): Use
>         @W_NO_IMPLICIT_FALLTHROUGH@ instead of -Wno-error.
>         * configure.ac: Add check for -Wimplicit-fallthrough.
>         * configure: Regenerate.
>
> diff --git a/gcc/Makefile.in b/gcc/Makefile.in
> index ff12908..5871a47 100644
> --- a/gcc/Makefile.in
> +++ b/gcc/Makefile.in
> @@ -218,11 +218,11 @@ libgcov-merge-tool.o-warn = -Wno-error
>  gimple-match.o-warn = -Wno-unused
>  generic-match.o-warn = -Wno-unused
>  dfp.o-warn = -Wno-strict-aliasing
> -insn-attrtab.o-warn = -Wno-error
> -insn-dfatab.o-warn = -Wno-error
> -insn-latencytab.o-warn = -Wno-error
> -insn-output.o-warn = -Wno-error
> -insn-emit.o-warn = -Wno-error
> +insn-attrtab.o-warn = @W_NO_IMPLICIT_FALLTHROUGH@
> +insn-dfatab.o-warn = @W_NO_IMPLICIT_FALLTHROUGH@
> +insn-latencytab.o-warn = @W_NO_IMPLICIT_FALLTHROUGH@
> +insn-output.o-warn = @W_NO_IMPLICIT_FALLTHROUGH@
> +insn-emit.o-warn = @W_NO_IMPLICIT_FALLTHROUGH@
>
>  # All warnings have to be shut off in stage1 if the compiler used then
>  # isn't gcc; configure determines that.  WARN_CFLAGS will be either
> diff --git a/gcc/configure b/gcc/configure
> index 96eba9e..459f513 100755
> --- a/gcc/configure
> +++ b/gcc/configure
> @@ -789,6 +789,7 @@ valgrind_path
>  TREECHECKING
>  nocommon_flag
>  noexception_flags
> +W_NO_IMPLICIT_FALLTHROUGH
>  warn_cxxflags
>  warn_cflags
>  c_strict_warn
> @@ -7006,6 +7007,34 @@ fi
>
>
>
> +# Check whether -Wimplicit-fallthrough works.
> +W_NO_IMPLICIT_FALLTHROUGH=
> +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for -Wimplicit-fallthrough option" >&5
> +$as_echo_n "checking for -Wimplicit-fallthrough option... " >&6; }
> +if test "${gcc_cv_implicit_fallthrough+set}" = set; then :
> +  $as_echo_n "(cached) " >&6
> +else
> +  saved_CXXFLAGS="$CXXFLAGS"
> +   CXXFLAGS="$CXXFLAGS -Wimplicit-fallthrough"
> +   cat confdefs.h - <<_ACEOF >conftest.$ac_ext
> +/* end confdefs.h.  */
> +int main(void) {return 0;}
> +_ACEOF
> +if ac_fn_cxx_try_compile "$LINENO"; then :
> +  gcc_cv_implicit_fallthrough=yes
> +else
> +  gcc_cv_implicit_fallthrough=no
> +fi
> +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
> +   CXXFLAGS="$saved_CXXFLAGS"
> +fi
> +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $gcc_cv_implicit_fallthrough" >&5
> +$as_echo "$gcc_cv_implicit_fallthrough" >&6; }
> +if test "$gcc_cv_implicit_fallthrough" = "yes"; then
> +  W_NO_IMPLICIT_FALLTHROUGH="-Wno-implicit-fallthrough"
> +fi
> +
> +
>  # Disable exceptions and RTTI if building with g++
>  ac_ext=c
>  ac_cpp='$CPP $CPPFLAGS'
> @@ -18476,7 +18505,7 @@ else
>    lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
>    lt_status=$lt_dlunknown
>    cat > conftest.$ac_ext <<_LT_EOF
> -#line 18479 "configure"
> +#line 18508 "configure"
>  #include "confdefs.h"
>
>  #if HAVE_DLFCN_H
> @@ -18582,7 +18611,7 @@ else
>    lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
>    lt_status=$lt_dlunknown
>    cat > conftest.$ac_ext <<_LT_EOF
> -#line 18585 "configure"
> +#line 18614 "configure"
>  #include "confdefs.h"
>
>  #if HAVE_DLFCN_H
> diff --git a/gcc/configure.ac b/gcc/configure.ac
> index 534f22e..b72e52a 100644
> --- a/gcc/configure.ac
> +++ b/gcc/configure.ac
> @@ -503,6 +503,21 @@ fi
>  AC_SUBST(warn_cflags)
>  AC_SUBST(warn_cxxflags)
>
> +# Check whether -Wimplicit-fallthrough works.
> +W_NO_IMPLICIT_FALLTHROUGH=
> +AC_CACHE_CHECK([for -Wimplicit-fallthrough option],
> +  [gcc_cv_implicit_fallthrough],
> +  [saved_CXXFLAGS="$CXXFLAGS"
> +   CXXFLAGS="$CXXFLAGS -Wimplicit-fallthrough"
> +   AC_COMPILE_IFELSE([int main(void) {return 0;}],
> +     [gcc_cv_implicit_fallthrough=yes],
> +     [gcc_cv_implicit_fallthrough=no])
> +   CXXFLAGS="$saved_CXXFLAGS"])
> +if test "$gcc_cv_implicit_fallthrough" = "yes"; then
> +  W_NO_IMPLICIT_FALLTHROUGH="-Wno-implicit-fallthrough"
> +fi
> +AC_SUBST([W_NO_IMPLICIT_FALLTHROUGH])
> +
>  # Disable exceptions and RTTI if building with g++
>  ACX_PROG_CC_WARNING_OPTS(
>         m4_quote(m4_do([-fno-exceptions -fno-rtti -fasynchronous-unwind-tables])),
>
>         Marek

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Add configure check for -Wimplicit-fallthrough
  2016-09-27 13:09 Add configure check for -Wimplicit-fallthrough Marek Polacek
  2016-09-27 13:13 ` Richard Biener
@ 2016-09-27 13:14 ` Jakub Jelinek
  1 sibling, 0 replies; 6+ messages in thread
From: Jakub Jelinek @ 2016-09-27 13:14 UTC (permalink / raw)
  To: Marek Polacek; +Cc: GCC Patches

On Tue, Sep 27, 2016 at 03:05:24PM +0200, Marek Polacek wrote:
> Using -Wno-error where only -Wno-implicit-fallthrough was meant was deemed
> to coarse, so this patch attempts to add a configure check for this warnign
> and only use -Wno-implicit-fallthrough when appropriate.
> 
> Bootstrapped on x86_64-linux and ppc64-linux, ok for trunk?
> 
> 2016-09-27  Marek Polacek  <polacek@redhat.com>
> 
> 	* Makefile.in (insn-attrtab.o-warn, insn-dfatab.o-warn,
> 	insn-latencytab.o-warn, insn-output.o-warn, insn-emit.o-warn): Use
> 	@W_NO_IMPLICIT_FALLTHROUGH@ instead of -Wno-error.
> 	* configure.ac: Add check for -Wimplicit-fallthrough.
> 	* configure: Regenerate.

Shouldn't this use ACX_PROG_CXX_WARNING_OPTS ?

	Jakub

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Add configure check for -Wimplicit-fallthrough
  2016-09-27 13:13 ` Richard Biener
@ 2016-09-27 13:21   ` Jakub Jelinek
  2016-09-27 13:30     ` Richard Biener
  0 siblings, 1 reply; 6+ messages in thread
From: Jakub Jelinek @ 2016-09-27 13:21 UTC (permalink / raw)
  To: Richard Biener; +Cc: Marek Polacek, GCC Patches

On Tue, Sep 27, 2016 at 03:09:36PM +0200, Richard Biener wrote:
> On Tue, Sep 27, 2016 at 3:05 PM, Marek Polacek <polacek@redhat.com> wrote:
> > Using -Wno-error where only -Wno-implicit-fallthrough was meant was deemed
> > to coarse, so this patch attempts to add a configure check for this warnign
> > and only use -Wno-implicit-fallthrough when appropriate.
> >
> > Bootstrapped on x86_64-linux and ppc64-linux, ok for trunk?
> 
> It looks to me this would hide eventual bugs in .md files by not
> issueing the warning?

Guess it depends on what kind of warnings we want to suppress here, if it is
something user can control in their *.md files, or something that perhaps
changes to the generators could handle (add /* FALLTHRU */ comments or
gcc_fallthrough (); in some cases)?

> > 2016-09-27  Marek Polacek  <polacek@redhat.com>
> >
> >         * Makefile.in (insn-attrtab.o-warn, insn-dfatab.o-warn,
> >         insn-latencytab.o-warn, insn-output.o-warn, insn-emit.o-warn): Use
> >         @W_NO_IMPLICIT_FALLTHROUGH@ instead of -Wno-error.
> >         * configure.ac: Add check for -Wimplicit-fallthrough.
> >         * configure: Regenerate.

	Jakub

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Add configure check for -Wimplicit-fallthrough
  2016-09-27 13:21   ` Jakub Jelinek
@ 2016-09-27 13:30     ` Richard Biener
  2016-09-27 17:29       ` Marek Polacek
  0 siblings, 1 reply; 6+ messages in thread
From: Richard Biener @ 2016-09-27 13:30 UTC (permalink / raw)
  To: Jakub Jelinek; +Cc: Marek Polacek, GCC Patches

On Tue, Sep 27, 2016 at 3:13 PM, Jakub Jelinek <jakub@redhat.com> wrote:
> On Tue, Sep 27, 2016 at 03:09:36PM +0200, Richard Biener wrote:
>> On Tue, Sep 27, 2016 at 3:05 PM, Marek Polacek <polacek@redhat.com> wrote:
>> > Using -Wno-error where only -Wno-implicit-fallthrough was meant was deemed
>> > to coarse, so this patch attempts to add a configure check for this warnign
>> > and only use -Wno-implicit-fallthrough when appropriate.
>> >
>> > Bootstrapped on x86_64-linux and ppc64-linux, ok for trunk?
>>
>> It looks to me this would hide eventual bugs in .md files by not
>> issueing the warning?
>
> Guess it depends on what kind of warnings we want to suppress here, if it is
> something user can control in their *.md files, or something that perhaps
> changes to the generators could handle (add /* FALLTHRU */ comments or
> gcc_fallthrough (); in some cases)?

I just looked at one random one and it was sse.md (repeatedly doing)

    case MODE_V16SF:
      gcc_assert (TARGET_AVX512F);
    case MODE_V8SF:
      gcc_assert (TARGET_AVX);
    case MODE_V4SF:
      gcc_assert (TARGET_SSE);
...

Richard.

>> > 2016-09-27  Marek Polacek  <polacek@redhat.com>
>> >
>> >         * Makefile.in (insn-attrtab.o-warn, insn-dfatab.o-warn,
>> >         insn-latencytab.o-warn, insn-output.o-warn, insn-emit.o-warn): Use
>> >         @W_NO_IMPLICIT_FALLTHROUGH@ instead of -Wno-error.
>> >         * configure.ac: Add check for -Wimplicit-fallthrough.
>> >         * configure: Regenerate.
>
>         Jakub

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Add configure check for -Wimplicit-fallthrough
  2016-09-27 13:30     ` Richard Biener
@ 2016-09-27 17:29       ` Marek Polacek
  0 siblings, 0 replies; 6+ messages in thread
From: Marek Polacek @ 2016-09-27 17:29 UTC (permalink / raw)
  To: Richard Biener; +Cc: Jakub Jelinek, GCC Patches

On Tue, Sep 27, 2016 at 03:23:52PM +0200, Richard Biener wrote:
> On Tue, Sep 27, 2016 at 3:13 PM, Jakub Jelinek <jakub@redhat.com> wrote:
> > On Tue, Sep 27, 2016 at 03:09:36PM +0200, Richard Biener wrote:
> >> On Tue, Sep 27, 2016 at 3:05 PM, Marek Polacek <polacek@redhat.com> wrote:
> >> > Using -Wno-error where only -Wno-implicit-fallthrough was meant was deemed
> >> > to coarse, so this patch attempts to add a configure check for this warnign
> >> > and only use -Wno-implicit-fallthrough when appropriate.
> >> >
> >> > Bootstrapped on x86_64-linux and ppc64-linux, ok for trunk?
> >>
> >> It looks to me this would hide eventual bugs in .md files by not
> >> issueing the warning?
> >
> > Guess it depends on what kind of warnings we want to suppress here, if it is
> > something user can control in their *.md files, or something that perhaps
> > changes to the generators could handle (add /* FALLTHRU */ comments or
> > gcc_fallthrough (); in some cases)?
> 
> I just looked at one random one and it was sse.md (repeatedly doing)
> 
>     case MODE_V16SF:
>       gcc_assert (TARGET_AVX512F);
>     case MODE_V8SF:
>       gcc_assert (TARGET_AVX);
>     case MODE_V4SF:
>       gcc_assert (TARGET_SSE);
> ...

These were the easy cases.  Now that I investigated more, I think the rest
can be fixed by making genattrtab.c emit the /* FALLTHRU */ comments.  See
<https://gcc.gnu.org/ml/gcc-patches/2016-09/msg02024.html> -- so I think we
might not need this configure check at all in the end.

	Marek

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2016-09-27 16:49 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-09-27 13:09 Add configure check for -Wimplicit-fallthrough Marek Polacek
2016-09-27 13:13 ` Richard Biener
2016-09-27 13:21   ` Jakub Jelinek
2016-09-27 13:30     ` Richard Biener
2016-09-27 17:29       ` Marek Polacek
2016-09-27 13:14 ` Jakub Jelinek

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).