1 1.6 rillig /* $NetBSD: d_gcc_compound_statements2.c,v 1.6 2023/07/07 19:45:22 rillig Exp $ */ 2 1.2 rillig # 3 "d_gcc_compound_statements2.c" 3 1.2 rillig 4 1.5 rillig /* 5 1.5 rillig * GCC statement expressions with non-expressions. 6 1.5 rillig * 7 1.5 rillig * https://gcc.gnu.org/onlinedocs/gcc/Statement-Exprs.html 8 1.5 rillig */ 9 1.5 rillig 10 1.6 rillig /* lint1-extra-flags: -X 351 */ 11 1.6 rillig 12 1.1 jruoho struct cpu_info { 13 1.1 jruoho int bar; 14 1.1 jruoho }; 15 1.1 jruoho 16 1.1 jruoho int 17 1.5 rillig statement_expr_with_decl_and_stmt(void) 18 1.1 jruoho { 19 1.1 jruoho return ({ 20 1.3 rillig struct cpu_info *ci; 21 1.3 rillig __asm__ volatile("movl %%fs:4,%0":"=r" (ci)); 22 1.3 rillig ci; 23 1.1 jruoho })->bar; 24 1.1 jruoho } 25 1.3 rillig 26 1.3 rillig int 27 1.5 rillig statement_expr_with_only_stmt(void) 28 1.3 rillig { 29 1.3 rillig struct cpu_info ci = { 0 }; 30 1.3 rillig return ({ 31 1.4 rillig if (ci.bar > 0) 32 1.4 rillig ci.bar++; 33 1.4 rillig ci; 34 1.3 rillig }).bar; 35 1.3 rillig } 36 1.5 rillig 37 1.5 rillig /* 38 1.5 rillig * Since main1.c 1.58 from 2021-12-17 and before tree.c 1.404 from 39 1.5 rillig * 2022-02-26, lint ran into an assertion failure due to a use-after-free. 40 1.5 rillig * When typeok checked the operand types of the '=', the left node and the 41 1.5 rillig * right node overlapped by 16 out of their 40 bytes on x86_64. 42 1.5 rillig */ 43 1.5 rillig void 44 1.5 rillig statement_expr_with_loop(unsigned u) 45 1.5 rillig { 46 1.5 rillig u = ({ 47 1.5 rillig do { 48 1.5 rillig } while (0); 49 1.5 rillig u; 50 1.5 rillig }); 51 1.5 rillig } 52