gcc_statement_expression.c revision 1.3
11.3Srillig/* $NetBSD: gcc_statement_expression.c,v 1.3 2023/07/15 14:54:31 rillig Exp $ */ 21.1Srillig# 3 "gcc_statement_expression.c" 31.1Srillig 41.1Srillig/* 51.1Srillig * Tests for the GCC extension 'statement expressions', which allows a block of 61.1Srillig * statements to occur as part of an expression. 71.1Srillig */ 81.1Srillig 91.1Srillig 101.1Srillig// Ensure that the inner types are accessible from outside the block. 111.1Srillig// Depending on the memory management strategy, the inner types might be freed 121.1Srillig// too early. 131.1Srilligstatic inline int 141.1Srilliguse_inner_type_from_outside(void) 151.1Srillig{ 161.1Srillig int x = ({ 171.1Srillig struct outer { 181.1Srillig struct inner { 191.1Srillig int member; 201.1Srillig } inner; 211.1Srillig } outer = { { 3 } }; 221.2Srillig outer; 231.2Srillig }).inner.member; 241.2Srillig 251.1Srillig return x; 261.1Srillig} 27