c11.c revision 1.3
1/*	$NetBSD: c11.c,v 1.3 2023/07/13 20:30:21 rillig Exp $	*/
2# 3 "c11.c"
3
4/*
5 * Test the language level C11, which adds _Generic expressions, _Noreturn
6 * functions, anonymous struct/union members, and several more.
7 */
8
9/* lint1-flags: -Ac11 -w -X 236 -X 351 */
10
11_Noreturn void exit(int);
12void _Noreturn exit(int);
13
14_Noreturn void
15noreturn_before_type(void)
16{
17	exit(0);
18}
19
20void _Noreturn
21noreturn_after_type(void)
22{
23	exit(0);
24}
25
26static _Noreturn void
27noreturn_after_storage_class(void)
28{
29	exit(0);
30}
31
32_Noreturn static void
33noreturn_before_storage_class(void)
34{
35	exit(0);
36}
37
38/* C11 6.7.4p5: A function specifier may appear more than once. */
39_Noreturn _Noreturn _Noreturn void
40three_times(void)
41{
42	exit(0);
43}
44
45// In C11 mode, 'thread_local' is not yet known, but '_Thread_local' is.
46/* expect+2: error: old-style declaration; add 'int' [1] */
47/* expect+1: error: syntax error 'int' [249] */
48thread_local int thread_local_variable_c23;
49_Thread_local int thread_local_variable_c11;
50
51/* The '_Noreturn' must not appear after the declarator. */
52void _Noreturn exit(int) _Noreturn;
53/* expect-1: error: formal parameter #1 lacks name [59] */
54/* expect-2: warning: empty declaration [2] */
55/* expect+2: error: syntax error '' [249] */
56/* expect+1: error: cannot recover from previous errors [224] */
57