summaryrefslogtreecommitdiff
path: root/tests/usr.bin/xlint/lint1/gcc_attribute_enum.c
blob: 66d43dd075dd1374a55b377837fe81bf483e7ddf (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
/*	$NetBSD: gcc_attribute_enum.c,v 1.5 2022/06/17 18:54:53 rillig Exp $	*/
# 3 "gcc_attribute_enum.c"

/*
 * Tests for the GCC __attribute__ for enumerators.
 *
 * https://gcc.gnu.org/onlinedocs/gcc/Enumerator-Attributes.html
 */

/*
 * Attributes in enum-specifier.
 *
 * See GCC, c-parser.c, function c_parser_enum_specifier.
 */

enum __attribute__(()) tag;

enum __attribute__(()) tag_with_declaration {
	TAG_WITH_DECL
} __attribute__(());

enum __attribute__(()) {
	ONLY_DECL
} __attribute__(());

/*
 * Attributes in enumerator.
 *
 * See GCC, c-parser.c, function c_parser_enum_specifier.
 */

enum without_initializer {
	NO_INIT_FIRST __attribute__(()),
	NO_INIT_LAST __attribute__(())
};

enum with_initializer {
	INIT_FIRST __attribute__(()) = 1,
	INIT_LAST __attribute__(()) = 2,
	/* expect+1: error: syntax error '__attribute__' [249] */
	INIT_WRONG = 3 __attribute__(()),
};

enum tag {
	TAG
};