1 /* $OpenBSD: test-11.c,v 1.3 2007/10/08 08:18:35 gilles Exp $ */
4 * Placed in the public domain by Chad Loder <cloder@openbsd.org>.
6 * Test lint parsing of gcc's __attribute__ syntax.
9 /* Define this here so we don't need to pull in a header */
13 * A function prototype with a single attribute before.
15 __attribute__((__noreturn__)) void foo1(void);
18 * A function prototype with a multiple attributes before.
20 __attribute__((__noreturn__))
21 __attribute__((__pure__))
22 __attribute__((__section__("text")))
26 * A function prototype with a single attribute after.
28 void foo3(void) __attribute__((__noreturn__));
31 * A function prototype with multiple attributes after.
34 __attribute__((__noreturn__))
35 __attribute__((__pure__))
36 __attribute__((__section__("text")));
39 * A function prototype with multiple attributes after,
40 * one of which (volatile) is stupidly also a C keyword.
42 __attribute__((__noreturn__)) void foo5(const char *, ...)
43 __attribute__((volatile, __format__ (printf, 1, 2)));
46 * A function prototype with unnamed parameters having attributes.
48 void foo6(char[], int __attribute__((unused)));
51 * A function prototype with named parameters having attributes.
53 void foo7(char func[], int i __attribute__((unused)));
56 * A function definition with a single attribute before.
58 __attribute__((__noreturn__)) void
65 * A function definition with multiple attributes before.
67 __attribute__((__noreturn__))
68 __attribute__((__pure__))
69 __attribute__((__section__("text")))
77 * A struct type having members with attributes.
81 unsigned char c_data[128] __packed;
82 unsigned int u_data[128] __packed;
87 * A struct with attributes.
90 unsigned char c_data[128];
94 * A typedef with an attribute after the typename.
96 typedef int more_aligned_int __attribute__ ((aligned (8)));
99 * A typedef with attributes before the typename.
101 typedef short __attribute__((__may_alias__)) short_a;
105 * A variable declaration with attributes.
107 int sh __attribute__((__section__ ("shared")));
110 * A variable declaration with attributes and initializer.
112 int sh2 __attribute__((__section__ ("shared"))) = 0;
115 * A simple indirection: "pointer to 8-bit aligned pointer to char"
117 char * __attribute__((__aligned__(8))) *pac;
120 * A really tough one with multiple indirections that even older
121 * gcc has problems with.
123 void (****f)(void) __attribute__((__noreturn__));
126 main(int argc, char* argv[])