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
14void
15example(void)
16{
17	function_call();
18	function_call (1);
19	function_call   (1,2,3);
20}
21//indent end
22
23//indent run -pcs
24void
25example(void)
26{
27	function_call ();
28	function_call (1);
29	function_call (1, 2, 3);
30}
31//indent end
32
33//indent run -npcs
34void
35example(void)
36{
37	function_call();
38	function_call(1);
39	function_call(1, 2, 3);
40}
41//indent end
42
43
44//indent input
45void ( * signal ( void ( * handler ) ( int ) ) ) ( int ) ;
46int var = (function)(arg);
47//indent end
48
49//indent run -di0 -pcs
50void (*signal (void (*handler) (int))) (int);
51// $ This may be a function call or a cast, depending on the context.
52int var = (function) (arg);
53//indent end
54
55//indent run -di0 -npcs
56void (*signal(void (*handler)(int)))(int);
57int 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
66int sizeof_type = sizeof   (int);
67int sizeof_type = sizeof(int);
68int sizeof_expr = sizeof   (0);
69int sizeof_expr = sizeof(0);
70int sizeof_expr = sizeof   0;
71
72int offset = offsetof(struct s, member);
73int offset = offsetof   (struct s, member);
74//indent end
75
76/* The option '-pcs' overrides '-nbs'. */
77//indent run -pcs -di0 -nbs
78int sizeof_type = sizeof (int);
79int sizeof_type = sizeof (int);
80int sizeof_expr = sizeof (0);
81int sizeof_expr = sizeof (0);
82int sizeof_expr = sizeof 0;
83
84int offset = offsetof (struct s, member);
85int 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
93int sizeof_type = sizeof (int);
94int sizeof_type = sizeof (int);
95int sizeof_expr = sizeof (0);
96int sizeof_expr = sizeof (0);
97int sizeof_expr = sizeof 0;
98
99int offset = offsetof(struct s, member);
100int offset = offsetof(struct s, member);
101//indent end
102
103//indent run -npcs -di0
104int sizeof_type = sizeof(int);
105int sizeof_type = sizeof(int);
106int sizeof_expr = sizeof(0);
107int sizeof_expr = sizeof(0);
108int sizeof_expr = sizeof 0;
109
110int offset = offsetof(struct s, member);
111int offset = offsetof(struct s, member);
112//indent end
113
114
115//indent input
116int unary = +call();
117int postfix = step++();
118int binary = 1 + call();
119//indent end
120
121//indent run-equals-input -npcs -di0
122
123//indent run -pcs -di0
124int unary = +call ();
125int postfix = step++ ();
126int binary = 1 + call ();
127//indent end
128