1// RUN: %clang_cc1 -fsyntax-only -verify %s -pedantic -std=c99 2 3int __attribute__(()) x; 4 5__inline void __attribute__((__always_inline__, __nodebug__)) 6foo(void) { 7} 8 9 10__attribute__(()) y; // expected-warning {{defaults to 'int'}} 11 12// PR2796 13int (__attribute__(()) *z)(long y); 14 15 16void f1(__attribute__(()) int x); 17 18int 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. 22void f3(__attribute__(()) x, // expected-warning {{defaults to 'int'}} 23 y); // expected-warning {{defaults to 'int'}} 24 25void f4(__attribute__(())); // expected-error {{expected parameter declarator}} 26 27 28// This is ok, the __attribute__ applies to the pointer. 29int baz(int (__attribute__(()) *x)(long y)); 30 31void 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}} 35 36 37void (*h1)(void (*f1)(__attribute__(()) int x)); 38void (*h2)(int (*f2)(y, __attribute__(()) x)); // expected-error {{expected identifier}} 39 40void (*h3)(void (*f3)(__attribute__(()) x)); // expected-warning {{defaults to 'int'}} 41void (*h4)(void (*f4)(__attribute__(()))); // expected-error {{expected parameter declarator}} 42 43 44 45// rdar://6131260 46int foo42(void) { 47 int x, __attribute__((unused)) y, z; 48 return 0; 49} 50 51// rdar://6096491 52void __attribute__((noreturn)) d0(void), __attribute__((noreturn)) d1(void); 53 54void d2(void) __attribute__((noreturn)), d3(void) __attribute__((noreturn)); 55 56 57// PR6287 58void __attribute__((returns_twice)) returns_twice_test(); 59 60int aligned(int); 61int __attribute__((vec_type_hint(char, aligned(16) )) missing_rparen_1; // expected-error 2{{expected ')'}} expected-note {{to match}} expected-warning {{does not declare anything}} 62int __attribute__((mode(x aligned(16) )) missing_rparen_2; // expected-error {{expected ')'}} 63int __attribute__((format(printf, 0 aligned(16) )) missing_rparen_3; // expected-error {{expected ')'}} 64 65 66 67int 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 73void testFundef2() __attribute__((noreturn)) { // \ 74 // expected-warning {{GCC does not allow 'noreturn' attribute in this position on a function definition}} 75 testFundef2(); 76} 77 78int 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 85int 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 93void testFundef5() __attribute__(()) { } 94 95__attribute__((pure)) int testFundef6(int a) { return a; } 96 97void deprecatedTestFun(void) __attribute__((deprecated())); 98 99struct 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. 106struct s 107__attribute__((used)) bar; 108