1 // RUN: %clang_cc1 -fsyntax-only -verify %s -pedantic -std=c99
2
3 int __attribute__(()) x;
4
5 __inline void __attribute__((__always_inline__, __nodebug__))
foo(void)6 foo(void) {
7 }
8
9
10 __attribute__(()) y; // expected-warning {{defaults to 'int'}}
11
12 // PR2796
13 int (__attribute__(()) *z)(long y);
14
15
16 void f1(__attribute__(()) int x);
17
18 int f2(y, __attribute__(()) x); // expected-error {{expected identifier}}
19
20 // This is parsed as a normal argument list (with two args that are implicit
21 // int) because the __attribute__ is a declspec.
22 void f3(__attribute__(()) x, // expected-warning {{defaults to 'int'}}
23 y); // expected-warning {{defaults to 'int'}}
24
25 void f4(__attribute__(())); // expected-error {{expected parameter declarator}}
26
27
28 // This is ok, the __attribute__ applies to the pointer.
29 int baz(int (__attribute__(()) *x)(long y));
30
31 void g1(void (*f1)(__attribute__(()) int x));
32 void g2(int (*f2)(y, __attribute__(()) x)); // expected-error {{expected identifier}}
33 void g3(void (*f3)(__attribute__(()) x, int y)); // expected-warning {{defaults to 'int'}}
34 void g4(void (*f4)(__attribute__(()))); // expected-error {{expected parameter declarator}}
35
36
37 void (*h1)(void (*f1)(__attribute__(()) int x));
38 void (*h2)(int (*f2)(y, __attribute__(()) x)); // expected-error {{expected identifier}}
39
40 void (*h3)(void (*f3)(__attribute__(()) x)); // expected-warning {{defaults to 'int'}}
41 void (*h4)(void (*f4)(__attribute__(()))); // expected-error {{expected parameter declarator}}
42
43
44
45 // rdar://6131260
foo42(void)46 int foo42(void) {
47 int x, __attribute__((unused)) y, z;
48 return 0;
49 }
50
51 // rdar://6096491
52 void __attribute__((noreturn)) d0(void), __attribute__((noreturn)) d1(void);
53
54 void d2(void) __attribute__((noreturn)), d3(void) __attribute__((noreturn));
55
56
57 // PR6287
58 void __attribute__((returns_twice)) returns_twice_test();
59
60 int aligned(int);
61 int __attribute__((vec_type_hint(char, aligned(16) )) missing_rparen_1; // expected-error 2{{expected ')'}} expected-note {{to match}} expected-warning {{does not declare anything}}
62 int __attribute__((mode(x aligned(16) )) missing_rparen_2; // expected-error {{expected ')'}}
63 int __attribute__((format(printf, 0 aligned(16) )) missing_rparen_3; // expected-error {{expected ')'}}
64
65
66
67 int testFundef1(int *a) __attribute__((nonnull(1))) { // \
68 // expected-warning {{GCC does not allow 'nonnull' attribute in this position on a function definition}}
69 return *a;
70 }
71
72 // noreturn is lifted to type qualifier
73 void testFundef2() __attribute__((noreturn)) { // \
74 // expected-warning {{GCC does not allow 'noreturn' attribute in this position on a function definition}}
75 testFundef2();
76 }
77
78 int testFundef3(int *a) __attribute__((nonnull(1), // \
79 // expected-warning {{GCC does not allow 'nonnull' attribute in this position on a function definition}}
80 pure)) { // \
81 // expected-warning {{GCC does not allow 'pure' attribute in this position on a function definition}}
82 return *a;
83 }
84
85 int testFundef4(int *a) __attribute__((nonnull(1))) // \
86 // expected-warning {{GCC does not allow 'nonnull' attribute in this position on a function definition}}
87 __attribute((pure)) { // \
88 // expected-warning {{GCC does not allow 'pure' attribute in this position on a function definition}}
89 return *a;
90 }
91
92 // GCC allows these
93 void testFundef5() __attribute__(()) { }
94
95 __attribute__((pure)) int testFundef6(int a) { return a; }
96
97 void deprecatedTestFun(void) __attribute__((deprecated()));
98
99 struct s {
100 int a;
101 };
102
103 // This test ensure compatibility with parsing GNU-style attributes
104 // where the attribute is on a separate line from the elaborated type
105 // specifier.
106 struct s
107 __attribute__((used)) bar;
108