diff options
author | Jakub Jelinek <jakub@redhat.com> | 2016-10-08 12:48:54 +0200 |
---|---|---|
committer | Jakub Jelinek <jakub@gcc.gnu.org> | 2016-10-08 12:48:54 +0200 |
commit | 7bad794aa005aa3ee52fc9c872051d8346c09a24 (patch) | |
tree | dbcbde73147d32631dd626a01571e5964d9ff5fe /gcc/c-family | |
parent | 6dc29c6db124fab32ab9b69cfb283e078cc881fc (diff) | |
download | gcc-7bad794aa005aa3ee52fc9c872051d8346c09a24.zip gcc-7bad794aa005aa3ee52fc9c872051d8346c09a24.tar.gz gcc-7bad794aa005aa3ee52fc9c872051d8346c09a24.tar.bz2 |
c-lex.c (c_lex_with_flags): For CPP_COMMENT token with PREV_FALLTHROUGH...
* 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-23.c: New test.
* c-c++-common/Wimplicit-fallthrough-24.c: New test.
From-SVN: r240884
Diffstat (limited to 'gcc/c-family')
-rw-r--r-- | gcc/c-family/ChangeLog | 6 | ||||
-rw-r--r-- | gcc/c-family/c-lex.c | 18 |
2 files changed, 21 insertions, 3 deletions
diff --git a/gcc/c-family/ChangeLog b/gcc/c-family/ChangeLog index 52ba9b8..9f6b16d 100644 --- a/gcc/c-family/ChangeLog +++ b/gcc/c-family/ChangeLog @@ -1,3 +1,9 @@ +2016-10-08 Jakub Jelinek <jakub@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. + 2016-10-07 Jakub Jelinek <jakub@redhat.com> Implement LWG2296 helper intrinsic diff --git a/gcc/c-family/c-lex.c b/gcc/c-family/c-lex.c index 5c6496e..e3803b0 100644 --- a/gcc/c-family/c-lex.c +++ b/gcc/c-family/c-lex.c @@ -596,9 +596,21 @@ c_lex_with_flags (tree *value, location_t *loc, unsigned char *cpp_flags, case CPP_MACRO_ARG: gcc_unreachable (); - /* CPP_COMMENT will appear when compiling with -C and should be - ignored. */ - case CPP_COMMENT: + /* CPP_COMMENT will appear when compiling with -C. Ignore, except + when it is a FALLTHROUGH comment, in that case set + PREV_FALLTHROUGH flag on the next non-comment token. */ + 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; + goto retry_after_at; + } goto retry; default: |