opt_pcs.c revision 1.5 1 /* $NetBSD: opt_pcs.c,v 1.5 2021/10/24 11:42:57 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 * The option '-pcs' also applies to 'sizeof' and 'offsetof', even though
46 * these are not functions.
47 */
48 #indent input
49 int sizeof_type = sizeof (int);
50 int sizeof_type = sizeof(int);
51 int sizeof_expr = sizeof (0);
52 int sizeof_expr = sizeof(0);
53 int sizeof_expr = sizeof 0;
54
55 int offset = offsetof(struct s, member);
56 int offset = offsetof (struct s, member);
57 #indent end
58
59 /* The option '-pcs' overrides '-nbs'. */
60 #indent run -pcs -di0 -nbs
61 int sizeof_type = sizeof (int);
62 int sizeof_type = sizeof (int);
63 int sizeof_expr = sizeof (0);
64 int sizeof_expr = sizeof (0);
65 int sizeof_expr = sizeof 0;
66
67 int offset = offsetof (struct s, member);
68 int offset = offsetof (struct s, member);
69 #indent end
70
71 /*
72 * If the option '-npcs' is given, '-bs' can still specialize it. This only
73 * applies to 'sizeof', but not 'offsetof'.
74 */
75 #indent run -npcs -di0 -bs
76 int sizeof_type = sizeof (int);
77 int sizeof_type = sizeof (int);
78 int sizeof_expr = sizeof (0);
79 int sizeof_expr = sizeof (0);
80 int sizeof_expr = sizeof 0;
81
82 int offset = offsetof(struct s, member);
83 int offset = offsetof(struct s, member);
84 #indent end
85
86 #indent run -npcs -di0
87 int sizeof_type = sizeof(int);
88 int sizeof_type = sizeof(int);
89 int sizeof_expr = sizeof(0);
90 int sizeof_expr = sizeof(0);
91 int sizeof_expr = sizeof 0;
92
93 int offset = offsetof(struct s, member);
94 int offset = offsetof(struct s, member);
95 #indent end
96