llvm-project
140 строк · 8.8 Кб
1// RUN: sed -e "s@ATTR_USE@__arm_streaming@g" -e "s@ATTR_NAME@__arm_streaming@g" %s > %t
2// RUN: %clang_cc1 -fsyntax-only -triple aarch64-none-linux-gnu -target-feature +sme -verify=expected,notc2x -Wno-strict-prototypes %t
3// RUN: %clang_cc1 -fsyntax-only -triple aarch64-none-linux-gnu -target-feature +sme -verify=expected,c2x %t
4// RUN: sed -e "s@ATTR_USE@__arm_inout\(\"za\"\)@g" -e "s@ATTR_NAME@__arm_inout@g" %s > %t
5// RUN: %clang_cc1 -fsyntax-only -triple aarch64-none-linux-gnu -target-feature +sme -verify=expected,notc2x -Wno-strict-prototypes %t
6// RUN: %clang_cc1 -fsyntax-only -triple aarch64-none-linux-gnu -target-feature +sme -verify=expected,c2x %t
7
8enum ATTR_USE E { // expected-error {{'ATTR_NAME' only applies to non-K&R-style functions}}
9One ATTR_USE, // expected-error {{'ATTR_NAME' only applies to non-K&R-style functions}}
10Two,
11Three ATTR_USE // expected-error {{'ATTR_NAME' only applies to non-K&R-style functions}}
12};
13
14enum ATTR_USE { Four }; // expected-error {{'ATTR_NAME' only applies to non-K&R-style functions}}
15ATTR_USE enum E2 { Five }; // expected-error {{misplaced 'ATTR_NAME'}}
16
17// FIXME: this diagnostic can be improved.
18enum { ATTR_USE Six }; // expected-error {{expected identifier}}
19
20// FIXME: this diagnostic can be improved.
21enum E3 ATTR_USE { Seven }; // expected-error {{expected identifier or '('}}
22
23struct ATTR_USE S1 { // expected-error {{'ATTR_NAME' only applies to non-K&R-style functions}}
24int i ATTR_USE; // expected-error {{'ATTR_NAME' only applies to function types}}
25int ATTR_USE j; // expected-error {{'ATTR_NAME' only applies to function types}}
26int k[10] ATTR_USE; // expected-error {{'ATTR_NAME' only applies to function types}}
27int l ATTR_USE[10]; // expected-error {{'ATTR_NAME' only applies to function types}}
28ATTR_USE int m, n; // expected-error {{'ATTR_NAME' only applies to function types}}
29int o ATTR_USE : 12; // expected-error {{'ATTR_NAME' only applies to function types}}
30int ATTR_USE : 0; // expected-error {{'ATTR_NAME' only applies to function types}}
31int p, ATTR_USE : 0; // expected-error {{'ATTR_NAME' cannot appear here}}
32int q, ATTR_USE r; // expected-error {{'ATTR_NAME' cannot appear here}}
33ATTR_USE int; // expected-error {{'ATTR_NAME' cannot appear here}} \
34// expected-warning {{declaration does not declare anything}}
35};
36
37ATTR_USE struct S2 { int a; }; // expected-error {{misplaced 'ATTR_NAME'}}
38struct S3 ATTR_USE { int a; }; // expected-error {{'ATTR_NAME' cannot appear here}} \
39expected-error {{'ATTR_NAME' only applies to non-K&R-style functions}}
40
41union ATTR_USE U { // expected-error {{'ATTR_NAME' only applies to non-K&R-style functions}}
42double d ATTR_USE; // expected-error {{'ATTR_NAME' only applies to function types; type here is 'double'}}
43ATTR_USE int i; // expected-error {{'ATTR_NAME' only applies to function types; type here is 'int'}}
44};
45
46ATTR_USE union U2 { double d; }; // expected-error {{misplaced 'ATTR_NAME'}}
47union U3 ATTR_USE { double d; }; // expected-error {{'ATTR_NAME' cannot appear here}} \
48expected-error {{'ATTR_NAME' only applies to non-K&R-style functions}}
49
50struct ATTR_USE IncompleteStruct; // expected-error {{'ATTR_NAME' only applies to non-K&R-style functions}}
51union ATTR_USE IncompleteUnion; // expected-error {{'ATTR_NAME' only applies to non-K&R-style functions}}
52enum ATTR_USE IncompleteEnum; // expected-error {{'ATTR_NAME' only applies to non-K&R-style functions}}
53
54ATTR_USE void f1(void); // expected-error {{'ATTR_NAME' cannot be applied to a declaration}}
55void ATTR_USE f2(void); // expected-error {{'ATTR_NAME' only applies to function types}}
56void f3 ATTR_USE (void); // expected-error {{'ATTR_NAME' cannot be applied to a declaration}}
57void f4(void) ATTR_USE;
58
59void f5(int i ATTR_USE, ATTR_USE int j, int ATTR_USE k); // expected-error 3 {{'ATTR_NAME' only applies to function types}}
60
61void f6(a, b) ATTR_USE int a; int b; { // expected-error {{'ATTR_NAME' cannot appear here}} \
62c2x-warning {{deprecated}}
63}
64
65// FIXME: technically, an attribute list cannot appear here, but we currently
66// parse it as part of the return type of the function, which is reasonable
67// behavior given that we *don't* want to parse it as part of the K&R parameter
68// declarations. It is disallowed to avoid a parsing ambiguity we already
69// handle well.
70int (*f7(a, b))(int, int) ATTR_USE int a; int b; { // c2x-warning {{deprecated}}
71return 0;
72}
73
74ATTR_USE int a, b; // expected-error {{'ATTR_NAME' only applies to function types}}
75int c ATTR_USE, d ATTR_USE; // expected-error 2 {{'ATTR_NAME' only applies to function types}}
76
77void f8(void) ATTR_USE {
78ATTR_USE int i, j; // expected-error {{'ATTR_NAME' only applies to function types}}
79int k, l ATTR_USE; // expected-error {{'ATTR_NAME' only applies to function types}}
80}
81
82ATTR_USE void f9(void) { // expected-error {{'ATTR_NAME' cannot be applied to a declaration}}
83int i[10] ATTR_USE; // expected-error {{'ATTR_NAME' only applies to function types}}
84int (*fp1)(void)ATTR_USE;
85int (*fp2 ATTR_USE)(void); // expected-error {{'ATTR_NAME' cannot be applied to a declaration}}
86
87int * ATTR_USE *ipp; // expected-error {{'ATTR_NAME' only applies to function types}}
88}
89
90void f10(int j[static 10] ATTR_USE, int k[*] ATTR_USE); // expected-error 2 {{'ATTR_NAME' only applies to function types}}
91
92void f11(void) {
93ATTR_USE {} // expected-error {{'ATTR_NAME' cannot be applied to a statement}}
94ATTR_USE if (1) {} // expected-error {{'ATTR_NAME' cannot be applied to a statement}}
95
96ATTR_USE switch (1) { // expected-error {{'ATTR_NAME' cannot be applied to a statement}}
97ATTR_USE case 1: ATTR_USE break; // expected-error 2 {{'ATTR_NAME' cannot be applied to a statement}}
98ATTR_USE default: break; // expected-error {{'ATTR_NAME' cannot be applied to a statement}}
99}
100
101goto foo;
102ATTR_USE foo: (void)1; // expected-error {{'ATTR_NAME' only applies to non-K&R-style functions}}
103
104ATTR_USE for (;;); // expected-error {{'ATTR_NAME' cannot be applied to a statement}}
105ATTR_USE while (1); // expected-error {{'ATTR_NAME' cannot be applied to a statement}}
106ATTR_USE do ATTR_USE { } while(1); // expected-error 2 {{'ATTR_NAME' cannot be applied to a statement}}
107
108ATTR_USE (void)1; // expected-error {{'ATTR_NAME' cannot be applied to a statement}}
109
110ATTR_USE; // expected-error {{'ATTR_NAME' cannot be applied to a statement}}
111
112(void)sizeof(int [4]ATTR_USE); // expected-error {{'ATTR_NAME' only applies to function types}}
113(void)sizeof(struct ATTR_USE S3 { int a ATTR_USE; }); // expected-error {{'ATTR_NAME' only applies to non-K&R-style functions}} \
114// expected-error {{'ATTR_NAME' only applies to function types; type here is 'int'}}
115
116ATTR_USE return; // expected-error {{'ATTR_NAME' cannot be applied to a statement}}
117
118ATTR_USE asm (""); // expected-error {{'ATTR_NAME' cannot appear here}}
119}
120
121struct ATTR_USE S4 *s; // expected-error {{'ATTR_NAME' cannot appear here}}
122struct S5 {};
123int c = sizeof(struct ATTR_USE S5); // expected-error {{'ATTR_NAME' cannot appear here}}
124
125void invalid_parentheses1() __arm_inout; // expected-error {{expected '(' after ''__arm_inout''}}
126void invalid_parentheses2() __arm_inout(; // expected-error {{expected string literal as argument of '__arm_inout' attribute}}
127void invalid_parentheses3() __arm_inout((); // expected-error {{expected string literal as argument of '__arm_inout' attribute}}
128void invalid_parentheses4() __arm_inout); // expected-error {{expected '(' after ''__arm_inout''}} \
129// expected-error {{expected function body after function declarator}}
130void invalid_parentheses5() __arm_inout(()); // expected-error {{expected string literal as argument of '__arm_inout' attribute}}
131void invalid_parentheses6() __arm_inout("za"; // expected-error {{expected ')'}}
132void invalid_parentheses7() __arm_streaming(; // expected-error {{expected parameter declarator}} \
133// expected-error {{expected ')'}} \
134// expected-note {{to match this '('}} \
135// expected-error {{function cannot return function type 'void ()'}} \
136// expected-error {{'__arm_streaming' only applies to function types; type here is 'int ()'}} \
137// expected-warning {{'__arm_streaming' only applies to non-K&R-style functions}}
138void invalid_parentheses8() __arm_streaming(); // expected-error {{function cannot return function type 'void ()'}} \
139// expected-error {{'__arm_streaming' only applies to function types; type here is 'int ()'}} \
140// expected-warning {{'__arm_streaming' only applies to non-K&R-style functions}}
141