blob: d7fc35d92b3a483df5a427635c2ad4aa7555fe2d [file] [log] [blame]
Chris Lattner7399ee02008-10-20 02:05:46 +00001// RUN: clang -fsyntax-only -verify %s -pedantic -std=c99
Reid Spencer5f016e22007-07-11 17:01:13 +00002
Chris Lattner7399ee02008-10-20 02:05:46 +00003int __attribute__(()) x; // expected-warning {{extension used}}
4
5// Hide __attribute__ behind a macro, to silence extension warnings about
6// "__attribute__ being an extension".
7#define attribute __attribute__
8
9__inline void attribute((__always_inline__, __nodebug__))
10foo(void) {
Reid Spencer5f016e22007-07-11 17:01:13 +000011}
Chris Lattner7399ee02008-10-20 02:05:46 +000012
13
14attribute(()) y; // expected-warning {{defaults to 'int'}}
15
16// PR2796
17int (attribute(()) *z)(long y);
18
19
20void f1(attribute(()) int x);
21
22int f2(y, attribute(()) x); // expected-error {{expected identifier}}
23
24// This is parsed as a normal argument list (with two args that are implicit
25// int) because the attribute is a declspec.
26void f3(attribute(()) x, // expected-warning {{defaults to 'int'}}
27 y); // expected-warning {{defaults to 'int'}}
28
29void f4(attribute(())); // expected-error {{expected parameter declarator}}
30
31
32// This is ok, the attribute applies to the pointer.
33int baz(int (attribute(()) *x)(long y));
34
35void g1(void (*f1)(attribute(()) int x));
36void g2(int (*f2)(y, attribute(()) x)); // expected-error {{expected identifier}}
37void g3(void (*f3)(attribute(()) x, int y)); // expected-warning {{defaults to 'int'}}
38void g4(void (*f4)(attribute(()))); // expected-error {{expected parameter declarator}}
39
40
41void (*h1)(void (*f1)(attribute(()) int x));
42void (*h2)(int (*f2)(y, attribute(()) x)); // expected-error {{expected identifier}}
43
44void (*h3)(void (*f3)(attribute(()) x)); // expected-warning {{defaults to 'int'}}
45void (*h4)(void (*f4)(attribute(()))); // expected-error {{expected parameter declarator}}
Chris Lattneraab740a2008-10-20 04:57:38 +000046
47
48
49// rdar://6131260
50int foo42(void) {
51 int x, attribute((unused)) y, z;
52 return 0;
53}
54
55// rdar://6096491
56void attribute((noreturn)) d0(void), attribute((noreturn)) d1(void);
57