[PATCH] Fix fallthrough attribute ignorance w/ -fsanitize=address (PR sanitizer/82792).

Marek Polacek polacek@redhat.com
Wed Nov 8 11:48:00 GMT 2017


On Wed, Nov 08, 2017 at 12:17:29PM +0100, Martin Liška wrote:
> On 11/08/2017 09:37 AM, Marek Polacek wrote:
> > On Wed, Nov 08, 2017 at 08:07:42AM +0100, Martin Liška wrote:
> >> diff --git a/gcc/gimplify.c b/gcc/gimplify.c
> >> index c4fd5038d92..9563d825a6a 100644
> >> --- a/gcc/gimplify.c
> >> +++ b/gcc/gimplify.c
> >> @@ -2223,7 +2223,8 @@ expand_FALLTHROUGH_r (gimple_stmt_iterator *gsi_p, bool *handled_ops_p,
> >>  	  while (!gsi_end_p (gsi2))
> >>  	    {
> >>  	      stmt = gsi_stmt (gsi2);
> >> -	      if (gimple_code (stmt) == GIMPLE_LABEL)
> >> +	      enum gimple_code gc = gimple_code (stmt);
> >> +	      if (gc == GIMPLE_LABEL)
> >>  		{
> >>  		  tree label = gimple_label_label (as_a <glabel *> (stmt));
> >>  		  if (gimple_has_location (stmt) && DECL_ARTIFICIAL (label))
> >> @@ -2232,8 +2233,11 @@ expand_FALLTHROUGH_r (gimple_stmt_iterator *gsi_p, bool *handled_ops_p,
> >>  		      break;
> >>  		    }
> >>  		}
> >> +	      else if (gc == GIMPLE_CALL
> >> +		       && gimple_call_internal_p (stmt, IFN_ASAN_MARK))
> >> +		;
> > 
> > I thought you could simply use gimple_call_internal_p (stmt, IFN_ASAN_MARK)
> > here.
> 
> Hi Marek.
> 
> You're right! Are you fine with attached patch?

Yes.

> > And shouldn't this use -Wextra or -Wimplicit-fallthrough to check whether
> > the warning is really gone?
> 
> I don't think so:
> 
> /home/marxin/Programming/gcc/gcc/testsuite/g++.dg/asan/pr82792.C: In function ‘int test(int, int)’:
> /home/marxin/Programming/gcc/gcc/testsuite/g++.dg/asan/pr82792.C:25:7: warning: attribute ‘fallthrough’ not preceding a case label or default label
>        __attribute ((fallthrough));
>        ^~~~~~~~~~~

Oh, I see now.

	Marek



More information about the Gcc-patches mailing list