aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJakub Jelinek <jakub@redhat.com>2016-10-08 12:54:27 +0200
committerJakub Jelinek <jakub@gcc.gnu.org>2016-10-08 12:54:27 +0200
commitee19ef45ba9dc5a783303e353d538e83dabe3377 (patch)
tree2bb03fc407441f31957cbe3fcb1f2eeb60783246
parent81b02905b035e7afee46c38186c95434b6d86813 (diff)
downloadgcc-ee19ef45ba9dc5a783303e353d538e83dabe3377.zip
gcc-ee19ef45ba9dc5a783303e353d538e83dabe3377.tar.gz
gcc-ee19ef45ba9dc5a783303e353d538e83dabe3377.tar.bz2
invoke.texi: Document accepting Else, fallthrough.
* 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. From-SVN: r240886
-rw-r--r--gcc/ChangeLog2
-rw-r--r--gcc/doc/invoke.texi6
-rw-r--r--gcc/testsuite/ChangeLog2
-rw-r--r--gcc/testsuite/c-c++-common/Wimplicit-fallthrough-23.c12
-rw-r--r--libcpp/ChangeLog2
-rw-r--r--libcpp/lex.c19
6 files changed, 34 insertions, 9 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index f547a7b..fa748f3 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,5 +1,7 @@
2016-10-08 Jakub Jelinek <jakub@redhat.com>
+ * doc/invoke.texi: Document accepting Else, fallthrough.
+
* doc/invoke.texi (-Wimplicit-fallthrough): Document FALLTHRU comment
style changes.
diff --git a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi
index 65805ba..8d8fdee 100644
--- a/gcc/doc/invoke.texi
+++ b/gcc/doc/invoke.texi
@@ -4181,11 +4181,11 @@ should match one of the following regular expressions:
@item @code{lint -fallthrough ?}
-@item @code{[ \t.!]*(ELSE |INTENTIONAL(LY)? )?FALL(S | |-)?THR(OUGH|U)[ \t.!]*(-[^\n\r]*)?}
+@item @code{[ \t.!]*(ELSE,? |INTENTIONAL(LY)? )?FALL(S | |-)?THR(OUGH|U)[ \t.!]*(-[^\n\r]*)?}
-@item @code{[ \t.!]*(Else |Intentional(ly)? )?Fall((s | |-)[Tt]|t)hr(ough|u)[ \t.!]*(-[^\n\r]*)?}
+@item @code{[ \t.!]*(Else,? |Intentional(ly)? )?Fall((s | |-)[Tt]|t)hr(ough|u)[ \t.!]*(-[^\n\r]*)?}
-@item @code{[ \t.!]*([Ee]lse |[Ii]ntentional(ly)? )?fall(s | |-)?thr(ough|u)[ \t.!]*(-[^\n\r]*)?}
+@item @code{[ \t.!]*([Ee]lse,? |[Ii]ntentional(ly)? )?fall(s | |-)?thr(ough|u)[ \t.!]*(-[^\n\r]*)?}
@end itemize
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 12b9009..9422a47 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -2,6 +2,8 @@
* c-c++-common/Wimplicit-fallthrough-23.c (foo): Add further tests.
+ * c-c++-common/Wimplicit-fallthrough-23.c (foo): Add further tests.
+
* c-c++-common/Wimplicit-fallthrough-23.c: New test.
* c-c++-common/Wimplicit-fallthrough-24.c: New test.
diff --git a/gcc/testsuite/c-c++-common/Wimplicit-fallthrough-23.c b/gcc/testsuite/c-c++-common/Wimplicit-fallthrough-23.c
index c2988b7..01a4388 100644
--- a/gcc/testsuite/c-c++-common/Wimplicit-fallthrough-23.c
+++ b/gcc/testsuite/c-c++-common/Wimplicit-fallthrough-23.c
@@ -114,6 +114,12 @@ foo (int i)
case 34:
bar (34);
break;
+ case 35:
+ bar (35); /* { dg-bogus "this statement may \[laf]* through" } */
+ /* Else, fall-through. */
+ case 36:
+ bar (36);
+ break;
default:
break;
}
@@ -225,6 +231,12 @@ foo (int i)
case 34:
bar (34);
break;
+ case 35:
+ bar (35); /* { dg-bogus "this statement may \[laf]* through" } */
+ // Else, fall-through
+ case 36:
+ bar (36);
+ break;
default:
break;
}
diff --git a/libcpp/ChangeLog b/libcpp/ChangeLog
index 6e48566..1f4db49 100644
--- a/libcpp/ChangeLog
+++ b/libcpp/ChangeLog
@@ -1,5 +1,7 @@
2016-10-08 Jakub Jelinek <jakub@redhat.com>
+ * lex.c (fallthrough_comment_p): Accept Else, fallthrough.
+
* lex.c (fallthrough_comment_p): Extend to handle more common FALLTHRU
comment styles.
diff --git a/libcpp/lex.c b/libcpp/lex.c
index 2e0512d..4d8e5e7 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;