• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // First check compiling and printing of this file.
2 //
3 // RUN: %clang_cc1 -verify -ast-print %s > %t.c
4 // RUN: FileCheck --check-prefixes=CHECK,PRINT %s --input-file %t.c
5 //
6 // Now check compiling and printing of the printed file.
7 //
8 // RUN: echo "// expected""-warning@* 6 {{'T' is deprecated}}" >> %t.c
9 // RUN: echo "// expected""-note@* 6 {{'T' has been explicitly marked deprecated here}}" >> %t.c
10 //
11 // RUN: %clang_cc1 -verify -ast-print %t.c \
12 // RUN: | FileCheck --check-prefixes=CHECK,PRINT %s
13 
14 // END.
15 
16 // CHECK-LABEL: defFirst
defFirst()17 void defFirst() {
18   // PRINT-NEXT: enum
19   // PRINT-DAG:  __attribute__((aligned(16)))
20   // PRINT-DAG:  __attribute__((deprecated("")))
21   // PRINT-SAME: T {
22   // PRINT-NEXT:   E0,
23   // PRINT-NEXT:   E1
24   // PRINT-NEXT: } *p0;
25   // expected-warning@+2 {{'T' is deprecated}}
26   // expected-note@+1 2 {{'T' has been explicitly marked deprecated here}}
27   enum __attribute__((aligned(16))) __attribute__((deprecated(""))) T {
28     E0, E1
29   } *p0;
30 
31   // PRINT-NEXT: enum T *p1;
32   enum T *p1; // expected-warning {{'T' is deprecated}}
33 }
34 
35 // CHECK-LABEL: defLast
defLast()36 void defLast() {
37   // PRINT-NEXT: enum __attribute__((aligned(16))) T *p0;
38   enum __attribute__((aligned(16))) T *p0;
39 
40   // PRINT-NEXT: enum __attribute__((deprecated(""))) T {
41   // PRINT-NEXT:   E0,
42   // PRINT-NEXT:   E1
43   // PRINT-NEXT: } *p1;
44   // expected-warning@+2 {{'T' is deprecated}}
45   // expected-note@+1 {{'T' has been explicitly marked deprecated here}}
46   enum __attribute__((deprecated(""))) T { E0, E1 } *p1;
47 }
48 
49 // CHECK-LABEL: defMiddle
defMiddle()50 void defMiddle() {
51   // PRINT-NEXT: enum __attribute__((deprecated(""))) T *p0;
52   // expected-warning@+2 {{'T' is deprecated}}
53   // expected-note@+1 3 {{'T' has been explicitly marked deprecated here}}
54   enum __attribute__((deprecated(""))) T *p0;
55 
56   // PRINT-NEXT: enum __attribute__((aligned(16))) T {
57   // PRINT-NEXT:   E0
58   // PRINT-NEXT:   E1
59   // PRINT-NEXT: } *p1;
60   enum __attribute__((aligned(16))) T { E0, E1 } *p1; // expected-warning {{'T' is deprecated}}
61 
62   // PRINT-NEXT: enum T *p2;
63   enum T *p2; // expected-warning {{'T' is deprecated}}
64 }
65 
66 // CHECK-LABEL: declsOnly
declsOnly()67 void declsOnly() {
68   // FIXME: For some reason, attributes are ignored if they're not on the first
69   // declaration and not on the definition.
70 
71   // PRINT-NEXT: enum __attribute__((aligned)) T *p0;
72   enum __attribute__((aligned)) T *p0;
73 
74   // PRINT-NEXT: enum T *p1;
75   enum __attribute__((may_alias)) T *p1;
76 
77   // PRINT-NEXT: enum T *p2;
78   enum T *p2;
79 
80   // PRINT-NEXT: enum T *p3;
81   enum __attribute__((deprecated(""))) T *p3;
82 
83   // PRINT-NEXT: enum T *p4;
84   enum T *p4;
85 }
86 
87 // Check that tag decl groups stay together in decl contexts.
88 
89 // PRINT-LABEL: enum DeclGroupAtFileScope {
90 // PRINT-NEXT:    DeclGroupAtFileScope0
91 // PRINT-NEXT:  } *DeclGroupAtFileScopePtr;
92 enum DeclGroupAtFileScope { DeclGroupAtFileScope0 } *DeclGroupAtFileScopePtr;
93 
94 // PRINT-LABEL: struct DeclGroupInMemberList
95 struct DeclGroupInMemberList {
96   // PRINT-NEXT:  enum T1 {
97   // PRINT-NEXT:    T10
98   // PRINT-NEXT:  } *p0;
99   enum T1 { T10 } *p0;
100   // PRINT-NEXT:  enum T2 {
101   // PRINT-NEXT:    T20
102   // PRINT-NEXT:  } *p1, *p2;
103   enum T2 { T20 } *p1, *p2;
104   // PRINT-NEXT: };
105 };
106 
107 enum fixedEnum : int { fixedEnumerator };
108 // PRINT-LABEL: enum fixedEnum : int {
109 // PRINT-NEXT: fixedEnumerator
110 // PRINT-NEXT: };
111