OSDN Git Service

initial commit
[openbsd-octeon/openbsd-octeon.git] / src / regress / usr.bin / xlint / test-11.c
1 /*      $OpenBSD: test-11.c,v 1.3 2007/10/08 08:18:35 gilles Exp $      */
2
3 /*
4  * Placed in the public domain by Chad Loder <cloder@openbsd.org>.
5  *
6  * Test lint parsing of gcc's __attribute__ syntax.
7  */
8
9 /* Define this here so we don't need to pull in a header */
10 void exit(int);
11
12 /*
13  * A function prototype with a single attribute before.
14  */
15 __attribute__((__noreturn__)) void foo1(void);
16
17 /*
18  * A function prototype with a multiple attributes before.
19  */
20 __attribute__((__noreturn__))
21 __attribute__((__pure__))
22 __attribute__((__section__("text")))
23 void foo2(void);
24
25 /*
26  * A function prototype with a single attribute after.
27  */
28 void foo3(void) __attribute__((__noreturn__));
29
30 /*
31  * A function prototype with multiple attributes after.
32  */
33 void foo4(void)
34         __attribute__((__noreturn__))
35         __attribute__((__pure__))
36         __attribute__((__section__("text")));
37
38 /*
39  * A function prototype with multiple attributes after,
40  * one of which (volatile) is stupidly also a C keyword.
41  */
42 __attribute__((__noreturn__)) void foo5(const char *, ...)
43         __attribute__((volatile, __format__ (printf, 1, 2)));
44
45 /*
46  * A function prototype with unnamed parameters having attributes.
47  */
48 void foo6(char[], int __attribute__((unused)));
49
50 /*
51  * A function prototype with named parameters having attributes.
52  */
53 void foo7(char func[], int i __attribute__((unused)));
54
55 /*
56  * A function definition with a single attribute before.
57  */
58 __attribute__((__noreturn__)) void
59 foo8(void)
60 {
61         exit(0);
62 }
63
64 /*
65  * A function definition with multiple attributes before.
66  */
67 __attribute__((__noreturn__))
68 __attribute__((__pure__))
69 __attribute__((__section__("text")))
70 void
71 foo9(void)
72 {
73         exit(0);
74 }
75
76 /*
77  * A struct type having members with attributes.
78  */
79 typedef
80 struct mystruct {
81         unsigned char   c_data[128]     __packed;
82         unsigned int    u_data[128]     __packed;
83 } mystruct_t;
84
85
86 /*
87  * A struct with attributes.
88  */
89 struct mystruct2 {
90         unsigned char   c_data[128];
91 } __packed;
92
93 /*
94  * A typedef with an attribute after the typename.
95  */
96 typedef int more_aligned_int __attribute__ ((aligned (8)));
97
98 /*
99  * A typedef with attributes before the typename.
100  */
101 typedef short __attribute__((__may_alias__)) short_a;
102
103
104 /*
105  * A variable declaration with attributes.
106  */
107 int sh __attribute__((__section__ ("shared")));
108
109 /*
110  * A variable declaration with attributes and initializer.
111  */
112 int sh2 __attribute__((__section__ ("shared"))) = 0;
113
114 /*
115  * A simple indirection: "pointer to 8-bit aligned pointer to char"
116  */
117 char * __attribute__((__aligned__(8))) *pac;
118
119 /*
120  * A really tough one with multiple indirections that even older
121  * gcc has problems with.
122  */
123 void (****f)(void) __attribute__((__noreturn__));
124
125 int
126 main(int argc, char* argv[])
127 {
128         return 0;
129 }
130
131
132
133
134