On Fri, Sep 30, 2016 at 10:05:57PM +0200, Jakub Jelinek wrote:
> On Fri, Sep 30, 2016 at 11:26:27AM +0200, Marek Polacek wrote:
> > I haven't gone over the patch in detail yet, but I wonder if we should
> > also accept /* Else, fall through.  */ (to be found e.g. in 
> > aarch64-simd.md).
> 
> Here is the patch split into a series of 3 patches (the later patches depend
> on the earlier ones):
> 1) the first patch fixes some bugs and fixes also -Wimplicit-fallthrough -C
> 2) the second patch adds the else and intentional/ly etc.
> 3) the third one adds the optional comma between else and fall
> 
> Bootstrapped/regtested on x86_64-linux and i686-linux, ok?
> 
>       Jakub

> 2016-09-30  Jakub Jelinek  <ja...@redhat.com>
> 
>       * c-lex.c (c_lex_with_flags) <case CPP_COMMENT>: For CPP_COMMENT
>       token with PREV_FALLTHROUGH, skip all following CPP_PADDING and
>       CPP_COMMENT tokens and set add_flags to PREV_FALLTHROUGH afterwards.
> 
>       * doc/invoke.texi (-Wimplicit-fallthrough): Document the accepted
>       FALLTHRU comment styles.
> 
>       * lex.c (fallthrough_comment_p): Fix off-by-one size comparison
>       errors, cleanup.
>       (_cpp_lex_direct): Allow arbitrary comments in between
>       fallthrough_comment_p comment and following token.
> 
>       * c-c++-common/Wimplicit-fallthrough-22.c: New test.
>       * c-c++-common/Wimplicit-fallthrough-23.c: New test.
> 
> --- gcc/c-family/c-lex.c.jj   2016-09-30 18:16:26.303336781 +0200
> +++ gcc/c-family/c-lex.c      2016-09-30 18:26:14.650999215 +0200
> @@ -598,7 +598,18 @@ c_lex_with_flags (tree *value, location_
>  
>      /* CPP_COMMENT will appear when compiling with -C and should be
>         ignored.  */
> -     case CPP_COMMENT:
> +    case CPP_COMMENT:
> +      if (tok->flags & PREV_FALLTHROUGH)
> +     {
> +       do
> +         {
> +           tok = cpp_get_token_with_location (parse_in, loc);
> +           type = tok->type;
> +         }
> +       while (type == CPP_PADDING || type == CPP_COMMENT);
> +       add_flags = PREV_FALLTHROUGH;

Wouldn't |= be safer?

> +       goto retry_after_at;
> +     }

And the comment is not really true anymore; I think let's say that we
want to set PREV_FALLTHROUGH on the token following the comment.

Otherwise I'm ok with the first patch, just please rename the 
-22 test to -24, since I've added -22.c and -23.c.

        Marek

Reply via email to