case 4:
bar (4);
break;
+ case 5:
+ bar (5); /* { dg-bogus "this statement may \[laf]* through" } */
+ /* Else Fall-Thru! */
+ case 6:
+ bar (6);
+ break;
case 7:
bar (7); /* { dg-bogus "this statement may \[laf]* through" } */
/* Some comment. */
- /* fallthrough. */
+ /* ... fallthrough ... */
/* Some other comment. */
/* And yet another. */
case 8:
bar (8);
break;
+ case 9:
+ bar (9); /* { dg-bogus "this statement may \[laf]* through" } */
+ /* Intentional Fallthru */
+ case 10:
+ bar (10);
+ break;
+ case 11:
+ bar (11); /* { dg-bogus "this statement may \[laf]* through" } */
+ /* intentionally fall through */
+ case 12:
+ bar (12);
+ break;
+ case 13:
+ bar (13); /* { dg-bogus "this statement may \[laf]* through" } */
+ /* Falls Through - for reasons known only to the author. */
+ case 14:
+ bar (14);
+ break;
case 15:
bar (15); /* { dg-bogus "this statement may \[laf]* through" } */
/*-fallthrough*/
case 18:
bar (18);
break;
+ case 19:
+ bar (19); /* { dg-bogus "this statement may \[laf]* through" } */
+ /*lint -fallthrough*/
+ case 20:
+ bar (20);
+ break;
+ case 21:
+ bar (21); /* { dg-bogus "this statement may \[laf]* through" } */
+ /*lint -fallthrough */
+ case 22:
+ bar (22);
+ break;
case 23:
bar (23); /* { dg-bogus "this statement may \[laf]* through" } */
/*fallthru*/
case 24:
bar (24);
break;
+ case 25:
+ bar (25); /* { dg-bogus "this statement may \[laf]* through" } */
+ /*Else fallthru*/
+ case 26:
+ bar (26);
+ break;
+ case 27:
+ bar (27); /* { dg-bogus "this statement may \[laf]* through" } */
+ /*Intentional fallthru*/
+ case 28:
+ bar (28);
+ break;
+ case 29:
+ bar (29); /* { dg-bogus "this statement may \[laf]* through" } */
+ /*Intentionally fallthru*/
+ case 30:
+ bar (30);
+ break;
case 31:
bar (31); /* { dg-bogus "this statement may \[laf]* through" } */
/*Falls thru*/
case 4:
bar (4);
break;
+ case 5:
+ bar (5); /* { dg-bogus "this statement may \[laf]* through" } */
+ // Else Fall-Thru!
+ case 6:
+ bar (6);
+ break;
case 7:
bar (7); /* { dg-bogus "this statement may \[laf]* through" } */
// Some comment.
- // fallthrough
+ // ... fallthrough ...
// Some other comment.
// And yet another.
case 8:
bar (8);
break;
+ case 9:
+ bar (9); /* { dg-bogus "this statement may \[laf]* through" } */
+ // Intentional Fallthru
+ case 10:
+ bar (10);
+ break;
+ case 11:
+ bar (11); /* { dg-bogus "this statement may \[laf]* through" } */
+ // intentionally fall through
+ case 12:
+ bar (12);
+ break;
+ case 13:
+ bar (13); /* { dg-bogus "this statement may \[laf]* through" } */
+ // Falls Through - for reasons known only to the author.
+ case 14:
+ bar (14);
+ break;
case 15:
bar (15); /* { dg-bogus "this statement may \[laf]* through" } */
//-fallthrough
case 18:
bar (18);
break;
+ case 19:
+ bar (19); /* { dg-bogus "this statement may \[laf]* through" } */
+ //lint -fallthrough
+ case 20:
+ bar (20);
+ break;
+ case 21:
+ bar (21); /* { dg-bogus "this statement may \[laf]* through" } */
+ //lint -fallthrough
+ case 22:
+ bar (22);
+ break;
case 23:
bar (23); /* { dg-bogus "this statement may \[laf]* through" } */
//fallthru
case 24:
bar (24);
break;
+ case 25:
+ bar (25); /* { dg-bogus "this statement may \[laf]* through" } */
+ //Else fallthru
+ case 26:
+ bar (26);
+ break;
+ case 27:
+ bar (27); /* { dg-bogus "this statement may \[laf]* through" } */
+ //Intentional fallthru
+ case 28:
+ bar (28);
+ break;
+ case 29:
+ bar (29); /* { dg-bogus "this statement may \[laf]* through" } */
+ //Intentionally fallthru
+ case 30:
+ bar (30);
+ break;
case 31:
bar (31); /* { dg-bogus "this statement may \[laf]* through" } */
//Falls thru
from += 1 + len;
}
/* Whole comment contents (regex):
- [ \t]*FALL(S | |-)?THR(OUGH|U)\.?[ \t]*
- [ \t]*Fall((s | |-)[Tt]|t)hr(ough|u)\.?[ \t]*
- [ \t]*fall(s | |-)?thr(ough|u)\.?[ \t]*
+ lint -fallthrough ?
+ */
+ else if (*from == 'l')
+ {
+ size_t len = sizeof "int -fallthrough" - 1;
+ if ((size_t) (pfile->buffer->cur - from - 1) < len)
+ return false;
+ if (memcmp (from + 1, "int -fallthrough", len))
+ return false;
+ from += 1 + len;
+ if (*from == ' ')
+ 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]*)?
*/
else
{
- while (*from == ' ' || *from == '\t')
+ while (*from == ' ' || *from == '\t' || *from == '.' || *from == '!')
from++;
unsigned char f = *from;
+ bool all_upper = false;
+ if (f == 'E' || f == 'e')
+ {
+ 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)
+ all_upper = true;
+ else if (memcmp (from + 1, "lse ", sizeof "lse " - 1))
+ return false;
+ from += sizeof "else " - 1;
+ if (f == 'e' && *from == 'F')
+ return false;
+ f = *from;
+ }
+ else if (f == 'I' || f == 'i')
+ {
+ if ((size_t) (pfile->buffer->cur - from)
+ < sizeof "intentional fallthru" - 1)
+ return false;
+ if (f == 'I' && memcmp (from + 1, "NTENTIONAL",
+ sizeof "NTENTIONAL" - 1) == 0)
+ all_upper = true;
+ else if (memcmp (from + 1, "ntentional",
+ sizeof "ntentional" - 1))
+ return false;
+ from += sizeof "intentional" - 1;
+ if (*from == ' ')
+ {
+ from++;
+ if (all_upper && *from == 'f')
+ return false;
+ }
+ else if (all_upper)
+ {
+ if (memcmp (from, "LY F", sizeof "LY F" - 1))
+ return false;
+ from += sizeof "LY " - 1;
+ }
+ else
+ {
+ if (memcmp (from, "ly ", sizeof "ly " - 1))
+ return false;
+ from += sizeof "ly " - 1;
+ }
+ if (f == 'i' && *from == 'F')
+ return false;
+ f = *from;
+ }
if (f != 'F' && f != 'f')
return false;
if ((size_t) (pfile->buffer->cur - from) < sizeof "fallthru" - 1)
return false;
- bool all_upper = false;
if (f == 'F' && memcmp (from + 1, "ALL", sizeof "ALL" - 1) == 0)
all_upper = true;
+ else if (all_upper)
+ return false;
else if (memcmp (from + 1, "all", sizeof "all" - 1))
return false;
from += sizeof "fall" - 1;
}
else
from += sizeof "thru" - 1;
- if (*from == '.')
- from++;
- while (*from == ' ' || *from == '\t')
+ while (*from == ' ' || *from == '\t' || *from == '.' || *from == '!')
from++;
+ if (*from == '-')
+ {
+ from++;
+ if (*comment_start == '*')
+ {
+ do
+ {
+ while (*from && *from != '*'
+ && *from != '\n' && *from != '\r')
+ from++;
+ if (*from != '*' || from[1] == '/')
+ break;
+ from++;
+ }
+ while (1);
+ }
+ else
+ while (*from && *from != '\n' && *from != '\r')
+ from++;
+ }
}
/* C block comment. */
if (*comment_start == '*')