summaryrefslogtreecommitdiff
path: root/regress/usr.bin/xlint/test-11.c
blob: 1df0073680da4de9d57dad71f704f61cbabcc593 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
/*      $OpenBSD: test-11.c,v 1.3 2007/10/08 08:18:35 gilles Exp $	*/

/*
 * Placed in the public domain by Chad Loder <cloder@openbsd.org>.
 *
 * Test lint parsing of gcc's __attribute__ syntax.
 */

/* Define this here so we don't need to pull in a header */
void exit(int);

/*
 * A function prototype with a single attribute before.
 */
__attribute__((__noreturn__)) void foo1(void);

/*
 * A function prototype with a multiple attributes before.
 */
__attribute__((__noreturn__))
__attribute__((__pure__))
__attribute__((__section__("text")))
void foo2(void);

/*
 * A function prototype with a single attribute after.
 */
void foo3(void) __attribute__((__noreturn__));

/*
 * A function prototype with multiple attributes after.
 */
void foo4(void)
	__attribute__((__noreturn__))
	__attribute__((__pure__))
	__attribute__((__section__("text")));

/*
 * A function prototype with multiple attributes after,
 * one of which (volatile) is stupidly also a C keyword.
 */
__attribute__((__noreturn__)) void foo5(const char *, ...)
	__attribute__((volatile, __format__ (printf, 1, 2)));

/*
 * A function prototype with unnamed parameters having attributes.
 */
void foo6(char[], int __attribute__((unused)));

/*
 * A function prototype with named parameters having attributes.
 */
void foo7(char func[], int i __attribute__((unused)));

/*
 * A function definition with a single attribute before.
 */
__attribute__((__noreturn__)) void
foo8(void)
{
	exit(0);
}

/*
 * A function definition with multiple attributes before.
 */
__attribute__((__noreturn__))
__attribute__((__pure__))
__attribute__((__section__("text")))
void
foo9(void)
{
	exit(0);
}

/*
 * A struct type having members with attributes.
 */
typedef
struct mystruct {
	unsigned char	c_data[128]	__packed;
	unsigned int	u_data[128]	__packed;
} mystruct_t;


/*
 * A struct with attributes.
 */
struct mystruct2 {
	unsigned char	c_data[128];
} __packed;

/*
 * A typedef with an attribute after the typename.
 */
typedef int more_aligned_int __attribute__ ((aligned (8)));

/*
 * A typedef with attributes before the typename.
 */
typedef short __attribute__((__may_alias__)) short_a;


/*
 * A variable declaration with attributes.
 */
int sh __attribute__((__section__ ("shared")));

/*
 * A variable declaration with attributes and initializer.
 */
int sh2 __attribute__((__section__ ("shared"))) = 0;

/*
 * A simple indirection: "pointer to 8-bit aligned pointer to char"
 */
char * __attribute__((__aligned__(8))) *pac;

/*
 * A really tough one with multiple indirections that even older
 * gcc has problems with.
 */
void (****f)(void) __attribute__((__noreturn__));

int
main(int argc, char* argv[])
{
	return 0;
}