gcc_attribute_stmt.c revision 1.1
1/*	$NetBSD: gcc_attribute_stmt.c,v 1.1 2021/07/06 17:33:07 rillig Exp $	*/
2# 3 "gcc_attribute_stmt.c"
3
4/*
5 * Tests for the GCC __attribute__ for statements.
6 *
7 * https://gcc.gnu.org/onlinedocs/gcc/Statement-Attributes.html
8 */
9
10void println(const char *);
11
12void
13attribute_fallthrough(int i)
14{
15	switch (i) {
16	case 5:
17		/*
18		 * The attribute 'fallthrough' is only valid after a
19		 * preceding statement. This is already caught by GCC, so
20		 * lint does not need to care.
21		 */
22		__attribute__((__fallthrough__));
23	case 3:
24		println("odd");
25		__attribute__((__fallthrough__));
26	case 2:
27		/*
28		 * Only the null statement can have the attribute
29		 * 'fallthrough'. This is already caught by GCC, so
30		 * lint does not need to care.
31		 */
32		/* expect+2: error: syntax error '__attribute__' [249] */
33		println("prime")
34		    __attribute__((__fallthrough__));
35	}
36}
37