From 4582d852a48283a1f0813a2c0ac444901fb741aa Mon Sep 17 00:00:00 2001 From: jakub Date: Sat, 8 Oct 2016 10:54:27 +0000 Subject: * doc/invoke.texi: Document accepting Else, fallthrough. * lex.c (fallthrough_comment_p): Accept Else, fallthrough. * c-c++-common/Wimplicit-fallthrough-23.c (foo): Add further tests. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@240886 138bc75d-0d04-0410-961f-82ee72b054a4 --- libcpp/lex.c | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) (limited to 'libcpp/lex.c') diff --git a/libcpp/lex.c b/libcpp/lex.c index 2e0512d6428..4d8e5e70326 100644 --- a/libcpp/lex.c +++ b/libcpp/lex.c @@ -2074,9 +2074,9 @@ fallthrough_comment_p (cpp_reader *pfile, const unsigned char *comment_start) from++; } /* Whole comment contents (regex): - [ \t.!]*(ELSE |INTENTIONAL(LY)? )?FALL(S | |-)?THR(OUGH|U)[ \t.!]*(-[^\n\r]*)? - [ \t.!]*(Else |Intentional(ly)? )?Fall((s | |-)[Tt]|t)hr(ough|u)[ \t.!]*(-[^\n\r]*)? - [ \t.!]*([Ee]lse |[Ii]ntentional(ly)? )?fall(s | |-)?thr(ough|u)[ \t.!]*(-[^\n\r]*)? + [ \t.!]*(ELSE,? |INTENTIONAL(LY)? )?FALL(S | |-)?THR(OUGH|U)[ \t.!]*(-[^\n\r]*)? + [ \t.!]*(Else,? |Intentional(ly)? )?Fall((s | |-)[Tt]|t)hr(ough|u)[ \t.!]*(-[^\n\r]*)? + [ \t.!]*([Ee]lse,? |[Ii]ntentional(ly)? )?fall(s | |-)?thr(ough|u)[ \t.!]*(-[^\n\r]*)? */ else { @@ -2089,11 +2089,18 @@ fallthrough_comment_p (cpp_reader *pfile, const unsigned char *comment_start) if ((size_t) (pfile->buffer->cur - from) < sizeof "else fallthru" - 1) return false; - if (f == 'E' && memcmp (from + 1, "LSE F", sizeof "LSE F" - 1) == 0) + if (f == 'E' && memcmp (from + 1, "LSE", sizeof "LSE" - 1) == 0) all_upper = true; - else if (memcmp (from + 1, "lse ", sizeof "lse " - 1)) + else if (memcmp (from + 1, "lse", sizeof "lse" - 1)) + return false; + from += sizeof "else" - 1; + if (*from == ',') + from++; + if (*from != ' ') + return false; + from++; + if (all_upper && *from == 'f') return false; - from += sizeof "else " - 1; if (f == 'e' && *from == 'F') return false; f = *from; -- cgit v1.2.1