attributes.c revision a5728872c7702ddd09537c95bc3cbd20e1f2fb09
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