1 // RUN: %clang_cc1 %s -ast-print -verify > %t.c
2 // RUN: FileCheck %s --input-file %t.c
3 //
4 // RUN: echo >> %t.c "// expected""-warning@* {{use of GNU old-style field designator extension}}"
5 // RUN: echo >> %t.c "// expected""-warning@* {{'EnumWithAttributes' is deprecated}}"
6 // RUN: echo >> %t.c "// expected""-note@* {{'EnumWithAttributes' has been explicitly marked deprecated here}}"
7 // RUN: echo >> %t.c "// expected""-warning@* {{'EnumWithAttributes2' is deprecated}}"
8 // RUN: echo >> %t.c "// expected""-note@* {{'EnumWithAttributes2' has been explicitly marked deprecated here}}"
9 // RUN: echo >> %t.c "// expected""-warning@* {{'EnumWithAttributes3' is deprecated}}"
10 // RUN: echo >> %t.c "// expected""-note@* {{'EnumWithAttributes3' has been explicitly marked deprecated here}}"
11 // RUN: %clang_cc1 -fsyntax-only %t.c -verify
12
13 typedef void func_typedef();
14 func_typedef xxx;
15
16 typedef void func_t(int x);
17 func_t a;
18
19 struct blah {
20 struct {
21 struct {
22 int b;
23 };
24 };
25 };
26
27 // This used to crash clang.
28 struct {
29 }(s1);
30
foo(const struct blah * b)31 int foo(const struct blah *b) {
32 // CHECK: return b->b;
33 return b->b;
34 }
35
arr(int a[static3])36 int arr(int a[static 3]) {
37 // CHECK: int a[static 3]
38 return a[2];
39 }
40
rarr(int a[restrict static3])41 int rarr(int a[restrict static 3]) {
42 // CHECK: int a[restrict static 3]
43 return a[2];
44 }
45
varr(int n,int a[static n])46 int varr(int n, int a[static n]) {
47 // CHECK: int a[static n]
48 return a[2];
49 }
50
rvarr(int n,int a[restrict static n])51 int rvarr(int n, int a[restrict static n]) {
52 // CHECK: int a[restrict static n]
53 return a[2];
54 }
55
56 // CHECK: typedef struct {
57 typedef struct {
58 int f;
59 } T __attribute__ ((__aligned__));
60
61 // CHECK: struct __attribute__((visibility("default"))) S;
62 struct __attribute__((visibility("default"))) S;
63
64 struct pair_t {
65 int a;
66 int b;
67 };
68
69 // CHECK: struct pair_t p = {a: 3, .b = 4};
70 struct pair_t p = {a: 3, .b = 4}; // expected-warning {{use of GNU old-style field designator extension}}
71
initializers()72 void initializers() {
73 // CHECK: int *x = ((void *)0), *y = ((void *)0);
74 int *x = ((void *)0), *y = ((void *)0);
75 struct Z{};
76 struct {
77 struct Z z;
78 // CHECK: } z = {(struct Z){}};
79 } z = {(struct Z){}};
80 }
81
82 // CHECK-LABEL: enum __attribute__((deprecated(""))) EnumWithAttributes {
83 enum EnumWithAttributes { // expected-warning {{'EnumWithAttributes' is deprecated}}
84 // CHECK-NEXT: EnumWithAttributesFoo __attribute__((deprecated(""))),
85 EnumWithAttributesFoo __attribute__((deprecated)),
86 // CHECK-NEXT: EnumWithAttributesBar __attribute__((unavailable(""))) = 50
87 EnumWithAttributesBar __attribute__((unavailable)) = 50
88 // CHECK-NEXT: } *EnumWithAttributesPtr;
89 } __attribute__((deprecated)) *EnumWithAttributesPtr; // expected-note {{'EnumWithAttributes' has been explicitly marked deprecated here}}
90
91 // CHECK-LABEL: enum __attribute__((deprecated(""))) EnumWithAttributes2 *EnumWithAttributes2Ptr;
92 // expected-warning@+2 {{'EnumWithAttributes2' is deprecated}}
93 // expected-note@+1 {{'EnumWithAttributes2' has been explicitly marked deprecated here}}
94 enum __attribute__((deprecated)) EnumWithAttributes2 *EnumWithAttributes2Ptr;
95
96 // CHECK-LABEL: EnumWithAttributes3Fn
EnumWithAttributes3Fn()97 void EnumWithAttributes3Fn() {
98 // CHECK-NEXT: enum __attribute__((deprecated(""))) EnumWithAttributes3 *EnumWithAttributes3Ptr;
99 // expected-warning@+2 {{'EnumWithAttributes3' is deprecated}}
100 // expected-note@+1 {{'EnumWithAttributes3' has been explicitly marked deprecated here}}
101 enum __attribute__((deprecated)) EnumWithAttributes3 *EnumWithAttributes3Ptr;
102 // Printing must not put the attribute after the tag where it would apply to
103 // the variable instead of the type, and then our deprecation warning would
104 // move to this use of the variable.
105 void *p = EnumWithAttributes3Ptr;
106 }
107