blob: b2873638cdba8cf0617bb531a620f6aef0fd6531 [file] [log] [blame]
Daniel Dunbar8fbe78f2009-12-15 20:14:24 +00001// RUN: %clang_cc1 -fsyntax-only -verify %s -pedantic -std=c99
Chris Lattner43ec2ce2006-10-17 03:00:45 +00002
Eli Friedman2b680b42009-04-28 03:13:54 +00003int __attribute__(()) x;
Chris Lattner8ff2c6c2008-10-20 02:05:46 +00004
Eli Friedman2b680b42009-04-28 03:13:54 +00005__inline void __attribute__((__always_inline__, __nodebug__))
Chris Lattner8ff2c6c2008-10-20 02:05:46 +00006foo(void) {
Chris Lattner43ec2ce2006-10-17 03:00:45 +00007}
Chris Lattner8ff2c6c2008-10-20 02:05:46 +00008
9
Eli Friedman2b680b42009-04-28 03:13:54 +000010__attribute__(()) y; // expected-warning {{defaults to 'int'}}
Chris Lattner8ff2c6c2008-10-20 02:05:46 +000011
12// PR2796
Eli Friedman2b680b42009-04-28 03:13:54 +000013int (__attribute__(()) *z)(long y);
Chris Lattner8ff2c6c2008-10-20 02:05:46 +000014
15
Eli Friedman2b680b42009-04-28 03:13:54 +000016void f1(__attribute__(()) int x);
Chris Lattner8ff2c6c2008-10-20 02:05:46 +000017
Eli Friedman2b680b42009-04-28 03:13:54 +000018int f2(y, __attribute__(()) x); // expected-error {{expected identifier}}
Chris Lattner8ff2c6c2008-10-20 02:05:46 +000019
20// This is parsed as a normal argument list (with two args that are implicit
Eli Friedman2b680b42009-04-28 03:13:54 +000021// int) because the __attribute__ is a declspec.
22void f3(__attribute__(()) x, // expected-warning {{defaults to 'int'}}
Chris Lattner8ff2c6c2008-10-20 02:05:46 +000023 y); // expected-warning {{defaults to 'int'}}
24
Eli Friedman2b680b42009-04-28 03:13:54 +000025void f4(__attribute__(())); // expected-error {{expected parameter declarator}}
Chris Lattner8ff2c6c2008-10-20 02:05:46 +000026
27
Eli Friedman2b680b42009-04-28 03:13:54 +000028// This is ok, the __attribute__ applies to the pointer.
29int baz(int (__attribute__(()) *x)(long y));
Chris Lattner8ff2c6c2008-10-20 02:05:46 +000030
Eli Friedman2b680b42009-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 Lattner8ff2c6c2008-10-20 02:05:46 +000035
36
Eli Friedman2b680b42009-04-28 03:13:54 +000037void (*h1)(void (*f1)(__attribute__(()) int x));
38void (*h2)(int (*f2)(y, __attribute__(()) x)); // expected-error {{expected identifier}}
Chris Lattner8ff2c6c2008-10-20 02:05:46 +000039
Eli Friedman2b680b42009-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 Lattner29e6f2b2008-10-20 04:57:38 +000042
43
44
45// rdar://6131260
46int foo42(void) {
Eli Friedman2b680b42009-04-28 03:13:54 +000047 int x, __attribute__((unused)) y, z;
Chris Lattner29e6f2b2008-10-20 04:57:38 +000048 return 0;
49}
50
51// rdar://6096491
Eli Friedman2b680b42009-04-28 03:13:54 +000052void __attribute__((noreturn)) d0(void), __attribute__((noreturn)) d1(void);
Chris Lattner29e6f2b2008-10-20 04:57:38 +000053
John Thompson5bc5cbe2009-11-25 22:58:06 +000054void d2(void) __attribute__((noreturn)), d3(void) __attribute__((noreturn));
Chris Lattner37c75af2010-04-12 02:18:38 +000055
56
57// PR6287
58void __attribute__((returns_twice)) returns_twice_test();