Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / clang / test / Parser / c2x-attribute-keywords.c
blobd8291b710e6db644a0d0d4359fefeb7e20fd3003
1 // RUN: %clang_cc1 -fsyntax-only -triple aarch64-none-linux-gnu -target-feature +sme -verify=expected,notc2x -Wno-strict-prototypes %s
2 // RUN: %clang_cc1 -fsyntax-only -triple aarch64-none-linux-gnu -target-feature +sme -verify=expected,c2x %s
4 enum __arm_streaming E { // expected-error {{'__arm_streaming' only applies to non-K&R-style functions}}
5 One __arm_streaming, // expected-error {{'__arm_streaming' only applies to non-K&R-style functions}}
6 Two,
7 Three __arm_streaming // expected-error {{'__arm_streaming' only applies to non-K&R-style functions}}
8 };
10 enum __arm_streaming { Four }; // expected-error {{'__arm_streaming' only applies to non-K&R-style functions}}
11 __arm_streaming enum E2 { Five }; // expected-error {{misplaced '__arm_streaming'}}
13 // FIXME: this diagnostic can be improved.
14 enum { __arm_streaming Six }; // expected-error {{expected identifier}}
16 // FIXME: this diagnostic can be improved.
17 enum E3 __arm_streaming { Seven }; // expected-error {{expected identifier or '('}}
19 struct __arm_streaming S1 { // expected-error {{'__arm_streaming' only applies to non-K&R-style functions}}
20 int i __arm_streaming; // expected-error {{'__arm_streaming' only applies to function types}}
21 int __arm_streaming j; // expected-error {{'__arm_streaming' only applies to function types}}
22 int k[10] __arm_streaming; // expected-error {{'__arm_streaming' only applies to function types}}
23 int l __arm_streaming[10]; // expected-error {{'__arm_streaming' only applies to function types}}
24 __arm_streaming int m, n; // expected-error {{'__arm_streaming' only applies to function types}}
25 int o __arm_streaming : 12; // expected-error {{'__arm_streaming' only applies to function types}}
26 int __arm_streaming : 0; // expected-error {{'__arm_streaming' only applies to function types}}
27 int p, __arm_streaming : 0; // expected-error {{'__arm_streaming' cannot appear here}}
28 int q, __arm_streaming r; // expected-error {{'__arm_streaming' cannot appear here}}
29 __arm_streaming int; // expected-error {{'__arm_streaming' cannot appear here}} \
30 // expected-warning {{declaration does not declare anything}}
33 __arm_streaming struct S2 { int a; }; // expected-error {{misplaced '__arm_streaming'}}
34 struct S3 __arm_streaming { int a; }; // expected-error {{'__arm_streaming' cannot appear here}} \
35 expected-error {{'__arm_streaming' only applies to non-K&R-style functions}}
37 union __arm_streaming U { // expected-error {{'__arm_streaming' only applies to non-K&R-style functions}}
38 double d __arm_streaming; // expected-error {{'__arm_streaming' only applies to function types; type here is 'double'}}
39 __arm_streaming int i; // expected-error {{'__arm_streaming' only applies to function types; type here is 'int'}}
42 __arm_streaming union U2 { double d; }; // expected-error {{misplaced '__arm_streaming'}}
43 union U3 __arm_streaming { double d; }; // expected-error {{'__arm_streaming' cannot appear here}} \
44 expected-error {{'__arm_streaming' only applies to non-K&R-style functions}}
46 struct __arm_streaming IncompleteStruct; // expected-error {{'__arm_streaming' only applies to non-K&R-style functions}}
47 union __arm_streaming IncompleteUnion; // expected-error {{'__arm_streaming' only applies to non-K&R-style functions}}
48 enum __arm_streaming IncompleteEnum; // expected-error {{'__arm_streaming' only applies to non-K&R-style functions}}
50 __arm_streaming void f1(void); // expected-error {{'__arm_streaming' cannot be applied to a declaration}}
51 void __arm_streaming f2(void); // expected-error {{'__arm_streaming' only applies to function types}}
52 void f3 __arm_streaming (void); // expected-error {{'__arm_streaming' cannot be applied to a declaration}}
53 void f4(void) __arm_streaming;
55 void f5(int i __arm_streaming, __arm_streaming int j, int __arm_streaming k); // expected-error 3 {{'__arm_streaming' only applies to function types}}
57 void f6(a, b) __arm_streaming int a; int b; { // expected-error {{'__arm_streaming' cannot appear here}} \
58 c2x-warning {{deprecated}}
61 // FIXME: technically, an attribute list cannot appear here, but we currently
62 // parse it as part of the return type of the function, which is reasonable
63 // behavior given that we *don't* want to parse it as part of the K&R parameter
64 // declarations. It is disallowed to avoid a parsing ambiguity we already
65 // handle well.
66 int (*f7(a, b))(int, int) __arm_streaming int a; int b; { // c2x-warning {{deprecated}}
67 return 0;
70 __arm_streaming int a, b; // expected-error {{'__arm_streaming' only applies to function types}}
71 int c __arm_streaming, d __arm_streaming; // expected-error 2 {{'__arm_streaming' only applies to function types}}
73 void f8(void) __arm_streaming {
74 __arm_streaming int i, j; // expected-error {{'__arm_streaming' only applies to function types}}
75 int k, l __arm_streaming; // expected-error {{'__arm_streaming' only applies to function types}}
78 __arm_streaming void f9(void) { // expected-error {{'__arm_streaming' cannot be applied to a declaration}}
79 int i[10] __arm_streaming; // expected-error {{'__arm_streaming' only applies to function types}}
80 int (*fp1)(void)__arm_streaming;
81 int (*fp2 __arm_streaming)(void); // expected-error {{'__arm_streaming' cannot be applied to a declaration}}
83 int * __arm_streaming *ipp; // expected-error {{'__arm_streaming' only applies to function types}}
86 void f10(int j[static 10] __arm_streaming, int k[*] __arm_streaming); // expected-error 2 {{'__arm_streaming' only applies to function types}}
88 void f11(void) {
89 __arm_streaming {} // expected-error {{'__arm_streaming' cannot be applied to a statement}}
90 __arm_streaming if (1) {} // expected-error {{'__arm_streaming' cannot be applied to a statement}}
92 __arm_streaming switch (1) { // expected-error {{'__arm_streaming' cannot be applied to a statement}}
93 __arm_streaming case 1: __arm_streaming break; // expected-error 2 {{'__arm_streaming' cannot be applied to a statement}}
94 __arm_streaming default: break; // expected-error {{'__arm_streaming' cannot be applied to a statement}}
97 goto foo;
98 __arm_streaming foo: (void)1; // expected-error {{'__arm_streaming' only applies to non-K&R-style functions}}
100 __arm_streaming for (;;); // expected-error {{'__arm_streaming' cannot be applied to a statement}}
101 __arm_streaming while (1); // expected-error {{'__arm_streaming' cannot be applied to a statement}}
102 __arm_streaming do __arm_streaming { } while(1); // expected-error 2 {{'__arm_streaming' cannot be applied to a statement}}
104 __arm_streaming (void)1; // expected-error {{'__arm_streaming' cannot be applied to a statement}}
106 __arm_streaming; // expected-error {{'__arm_streaming' cannot be applied to a statement}}
108 (void)sizeof(int [4]__arm_streaming); // expected-error {{'__arm_streaming' only applies to function types}}
109 (void)sizeof(struct __arm_streaming S3 { int a __arm_streaming; }); // expected-error {{'__arm_streaming' only applies to non-K&R-style functions}} \
110 // expected-error {{'__arm_streaming' only applies to function types; type here is 'int'}}
112 __arm_streaming return; // expected-error {{'__arm_streaming' cannot be applied to a statement}}
114 __arm_streaming asm (""); // expected-error {{'__arm_streaming' cannot appear here}}
117 struct __arm_streaming S4 *s; // expected-error {{'__arm_streaming' cannot appear here}}
118 struct S5 {};
119 int c = sizeof(struct __arm_streaming S5); // expected-error {{'__arm_streaming' cannot appear here}}