opt_pcs.c revision 1.9 1 /* $NetBSD: opt_pcs.c,v 1.9 2021/11/20 11:13:18 rillig Exp $ */
2 /* $FreeBSD$ */
3
4 /*
5 * Tests for the options '-pcs' and '-npcs'.
6 *
7 * The option '-pcs' adds a space in a function call expression, between the
8 * function name and the opening parenthesis.
9 *
10 * The option '-npcs' removes any whitespace from a function call expression,
11 * between the function name and the opening parenthesis.
12 */
13
14 #indent input
15 void
16 example(void)
17 {
18 function_call();
19 function_call (1);
20 function_call (1,2,3);
21 }
22 #indent end
23
24 #indent run -pcs
25 void
26 example(void)
27 {
28 function_call ();
29 function_call (1);
30 function_call (1, 2, 3);
31 }
32 #indent end
33
34 #indent run -npcs
35 void
36 example(void)
37 {
38 function_call();
39 function_call(1);
40 function_call(1, 2, 3);
41 }
42 #indent end
43
44
45 #indent input
46 void ( * signal ( void ( * handler ) ( int ) ) ) ( int ) ;
47 int var = (function)(arg);
48 #indent end
49
50 #indent run -npsl -di0 -pcs
51 void (*signal(void (*handler) (int))) (int);
52 int var = (function) (arg);
53 #indent end
54
55 #indent run -npsl -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