1 /* $NetBSD: fmt_block.c,v 1.2 2021/11/19 22:24:29 rillig Exp $ */ 2 /* $FreeBSD$ */ 3 4 /* 5 * Tests for formatting blocks of statements and declarations. 6 * 7 * See also: 8 * lsym_lbrace.c 9 * psym_stmt.c 10 * psym_stmt_list.c 11 */ 12 13 #indent input 14 void 15 function(void) 16 { 17 if (true) { 18 19 } 20 21 { 22 print("block"); 23 } 24 } 25 #indent end 26 27 #indent run 28 void 29 function(void) 30 { 31 if (true) { 32 33 /* $ FIXME: indent must not merge these braces. */ 34 } { 35 /* $ FIXME: the following empty line was not in the input. */ 36 37 print("block"); 38 } 39 } 40 #indent end 41 42 43 /* 44 * Two adjacent blocks must not be merged. They are typically used in C90 and 45 * earlier to declare local variables with a limited scope. 46 */ 47 #indent input 48 void 49 function(void) 50 { 51 {}{} 52 } 53 #indent end 54 55 #indent run 56 void 57 function(void) 58 { 59 { 60 /* $ FIXME: '{' must start a new line. */ 61 } { 62 } 63 } 64 #indent end 65 66 /* 67 * The buggy behavior only occurs with the default setting '-br', which 68 * places an opening brace to the right of the preceding 'if (expr)' or 69 * similar statements. 70 */ 71 #indent run -bl 72 void 73 function(void) 74 { 75 { 76 } 77 { 78 } 79 } 80 #indent end 81