-
- Downloads
Make more bad uses of fallthrough attribute into pedwarns.
Various bad uses of the [[fallthrough]] attribute are constraint violations in C2x, so need pedwarns rather than warnings. This patch duly turns the relevant warnings into pedwarns. The relevant code is not specific to C, and does not know which form the attribute was given in ([[fallthrough]] or [[gnu::fallthrough]] or __attribute__((fallthrough))), but as I understand it these usages are also erroneous for C++ and it seems reasonable to give a pedwarn here even when a form other than [[fallthrough]] is being used. The precise meaning of the standard wording about "The next statement that would be executed" seems a but unclear in some corner cases; the tests added keep to cases where it is clear whether or not the next statement executed is of the required form. Bootstrapped with no regressions for x86_64-pc-linux-gnu. gcc: * gimplify.c (expand_FALLTHROUGH_r, expand_FALLTHROUGH): Use pedwarn instead of warning_at for fallthrough not preceding a case or default label. gcc/c-family: * c-attribs.c (handle_fallthrough_attribute): Use pedwarn instead of warning. gcc/testsuite: * gcc.dg/c2x-attr-fallthrough-6.c: New test. Split out from c2x-attr-fallthrough-3.c. * gcc.dg/c2x-attr-fallthrough-1.c: Add more tests. * gcc.dg/c2x-attr-fallthrough-2.c: Update expected diagnostics. * gcc.dg/c2x-attr-fallthrough-3.c: Split inside-switch part of test out to c2x-attr-fallthrough-6.c. From-SVN: r278599
Showing
- gcc/ChangeLog 6 additions, 0 deletionsgcc/ChangeLog
- gcc/c-family/ChangeLog 5 additions, 0 deletionsgcc/c-family/ChangeLog
- gcc/c-family/c-attribs.c 1 addition, 1 deletiongcc/c-family/c-attribs.c
- gcc/gimplify.c 4 additions, 4 deletionsgcc/gimplify.c
- gcc/testsuite/ChangeLog 9 additions, 0 deletionsgcc/testsuite/ChangeLog
- gcc/testsuite/gcc.dg/c2x-attr-fallthrough-1.c 16 additions, 1 deletiongcc/testsuite/gcc.dg/c2x-attr-fallthrough-1.c
- gcc/testsuite/gcc.dg/c2x-attr-fallthrough-2.c 2 additions, 1 deletiongcc/testsuite/gcc.dg/c2x-attr-fallthrough-2.c
- gcc/testsuite/gcc.dg/c2x-attr-fallthrough-3.c 1 addition, 8 deletionsgcc/testsuite/gcc.dg/c2x-attr-fallthrough-3.c
- gcc/testsuite/gcc.dg/c2x-attr-fallthrough-6.c 18 additions, 0 deletionsgcc/testsuite/gcc.dg/c2x-attr-fallthrough-6.c
Loading
Please register or sign in to comment