1 /* $NetBSD: psym_switch_expr.c,v 1.2 2021/11/20 16:54:17 rillig Exp $ */ 2 /* $FreeBSD$ */ 3 4 /* 5 * Tests for the parser symbol psym_switch_expr, which represents the keyword 6 * 'switch' followed by the controlling expression, now waiting for a 7 * statement (usually a block) containing the 'case' labels. 8 */ 9 10 #indent input 11 // TODO: add input 12 #indent end 13 14 #indent run-equals-input 15 16 17 /* 18 * In all practical cases, a 'switch (expr)' is followed by a block, but the 19 * C syntax allows an arbitrary statement. Unless such a statement has a 20 * label, it is unreachable. 21 */ 22 #indent input 23 void 24 function(void) 25 { 26 switch (expr) 27 if (cond) { 28 case 1: return; 29 case 2: break; 30 } 31 } 32 #indent end 33 34 #indent run 35 void 36 function(void) 37 { 38 switch (expr) 39 if (cond) { 40 case 1: 41 return; 42 case 2: 43 break; 44 } 45 } 46 #indent end 47