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