]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
* doc/invoke.texi: Document accepting Else, fallthrough.
authorjakub <jakub@138bc75d-0d04-0410-961f-82ee72b054a4>
Sat, 8 Oct 2016 10:54:27 +0000 (10:54 +0000)
committerjakub <jakub@138bc75d-0d04-0410-961f-82ee72b054a4>
Sat, 8 Oct 2016 10:54:27 +0000 (10:54 +0000)
* 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

gcc/ChangeLog
gcc/doc/invoke.texi
gcc/testsuite/ChangeLog
gcc/testsuite/c-c++-common/Wimplicit-fallthrough-23.c
libcpp/ChangeLog
libcpp/lex.c

index f547a7b8da6e4ff933e5341100e23bd7e70fab30..fa748f35aa56495b6cfb055241fc5dc047a85122 100644 (file)
@@ -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.
 
index 65805babb30e69ad416aad7c60daa156ed3537d3..8d8fdeedcf3c10af4997ecb3f95c430264a8b454 100644 (file)
@@ -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
 
index 12b90093a98a6437fa41e8872e65a5bca892ed55..9422a47dd0978cc9c9afbcc07cc7c11551ae53d9 100644 (file)
@@ -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.
 
index c2988b716db5b0d99cd0117f48f55ae9a15dd5ec..01a43883acc4b00340e44a8de7f50a5401c4bc02 100644 (file)
@@ -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;
     }
index 6e48566878e6c3e8e66de640cc141544a4f21ce3..1f4db497dd13b2bd3398a7539875c66506c85573 100644 (file)
@@ -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.
 
index 2e0512d6428e8391cd3bb57b57a2dee56acdb066..4d8e5e703269e5e1340010c292cfab2169225956 100644 (file)
@@ -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;