1 /* $NetBSD: opt_pcs.c,v 1.18 2023/06/16 23:07:52 rillig Exp $ */ 2 3 /* 4 * Tests for the options '-pcs' and '-npcs'. 5 * 6 * The option '-pcs' adds a space in a function call expression, between the 7 * function name and the opening parenthesis. 8 * 9 * The option '-npcs' removes any whitespace from a function call expression, 10 * between the function name and the opening parenthesis. 11 */ 12 13 //indent input 14 void 15 example(void) 16 { 17 function_call(); 18 function_call (1); 19 function_call (1,2,3); 20 } 21 //indent end 22 23 //indent run -pcs 24 void 25 example(void) 26 { 27 function_call (); 28 function_call (1); 29 function_call (1, 2, 3); 30 } 31 //indent end 32 33 //indent run -npcs 34 void 35 example(void) 36 { 37 function_call(); 38 function_call(1); 39 function_call(1, 2, 3); 40 } 41 //indent end 42 43 44 //indent input 45 void ( * signal ( void ( * handler ) ( int ) ) ) ( int ) ; 46 int var = (function)(arg); 47 //indent end 48 49 //indent run -di0 -pcs 50 void (*signal (void (*handler) (int))) (int); 51 // $ This may be a function call or a cast, depending on the context. 52 int var = (function) (arg); 53 //indent end 54 55 //indent run -di0 -npcs 56 void (*signal(void (*handler)(int)))(int); 57 int var = (function)(arg); 58 //indent end 59 60 61 /* 62 * The option '-pcs' also applies to 'sizeof' and 'offsetof', even though 63 * these are not functions. 64 */ 65 //indent input 66 int sizeof_type = sizeof (int); 67 int sizeof_type = sizeof(int); 68 int sizeof_expr = sizeof (0); 69 int sizeof_expr = sizeof(0); 70 int sizeof_expr = sizeof 0; 71 72 int offset = offsetof(struct s, member); 73 int offset = offsetof (struct s, member); 74 //indent end 75 76 /* The option '-pcs' overrides '-nbs'. */ 77 //indent run -pcs -di0 -nbs 78 int sizeof_type = sizeof (int); 79 int sizeof_type = sizeof (int); 80 int sizeof_expr = sizeof (0); 81 int sizeof_expr = sizeof (0); 82 int sizeof_expr = sizeof 0; 83 84 int offset = offsetof (struct s, member); 85 int offset = offsetof (struct s, member); 86 //indent end 87 88 /* 89 * If the option '-npcs' is given, '-bs' can still specialize it. This only 90 * applies to 'sizeof', but not 'offsetof'. 91 */ 92 //indent run -npcs -di0 -bs 93 int sizeof_type = sizeof (int); 94 int sizeof_type = sizeof (int); 95 int sizeof_expr = sizeof (0); 96 int sizeof_expr = sizeof (0); 97 int sizeof_expr = sizeof 0; 98 99 int offset = offsetof(struct s, member); 100 int offset = offsetof(struct s, member); 101 //indent end 102 103 //indent run -npcs -di0 104 int sizeof_type = sizeof(int); 105 int sizeof_type = sizeof(int); 106 int sizeof_expr = sizeof(0); 107 int sizeof_expr = sizeof(0); 108 int sizeof_expr = sizeof 0; 109 110 int offset = offsetof(struct s, member); 111 int offset = offsetof(struct s, member); 112 //indent end 113 114 115 //indent input 116 int unary = +call(); 117 int postfix = step++(); 118 int binary = 1 + call(); 119 //indent end 120 121 //indent run-equals-input -npcs -di0 122 123 //indent run -pcs -di0 124 int unary = +call (); 125 int postfix = step++ (); 126 int binary = 1 + call (); 127 //indent end 128