attributes.c revision aab740af64daaa8d94d34789a6ea7e2d2fc5ab39
1// RUN: clang -fsyntax-only -verify %s -pedantic -std=c99
2
3int __attribute__(()) x;  // expected-warning {{extension used}}
4
5// Hide __attribute__ behind a macro, to silence extension warnings about
6// "__attribute__ being an extension".
7#define attribute __attribute__
8
9__inline void attribute((__always_inline__, __nodebug__))
10foo(void) {
11}
12
13
14attribute(()) y;   // expected-warning {{defaults to 'int'}}
15
16// PR2796
17int (attribute(()) *z)(long y);
18
19
20void f1(attribute(()) int x);
21
22int f2(y, attribute(()) x);     // expected-error {{expected identifier}}
23
24// This is parsed as a normal argument list (with two args that are implicit
25// int) because the attribute is a declspec.
26void f3(attribute(()) x,  // expected-warning {{defaults to 'int'}}
27        y);               // expected-warning {{defaults to 'int'}}
28
29void f4(attribute(()));   // expected-error {{expected parameter declarator}}
30
31
32// This is ok, the attribute applies to the pointer.
33int baz(int (attribute(()) *x)(long y));
34
35void g1(void (*f1)(attribute(()) int x));
36void g2(int (*f2)(y, attribute(()) x));    // expected-error {{expected identifier}}
37void g3(void (*f3)(attribute(()) x, int y));  // expected-warning {{defaults to 'int'}}
38void g4(void (*f4)(attribute(())));  // expected-error {{expected parameter declarator}}
39
40
41void (*h1)(void (*f1)(attribute(()) int x));
42void (*h2)(int (*f2)(y, attribute(()) x));    // expected-error {{expected identifier}}
43
44void (*h3)(void (*f3)(attribute(()) x));   // expected-warning {{defaults to 'int'}}
45void (*h4)(void (*f4)(attribute(())));  // expected-error {{expected parameter declarator}}
46
47
48
49// rdar://6131260
50int foo42(void) {
51  int x, attribute((unused)) y, z;
52  return 0;
53}
54
55// rdar://6096491
56void attribute((noreturn)) d0(void), attribute((noreturn)) d1(void);
57
58