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