xref: /netbsd-src/tests/usr.bin/xlint/lint1/gcc_statement_expression.c (revision 865c57e0098351fba0d2d2a97b33e7e0270e62c6)
1 /*	$NetBSD: gcc_statement_expression.c,v 1.3 2023/07/15 14:54:31 rillig Exp $	*/
2 # 3 "gcc_statement_expression.c"
3 
4 /*
5  * Tests for the GCC extension 'statement expressions', which allows a block of
6  * statements to occur as part of an expression.
7  */
8 
9 
10 // Ensure that the inner types are accessible from outside the block.
11 // Depending on the memory management strategy, the inner types might be freed
12 // too early.
13 static inline int
14 use_inner_type_from_outside(void)
15 {
16 	int x = ({
17 		struct outer {
18 			struct inner {
19 				int member;
20 			} inner;
21 		} outer = { { 3 } };
22 		outer;
23 	}).inner.member;
24 
25 	return x;
26 }
27