PATCH to fix bogus -Wimplicit-fallthrough warning (PR c++/77803)

Markus Trippelsdorf markus@trippelsdorf.de
Sat Oct 1 05:18:00 GMT 2016


On 2016.09.30 at 23:31 +0200, Marek Polacek wrote:
> This PR reports a bogus -Wimplicit-fallthrough warning on the attached test.
> The problem is that last_stmt_in_scope should for GIMPLE_TRY, if the last
> statement of the eval part can't fallthrough, return this statement and don't
> warn.  And the same should be true for FALLTHROUGH ().   This patch fixes it.
> 
> Bootstrapped/regtested on x86_64-linux, ok for trunk?

Try to compile the testcase without the fallthrough attribute...

> diff --git gcc/testsuite/g++.dg/warn/Wimplicit-fallthrough-1.C gcc/testsuite/g++.dg/warn/Wimplicit-fallthrough-1.C
> index e69de29..8f80b01 100644
> --- gcc/testsuite/g++.dg/warn/Wimplicit-fallthrough-1.C
> +++ gcc/testsuite/g++.dg/warn/Wimplicit-fallthrough-1.C
> @@ -0,0 +1,16 @@
> +// PR c++/77803
> +// { dg-do compile { target c++11 } }
> +// { dg-options "-Wimplicit-fallthrough" }
> +
> +struct A {};
> +int a;
> +void fn1() {
> +  switch (0) {
> +  case 0: {
> +    A b;
> +    [[fallthrough]];
> +  }
> +  default:
> +    a = 0;
> +  }
> +}
> 
> 	Marek
> 

-- 
Markus



More information about the Gcc-patches mailing list