blob: dc2bb02670c63a3beca411dd35cc466973838098 [file] [log] [blame]
Daniel Dunbard7d5f022009-03-24 02:24:46 +00001// RUN: clang-cc -fsyntax-only -verify %s -pedantic -std=c99
Reid Spencer5f016e22007-07-11 17:01:13 +00002
Eli Friedmaneb32fde2009-04-28 03:13:54 +00003int __attribute__(()) x;
Chris Lattner7399ee02008-10-20 02:05:46 +00004
Eli Friedmaneb32fde2009-04-28 03:13:54 +00005__inline void __attribute__((__always_inline__, __nodebug__))
Chris Lattner7399ee02008-10-20 02:05:46 +00006foo(void) {
Reid Spencer5f016e22007-07-11 17:01:13 +00007}
Chris Lattner7399ee02008-10-20 02:05:46 +00008
9
Eli Friedmaneb32fde2009-04-28 03:13:54 +000010__attribute__(()) y; // expected-warning {{defaults to 'int'}}
Chris Lattner7399ee02008-10-20 02:05:46 +000011
12// PR2796
Eli Friedmaneb32fde2009-04-28 03:13:54 +000013int (__attribute__(()) *z)(long y);
Chris Lattner7399ee02008-10-20 02:05:46 +000014
15
Eli Friedmaneb32fde2009-04-28 03:13:54 +000016void f1(__attribute__(()) int x);
Chris Lattner7399ee02008-10-20 02:05:46 +000017
Eli Friedmaneb32fde2009-04-28 03:13:54 +000018int f2(y, __attribute__(()) x); // expected-error {{expected identifier}}
Chris Lattner7399ee02008-10-20 02:05:46 +000019
20// This is parsed as a normal argument list (with two args that are implicit
Eli Friedmaneb32fde2009-04-28 03:13:54 +000021// int) because the __attribute__ is a declspec.
22void f3(__attribute__(()) x, // expected-warning {{defaults to 'int'}}
Chris Lattner7399ee02008-10-20 02:05:46 +000023 y); // expected-warning {{defaults to 'int'}}
24
Eli Friedmaneb32fde2009-04-28 03:13:54 +000025void f4(__attribute__(())); // expected-error {{expected parameter declarator}}
Chris Lattner7399ee02008-10-20 02:05:46 +000026
27
Eli Friedmaneb32fde2009-04-28 03:13:54 +000028// This is ok, the __attribute__ applies to the pointer.
29int baz(int (__attribute__(()) *x)(long y));
Chris Lattner7399ee02008-10-20 02:05:46 +000030
Eli Friedmaneb32fde2009-04-28 03:13:54 +000031void g1(void (*f1)(__attribute__(()) int x));
32void g2(int (*f2)(y, __attribute__(()) x)); // expected-error {{expected identifier}}
33void g3(void (*f3)(__attribute__(()) x, int y)); // expected-warning {{defaults to 'int'}}
34void g4(void (*f4)(__attribute__(()))); // expected-error {{expected parameter declarator}}
Chris Lattner7399ee02008-10-20 02:05:46 +000035
36
Eli Friedmaneb32fde2009-04-28 03:13:54 +000037void (*h1)(void (*f1)(__attribute__(()) int x));
38void (*h2)(int (*f2)(y, __attribute__(()) x)); // expected-error {{expected identifier}}
Chris Lattner7399ee02008-10-20 02:05:46 +000039
Eli Friedmaneb32fde2009-04-28 03:13:54 +000040void (*h3)(void (*f3)(__attribute__(()) x)); // expected-warning {{defaults to 'int'}}
41void (*h4)(void (*f4)(__attribute__(()))); // expected-error {{expected parameter declarator}}
Chris Lattneraab740a2008-10-20 04:57:38 +000042
43
44
45// rdar://6131260
46int foo42(void) {
Eli Friedmaneb32fde2009-04-28 03:13:54 +000047 int x, __attribute__((unused)) y, z;
Chris Lattneraab740a2008-10-20 04:57:38 +000048 return 0;
49}
50
51// rdar://6096491
Eli Friedmaneb32fde2009-04-28 03:13:54 +000052void __attribute__((noreturn)) d0(void), __attribute__((noreturn)) d1(void);
Chris Lattneraab740a2008-10-20 04:57:38 +000053