1 /* $NetBSD: lsym_period.c,v 1.5 2023/05/11 09:28:53 rillig Exp $ */
2
3 /*
4 * Tests for the token lsym_period, which represents '.' in these contexts:
5 *
6 * In an initializer, '.' starts a named designator (since C99).
7 *
8 * In an expression, 'sou.member' accesses the member 'member' in the struct
9 * or union 'sou'.
10 *
11 * In a function prototype declaration, the sequence '.' '.' '.' marks the
12 * start of a variable number of arguments. It would have been more intuitive
13 * to model them as a single token, but it doesn't make any difference for
14 * formatting the code.
15 *
16 * See also:
17 * lsym_word.c for '.' inside numeric constants
18 */
19
20 /* Designators in an initialization */
21 //indent input
22 struct point {
23 int x;
24 int y;
25 } p = {
26 .x = 3,
27 .y = 4,
28 };
29 //indent end
30
31 //indent run-equals-input -di0
32
33
34 /* Accessing struct members */
35 //indent input
36 time_t
get_time(struct stat st)37 get_time(struct stat st)
38 {
39 return st.st_mtime > 0 ? st . st_atime : st.st_ctime;
40 }
41 //indent end
42
43 //indent run
44 time_t
get_time(struct stat st)45 get_time(struct stat st)
46 {
47 return st.st_mtime > 0 ? st.st_atime : st.st_ctime;
48 }
49 //indent end
50
51 //indent run-equals-prev-output -Ttime_t
52
53
54 /* Varargs in a function declaration */
55 //indent input
56 void my_printf(const char *, ...);
57 //indent end
58
59 //indent run-equals-input -di0
60