source: src/tests/attributes.c@ 903f7c3

ADT aaron-thesis arm-eh ast-experimental cleanup-dtors deferred_resn demangler enum forall-pointer-decay jacob/cs343-translation jenkins-sandbox new-ast new-ast-unique-expr new-env no_list persistent-indexer pthread-emulation qualifiedEnum resolv-new with_gc
Last change on this file since 903f7c3 was 00303d50, checked in by Thierry Delisle <tdelisle@…>, 8 years ago

Fixed attributes test and added more error handling for machine type

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