opt_ldi.c revision 1.4
1/* $NetBSD: opt_ldi.c,v 1.4 2022/04/22 21:21:20 rillig Exp $ */ 2 3/* 4 * Tests for the option '-ldi', which specifies where the variable names of 5 * locally declared variables are placed. 6 * 7 * See also: 8 * opt_di.c 9 */ 10 11#indent input 12int global; 13 14void 15function(void) 16{ 17 int local; 18} 19#indent end 20 21#indent run -ldi0 22int global; 23 24void 25function(void) 26{ 27 int local; 28} 29#indent end 30 31#indent run -ldi8 32int global; 33 34void 35function(void) 36{ 37 int local; 38} 39#indent end 40 41#indent run -ldi24 42int global; 43 44void 45function(void) 46{ 47 int local; 48} 49#indent end 50 51 52/* 53 * A variable that has an ad-hoc struct/union/enum type does not need to be 54 * indented to the right of the keyword 'struct', it only needs a single space 55 * of indentation. 56 * 57 * Before NetBSD indent.c 1.151 from 2021-10-24, the indentation depended on 58 * the length of the keyword 'struct', 'union' or 'enum', together with type 59 * qualifiers like 'const' or the storage class like 'static'. 60 */ 61#indent input 62{ 63 struct { 64 int member; 65 } var = { 66 3, 67 }; 68} 69#indent end 70 71/* 72 * Struct members use '-di' for indentation, no matter whether they are 73 * declared globally or locally. 74 */ 75#indent run -ldi0 76{ 77 struct { 78 int member; 79 } var = { 80 3, 81 }; 82} 83#indent end 84 85#indent run -ldi16 86{ 87 struct { 88 int member; 89 } var = { 90 3, 91 }; 92} 93#indent end 94