lsym_return.c revision 1.3
1175309Sdas/* $NetBSD: lsym_return.c,v 1.3 2022/04/22 21:21:20 rillig Exp $ */ 2175309Sdas 3175309Sdas/* 4175309Sdas * Tests for the token lsym_return, which represents the keyword 'return' that 5175309Sdas * starts a 'return' statement for leaving the execution of a function. 6175309Sdas */ 7175309Sdas 8175309Sdas/* 9175309Sdas * Return statements having a single-line expression are simple to format. 10 * Since 'return' is not a function name, there is a space between the 11 * 'return' and the '('. 12 */ 13#indent input 14void 15function(bool cond) 16{ 17 if (cond) 18 return; 19} 20 21int 22calculate(int a, int b) 23{ 24 return a; 25 return (b); 26 return (((a))) + b; 27 return calculate(b, a); 28} 29#indent end 30 31#indent run-equals-input 32 33 34/* 35 * Returning complex expressions may spread the expression over several lines. 36 * The exact formatting depends on the option '-lp'. 37 */ 38#indent input 39int 40multi_line(int a) 41{ 42 return calculate(3, 43 4); 44 return calculate( 45 3, 46 4); 47 return calculate( 48 3, 49 4 50 ); 51} 52#indent end 53 54#indent run-equals-input 55 56#indent run -nlp 57int 58multi_line(int a) 59{ 60 return calculate(3, 61 4); 62 return calculate( 63 3, 64 4); 65 return calculate( 66 3, 67 4 68 ); 69} 70#indent end 71