1 // RUN: %clang_cc1 -fsyntax-only -std=c2x -verify %s
3 // This is the latest version of fallthrough that we support.
4 _Static_assert(__has_c_attribute(fallthrough
) == 201910L);
10 [[fallthrough
]]; // ok
13 [[fallthrough
]]; // ok
18 for (int n
= 0; n
!= 10; ++n
)
19 [[fallthrough
]]; // expected-error {{does not directly precede switch label}}
22 [[fallthrough
]]; // expected-error {{does not directly precede switch label}}
25 [[fallthrough
]]; // expected-error {{does not directly precede switch label}}
27 do [[fallthrough
]]; while (1); // expected-error {{does not directly precede switch label}}
29 do [[fallthrough
]]; while (0); // expected-error {{does not directly precede switch label}}
33 // FIXME: This should be an error, even though the next thing we do is to
34 // fall through in an outer switch statement.
38 [[fallthrough
]]; // expected-error {{does not directly precede switch label}}
43 case 10: // no warning, -Wimplicit-fallthrough is not enabled in this test, and does not need to
44 // be enabled for these diagnostics to be produced.
49 [[fallthrough
]] typedef int n1
; // expected-error {{'fallthrough' attribute cannot be applied to a declaration}}
50 typedef int [[fallthrough
]] n2
; // expected-error {{'fallthrough' attribute cannot be applied to types}}
51 typedef int n3
[[fallthrough
]]; // expected-error {{'fallthrough' attribute cannot be applied to a declaration}}
53 enum [[fallthrough
]] E
{ // expected-error {{'fallthrough' attribute cannot be applied to a declaration}}
56 struct [[fallthrough
]] S
{ // expected-error {{'fallthrough' attribute cannot be applied to a declaration}}
60 [[fallthrough
]] // expected-error {{'fallthrough' attribute cannot be applied to a declaration}}
62 [[fallthrough
]] int n
; // expected-error {{'fallthrough' attribute cannot be applied to a declaration}}
63 [[fallthrough
]] ++n
; // expected-error {{'fallthrough' attribute only applies to empty statements}}
66 // FIXME: This should be an error.
71 [[fallthrough
, fallthrough
]]; // ok
73 [[fallthrough(0)]]; // expected-error {{argument list}}