Mercurial > hg > CbC > CbC_llvm
comparison clang/test/Parser/c2x-attributes.c @ 150:1d019706d866
LLVM10
author | anatofuz |
---|---|
date | Thu, 13 Feb 2020 15:10:13 +0900 |
parents | |
children | 2e18cbf3894f |
comparison
equal
deleted
inserted
replaced
147:c2174574ed3a | 150:1d019706d866 |
---|---|
1 // RUN: %clang_cc1 -fsyntax-only -fdouble-square-bracket-attributes -verify %s | |
2 // RUN: %clang_cc1 -fsyntax-only -std=gnu2x -verify %s | |
3 | |
4 enum [[]] E { | |
5 One [[]], | |
6 Two, | |
7 Three [[]] | |
8 }; | |
9 | |
10 enum [[]] { Four }; | |
11 [[]] enum E2 { Five }; // expected-error {{misplaced attributes}} | |
12 | |
13 // FIXME: this diagnostic can be improved. | |
14 enum { [[]] Six }; // expected-error {{expected identifier}} | |
15 | |
16 // FIXME: this diagnostic can be improved. | |
17 enum E3 [[]] { Seven }; // expected-error {{expected identifier or '('}} | |
18 | |
19 struct [[]] S1 { | |
20 int i [[]]; | |
21 int [[]] j; | |
22 int k[10] [[]]; | |
23 int l[[]][10]; | |
24 [[]] int m, n; | |
25 int o [[]] : 12; | |
26 }; | |
27 | |
28 [[]] struct S2 { int a; }; // expected-error {{misplaced attributes}} | |
29 struct S3 [[]] { int a; }; // expected-error {{an attribute list cannot appear here}} | |
30 | |
31 union [[]] U { | |
32 double d [[]]; | |
33 [[]] int i; | |
34 }; | |
35 | |
36 [[]] union U2 { double d; }; // expected-error {{misplaced attributes}} | |
37 union U3 [[]] { double d; }; // expected-error {{an attribute list cannot appear here}} | |
38 | |
39 struct [[]] IncompleteStruct; | |
40 union [[]] IncompleteUnion; | |
41 enum [[]] IncompleteEnum; | |
42 enum __attribute__((deprecated)) IncompleteEnum2; | |
43 | |
44 [[]] void f1(void); | |
45 void [[]] f2(void); | |
46 void f3 [[]] (void); | |
47 void f4(void) [[]]; | |
48 | |
49 void f5(int i [[]], [[]] int j, int [[]] k); | |
50 | |
51 void f6(a, b) [[]] int a; int b; { // expected-error {{an attribute list cannot appear here}} | |
52 } | |
53 | |
54 // FIXME: technically, an attribute list cannot appear here, but we currently | |
55 // parse it as part of the return type of the function, which is reasonable | |
56 // behavior given that we *don't* want to parse it as part of the K&R parameter | |
57 // declarations. It is disallowed to avoid a parsing ambiguity we already | |
58 // handle well. | |
59 int (*f7(a, b))(int, int) [[]] int a; int b; { | |
60 return 0; | |
61 } | |
62 | |
63 [[]] int a, b; | |
64 int c [[]], d [[]]; | |
65 | |
66 void f8(void) [[]] { | |
67 [[]] int i, j; | |
68 int k, l [[]]; | |
69 } | |
70 | |
71 [[]] void f9(void) { | |
72 int i[10] [[]]; | |
73 int (*fp1)(void)[[]]; | |
74 int (*fp2 [[]])(void); | |
75 | |
76 int * [[]] *ipp; | |
77 } | |
78 | |
79 void f10(int j[static 10] [[]], int k[*] [[]]); | |
80 | |
81 void f11(void) { | |
82 [[]] {} | |
83 [[]] if (1) {} | |
84 | |
85 [[]] switch (1) { | |
86 [[]] case 1: [[]] break; | |
87 [[]] default: break; | |
88 } | |
89 | |
90 goto foo; | |
91 [[]] foo: (void)1; | |
92 | |
93 [[]] for (;;); | |
94 [[]] while (1); | |
95 [[]] do [[]] { } while(1); | |
96 | |
97 [[]] (void)1; | |
98 | |
99 [[]]; | |
100 | |
101 (void)sizeof(int [4][[]]); | |
102 (void)sizeof(struct [[]] S3 { int a [[]]; }); | |
103 | |
104 [[]] return; | |
105 } | |
106 | |
107 [[attr]] void f12(void); // expected-warning {{unknown attribute 'attr' ignored}} | |
108 [[vendor::attr]] void f13(void); // expected-warning {{unknown attribute 'attr' ignored}} | |
109 | |
110 // Ensure that asm statements properly handle double colons. | |
111 void test_asm(void) { | |
112 asm("ret" :::); | |
113 asm("foo" :: "r" (xx)); // expected-error {{use of undeclared identifier 'xx'}} | |
114 } | |
115 | |
116 // Do not allow 'using' to introduce vendor attribute namespaces. | |
117 [[using vendor: attr1, attr2]] void f14(void); // expected-error {{expected ']'}} \ | |
118 // expected-warning {{unknown attribute 'vendor' ignored}} \ | |
119 // expected-warning {{unknown attribute 'using' ignored}} | |
120 | |
121 struct [[]] S4 *s; // expected-error {{an attribute list cannot appear here}} | |
122 struct S5 {}; | |
123 int c = sizeof(struct [[]] S5); // expected-error {{an attribute list cannot appear here}} |