annotate clang/test/Sema/attr-mode-enums.c @ 207:2e18cbf3894f

LLVM12
author Shinji KONO <kono@ie.u-ryukyu.ac.jp>
date Tue, 08 Jun 2021 06:07:14 +0900
parents 1d019706d866
children c4bab56944e8
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
150
anatofuz
parents:
diff changeset
1 // RUN: %clang_cc1 -fsyntax-only -verify %s
anatofuz
parents:
diff changeset
2
anatofuz
parents:
diff changeset
3 // Test checks that 'mode' attribute is handled correctly with enums, i. e. code
anatofuz
parents:
diff changeset
4 // 1. "typedef enum { A } __attribute__((mode(HI))) T;" is accepted,
anatofuz
parents:
diff changeset
5 // 2. "enum X __attribute__((mode(QI))) var;" forms a complete integer type.
anatofuz
parents:
diff changeset
6 // 3. "enum { A } __attribute__((mode(V4SI))) var;" is not accepted (vector mode).
anatofuz
parents:
diff changeset
7
anatofuz
parents:
diff changeset
8 typedef enum { E4 } EnumType;
anatofuz
parents:
diff changeset
9
anatofuz
parents:
diff changeset
10 int main() {
anatofuz
parents:
diff changeset
11 // Vector mode are not allowed with enums.
anatofuz
parents:
diff changeset
12 typedef enum { E1 } __attribute__((mode(V4QI))) RejectedType1; // expected-error{{mode 'V4QI' is not supported for enumeration types}}
anatofuz
parents:
diff changeset
13 // expected-warning@-1{{specifying vector types with the 'mode' attribute is deprecated}}
anatofuz
parents:
diff changeset
14 typedef enum __attribute__((mode(V8HI))) { E2 } RejectedType2; // expected-error{{mode 'V8HI' is not supported for enumeration types}}
anatofuz
parents:
diff changeset
15 // expected-warning@-1{{deprecated}}
anatofuz
parents:
diff changeset
16 typedef enum E3 __attribute__((mode(V2SI))) RejectedType3; // expected-error{{mode 'V2SI' is not supported for enumeration types}}
anatofuz
parents:
diff changeset
17 // expected-warning@-1{{deprecated}}
anatofuz
parents:
diff changeset
18 typedef EnumType __attribute__((mode(V4DI))) RejectedType4; // expected-error{{mode 'V4DI' is not supported for enumeration types}}
anatofuz
parents:
diff changeset
19 // expected-warning@-1{{deprecated}}
anatofuz
parents:
diff changeset
20 EnumType v1 __attribute__((mode(V4QI))); // expected-error{{mode 'V4QI' is not supported for enumeration types}}
anatofuz
parents:
diff changeset
21 // expected-warning@-1{{deprecated}}
anatofuz
parents:
diff changeset
22 enum __attribute__((mode(V8HI))) { E5 } v2; // expected-error{{mode 'V8HI' is not supported for enumeration types}}
anatofuz
parents:
diff changeset
23 // expected-warning@-1{{deprecated}}
anatofuz
parents:
diff changeset
24
anatofuz
parents:
diff changeset
25 // Incomplete enums without mode attribute are not allowed.
anatofuz
parents:
diff changeset
26 typedef enum Y IncompleteYType; // expected-note{{forward declaration of 'enum Y'}}
anatofuz
parents:
diff changeset
27
anatofuz
parents:
diff changeset
28 enum X a1; // expected-error{{variable has incomplete type 'enum X'}}
anatofuz
parents:
diff changeset
29 // expected-note@-1{{forward declaration of 'enum X'}}
anatofuz
parents:
diff changeset
30 IncompleteYType a2; // expected-error{{variable has incomplete type 'IncompleteYType' (aka 'enum Y')}}
anatofuz
parents:
diff changeset
31
anatofuz
parents:
diff changeset
32 // OK with 'mode' attribute.
anatofuz
parents:
diff changeset
33 typedef enum Y __attribute__((mode(QI))) CompleteYType1;
anatofuz
parents:
diff changeset
34 typedef enum Y CompleteYType2 __attribute__((mode(HI)));
anatofuz
parents:
diff changeset
35 typedef enum { A1, B1 } __attribute__((mode(QI))) CompleteType3;
anatofuz
parents:
diff changeset
36 typedef enum { A2, B2 } CompleteType4 __attribute__((mode(QI)));
anatofuz
parents:
diff changeset
37 typedef enum __attribute__((mode(QI))) { A3, B3 } CompleteType5;
anatofuz
parents:
diff changeset
38
anatofuz
parents:
diff changeset
39 enum X __attribute__((mode(QI))) a3;
anatofuz
parents:
diff changeset
40 enum X a4 __attribute__((mode(HI)));
anatofuz
parents:
diff changeset
41 IncompleteYType __attribute__((mode(QI))) a5;
anatofuz
parents:
diff changeset
42 IncompleteYType a6 __attribute__((mode(HI)));
anatofuz
parents:
diff changeset
43 CompleteYType1 a7;
anatofuz
parents:
diff changeset
44 CompleteYType2 a8;
anatofuz
parents:
diff changeset
45 CompleteType3 a9;
anatofuz
parents:
diff changeset
46 CompleteType4 a10;
anatofuz
parents:
diff changeset
47 CompleteType5 a11;
anatofuz
parents:
diff changeset
48 enum __attribute__((mode(QI))) { A4, B4 } a12;
anatofuz
parents:
diff changeset
49
anatofuz
parents:
diff changeset
50 return 0;
anatofuz
parents:
diff changeset
51 }