source: tests/attributes.cfa@ 332e93a

Last change on this file since 332e93a was bada452, checked in by Andrew Beach <ajbeach@…>, 8 months ago

Removed warnings from serveral tests and removed them from the ..._TO_INVESTIGATE list. One test triggered a Cforall warning and a new test to check that has been added. collections/vector-demo has no warnings in its body, but the library it uses does have warnings and will have to move after that is fixed.

  • Property mode set to 100644
File size: 10.9 KB
Line 
1//
2// Cforall Version 1.0.0 Copyright (C) 2017 University of Waterloo
3//
4// The contents of this file are covered under the licence agreement in the
5// file "LICENCE" distributed with Cforall.
6//
7// attributes.cfa --
8//
9// Author : Peter A. Buhr
10// Created On : Mon Feb 6 16:07:02 2017
11// Last Modified By : Peter A. Buhr
12// Last Modified On : Fri Dec 20 15:32:21 2024
13// Update Count : 53
14//
15
16#pragma GCC diagnostic ignored "-Wattributes"
17
18// label attribute
19int la() {
20 L: __attribute__(( unused )) 1;
21 return 1;
22}
23
24
25// aggregate_name
26static struct __attribute__(( unused )) {} Dummy;
27struct __attribute__(( unused )) Agn1;
28struct __attribute__(( unused )) Agn2 {};
29enum __attribute__(( unused )) { E1 };
30enum __attribute__(( unused )) Agn3;
31enum __attribute__(( packed )) Agn3 { E2 };
32#ifdef __CFA__
33struct __attribute__(( unused )) {} ( int );
34struct __attribute__(( unused )) Agn4 {} ( int );
35#endif // __CFA__
36
37
38// field_declaring_list
39struct Fdl {
40 int f1 __attribute__(( unused ));
41 int __attribute__(( unused )) f2;
42 int __attribute__(( unused )) f3 __attribute__(( unused ));
43 __attribute__(( unused )) int f4;
44 __attribute__(( unused )) int f5 __attribute__(( unused ));
45 __attribute__(( used )) int f6 __attribute__(( packed )), f7 __attribute__(( unused )) __attribute__(( unused )), __attribute__(( used )) f8 __attribute__(( unused ));
46 int * f9 __attribute__(( unused ));
47 __attribute__(( used )) int __attribute__(( unused )) * f10;
48 int ( ( * f11 __attribute__(( unused )) ) __attribute__(( unused )) );
49 int ( ( __attribute__(( unused )) * f12 __attribute__(( unused )) ) __attribute__(( unused )) );
50 int ( ( __attribute__(( unused )) * (f13) __attribute__(( unused )) ) __attribute__(( unused )) );
51 int ( ( ( __attribute__(( unused )) * (f14) ) __attribute__(( unused )) ) __attribute__(( unused )) );
52};
53
54
55// asm_name_opt
56int f() asm( "xyz" ) __attribute__(( unused ));
57
58
59// variable_declarator
60const __attribute__(( used )) int vd1 __attribute__(( used )), __attribute__(( unused )) vd2;
61const __attribute__(( used )) int __attribute__(( used )) * __attribute__(( used )) vd3 __attribute__(( used )), __attribute__(( unused )) (* __attribute__(( unused )) (vd4)) __attribute__(( used ));
62const __attribute__(( used )) int __attribute__(( used )) vd5[5] __attribute__(( used )), __attribute__(( unused )) ((vd6)[5]) __attribute__(( used ));
63const __attribute__(( used )) int __attribute__(( used )) (* __attribute__(( used )) vd7)() __attribute__(( used )), __attribute__(( unused )) ((* __attribute__(( used )) vd8)()) __attribute__(( used ));
64const __attribute__(( used )) int __attribute__(( used )) ( __attribute__(( used )) * vd9)() __attribute__(( used )), __attribute__(( unused )) (( __attribute__(( used )) * vd10)()) __attribute__(( used ));
65
66// function_declarator
67__attribute__(( unused )) int f1() __attribute__(( used ));
68__attribute__(( unused )) int f1() { return 1; }
69__attribute__(( unused )) int * __attribute__(( unused )) * const __attribute__(( unused )) f2() __attribute__(( used ));
70__attribute__(( unused )) int * __attribute__(( unused )) * const __attribute__(( unused )) f2() { return 0p; }
71__attribute__(( unused )) int (* __attribute__(( unused )) f3(int))[] __attribute__(( used ));
72__attribute__(( unused )) int ( __attribute__(( unused )) * __attribute__(( unused )) f4(int))[] __attribute__(( used ));
73__attribute__(( unused )) int (* __attribute__(( unused )) f5(int p))[] { (void)p; return 0p; }
74__attribute__(( unused )) int ( __attribute__(( unused )) * (f6)(int p))[] { (void)p; return 0p; }
75__attribute__(( unused )) int (* __attribute__(( unused )) f7())(int) __attribute__(( used ));
76__attribute__(( unused )) int (* __attribute__(( unused )) f8())(int) { return 0p; }
77__attribute__(( unused )) int ( __attribute__(( unused )) * f9())(int) { return 0p; }
78__attribute__(( unused )) int ( __attribute__(( unused )) * (f10)())(int) { return 0p; }
79
80
81// variable_type_redeclarator
82typedef int t1, t2, t3, t4, t5, t6, t7, t8;
83void vtr() {
84 // redefine typedef name in new scope
85 __attribute__(( unused )) int __attribute__(( unused )) t1 __attribute__(( used ));
86 __attribute__(( unused )) int __attribute__(( unused )) (* (* t2 __attribute__(( unused )) ) __attribute__(( unused )) ) __attribute__(( unused ));
87 __attribute__(( unused )) int __attribute__(( unused )) t3[5] __attribute__(( unused ));
88 __attribute__(( unused )) int __attribute__(( unused )) (* (* __attribute__(( unused )) t4[5]) __attribute__(( unused )) ) __attribute__(( unused ));
89 __attribute__(( unused )) int __attribute__(( unused )) ( __attribute__(( unused )) * ( __attribute__(( unused )) * t5[5]) __attribute__(( unused )) ) __attribute__(( unused ));
90 __attribute__(( unused )) int __attribute__(( unused )) t6() __attribute__(( unused ));
91 __attribute__(( unused )) int __attribute__(( unused )) * __attribute__(( unused )) ((t6))() __attribute__(( unused ));
92}
93
94
95// identifier_parameter_declarator
96void ipd1( __attribute__(( unused )) int __attribute__(( unused )) p __attribute__(( unused )),
97 __attribute__(( unused )) int __attribute__(( unused )) q __attribute__(( unused )) );
98void ipd1( __attribute__(( unused )) int __attribute__(( unused )) p __attribute__(( unused )),
99 __attribute__(( unused )) int __attribute__(( unused )) q __attribute__(( unused )) ) {}
100void ipd2( __attribute__(( unused )) int __attribute__(( unused )) * __attribute__(( unused )) p __attribute__(( unused )),
101 __attribute__(( unused )) int __attribute__(( unused )) (* (q)) __attribute__(( unused )) );
102void ipd2( __attribute__(( unused )) int __attribute__(( unused )) * __attribute__(( unused )) p __attribute__(( unused )),
103 __attribute__(( unused )) int __attribute__(( unused )) (* (q)) __attribute__(( unused )) ) {}
104void ipd3( __attribute__(( unused )) int __attribute__(( unused )) p[] __attribute__(( unused )),
105 __attribute__(( unused )) int __attribute__(( unused )) ((q)[]) __attribute__(( unused )) );
106void ipd3( __attribute__(( unused )) int __attribute__(( unused )) p[] __attribute__(( unused )),
107 __attribute__(( unused )) int __attribute__(( unused )) ((q)[]) __attribute__(( unused )) ) {}
108void ipd4( __attribute__(( unused )) int __attribute__(( unused )) p() __attribute__(( unused )),
109 __attribute__(( unused )) int __attribute__(( unused )) ((q)()) __attribute__(( unused )) );
110void ipd4( __attribute__(( unused )) int __attribute__(( unused )) p() __attribute__(( unused )),
111 __attribute__(( unused )) int __attribute__(( unused )) ((q)()) __attribute__(( unused )) ) {}
112
113
114// type_parameter_redeclarator
115typedef int Foo;
116int tpr1( __attribute__(( unused )) int __attribute__(( unused )) Foo __attribute__(( unused )) );
117int tpr2( __attribute__(( unused )) int __attribute__(( unused )) (* __attribute__(( unused )) (* __attribute__(( unused )) Foo) __attribute__(( unused )) ) __attribute__(( unused )) );
118int tpr3( __attribute__(( unused )) int __attribute__(( unused )) Foo[] __attribute__(( unused )));
119int tpr4( __attribute__(( unused )) int __attribute__(( unused )) ( __attribute__(( unused )) Foo[5] __attribute__(( unused )) ) );
120int tpr5( __attribute__(( unused )) int __attribute__(( unused )) (*Foo)() __attribute__(( unused )) );
121int tpr6( __attribute__(( unused )) int __attribute__(( unused )) Foo() __attribute__(( unused )) );
122int tpr7( __attribute__(( unused )) int __attribute__(( unused )) ( __attribute__(( unused )) Foo( __attribute__(( unused )) int __attribute__(( unused )) ) ) );
123
124
125// abstract_declarator
126void ad() {
127 typeof( int __attribute__(( used )) ) ad1 __attribute__(( unused ));
128 typeof( int __attribute__(( unused )) * __attribute__(( unused )) ) ad2 __attribute__(( unused ));
129 typeof( int __attribute__(( unused )) [5] ) __attribute__(( unused )) ad3 __attribute__(( unused ));
130 typeof( __attribute__(( unused )) int __attribute__(( unused )) (*)[10] __attribute__(( unused )) ) __attribute__(( unused )) ad4 __attribute__(( unused )), ad5 __attribute__(( used ));
131 typeof( __attribute__(( unused )) int __attribute__(( unused )) () __attribute__(( unused )) ) __attribute__(( unused )) ad6 __attribute__(( unused ));
132 sizeof( __attribute__(( unused )) int __attribute__(( unused )) );
133 sizeof( __attribute__(( unused )) int __attribute__(( unused )) (* __attribute__(( unused )) (* __attribute__(( unused )) ) ) );
134 sizeof( __attribute__(( unused )) int __attribute__(( unused )) [5] __attribute__(( unused )) );
135 sizeof( __attribute__(( unused )) int __attribute__(( unused )) (*)[10] __attribute__(( unused )) );
136 sizeof( __attribute__(( unused )) int __attribute__(( unused )) () __attribute__(( unused )) );
137 sizeof( struct { int i; } __attribute__(( unused )) );
138 sizeof( enum { R } __attribute__(( unused )) );
139}
140
141
142// abstract_parameter_declarator
143int apd1( __attribute__(( unused )) int __attribute__(( unused )) * __attribute__(( unused )),
144 __attribute__(( unused )) int __attribute__(( unused )) * __attribute__(( unused )) );
145int apd2( __attribute__(( unused )) int __attribute__(( unused )) (* (* __attribute__(( unused )) ) __attribute__(( unused )) ),
146 __attribute__(( unused )) int __attribute__(( unused )) (* (* __attribute__(( unused )) ) __attribute__(( unused )) ) );
147int apd3( __attribute__(( unused )) int __attribute__(( unused )) ([]) __attribute__(( unused )),
148 __attribute__(( unused )) int __attribute__(( unused )) ([]) __attribute__(( unused )) );
149int apd4( __attribute__(( unused )) int __attribute__(( unused )) () __attribute__(( unused )),
150 __attribute__(( unused )) int __attribute__(( unused )) () __attribute__(( unused )) );
151int apd5( __attribute__(( unused )) int __attribute__(( unused )) (( __attribute__(( unused )) int )) __attribute__(( unused )),
152 __attribute__(( unused )) int __attribute__(( unused )) ( __attribute__(( unused )) int ) __attribute__(( unused )) );
153int apd6( __attribute__(( unused )) int __attribute__(( unused )) (*)() __attribute__(( unused )),
154 __attribute__(( unused )) int __attribute__(( unused )) (*)() __attribute__(( unused )) );
155int apd7( __attribute__(( unused )) int __attribute__(( unused )) ((*)( __attribute__(( unused )) int ) ) __attribute__(( unused )),
156 __attribute__(( unused )) int __attribute__(( unused )) ((*)( __attribute__(( unused )) int ) ) __attribute__(( unused )) );
157
158
159// variable_abstract_declarator
160struct Vad {
161 int __attribute__(( unused )) x;
162 int __attribute__(( unused )) :4;
163 int __attribute__(( unused )) :4, __attribute__(( unused )) :6;
164};
165
166[[ noreturn ]] void fred() {
167 int [[unused]] i;
168 // C23 attributes are parsed but not pushed through the compiler.
169 // int [[gnu::xxx]] j;
170 switch ( 3 ) {
171 case 2:
172 4;
173// __attribute__(( fallthrough ))
174// [[fallthrough]]
175 case 1:
176 3;
177 }
178 abort();
179}
180
181@[ noreturn ] void mary() {
182 @[aligned(16)] struct S { int i; };
183 int @[unused] i;
184 switch ( 3 ) {
185 case 2:
186 4;
187// __attribute__(( fallthrough ))
188// [[fallthrough]]
189 case 1:
190 3;
191 }
192 abort();
193}
194
195// Local Variables: //
196// tab-width: 4 //
197// compile-command: "cfa attributes.cfa" //
198// End: //
Note: See TracBrowser for help on using the repository browser.