lsym_funcname.c revision 1.7 1 1.7 rillig /* $NetBSD: lsym_funcname.c,v 1.7 2023/06/17 22:09:24 rillig Exp $ */
2 1.1 rillig
3 1.1 rillig /*
4 1.5 rillig * Tests for the token lsym_funcname, which is the name of a function, but only
5 1.5 rillig * in a function definition, not in a declaration or a call expression.
6 1.4 rillig *
7 1.1 rillig * See also:
8 1.1 rillig * lsym_word.c
9 1.1 rillig */
10 1.1 rillig
11 1.3 rillig //indent input
12 1.4 rillig void
13 1.4 rillig function(void)
14 1.4 rillig {
15 1.4 rillig func();
16 1.4 rillig (func)();
17 1.4 rillig func(1, 2, 3);
18 1.4 rillig }
19 1.3 rillig //indent end
20 1.1 rillig
21 1.3 rillig //indent run-equals-input
22 1.6 rillig
23 1.6 rillig
24 1.6 rillig /*
25 1.6 rillig * The comment after the return type of a function definition is a code
26 1.6 rillig * comment, not a declaration comment.
27 1.6 rillig */
28 1.6 rillig //indent input
29 1.6 rillig void // comment
30 1.6 rillig function_with_comment(void)
31 1.6 rillig {
32 1.6 rillig }
33 1.6 rillig //indent end
34 1.6 rillig
35 1.6 rillig //indent run-equals-input
36 1.7 rillig
37 1.7 rillig
38 1.7 rillig /*
39 1.7 rillig * The heuristics for telling a function definition and a function declaration
40 1.7 rillig * apart look at the remaining characters in a line but don't tokenize them.
41 1.7 rillig * Due to that, a ');' in a comment influences the heuristics.
42 1.7 rillig */
43 1.7 rillig //indent input
44 1.7 rillig // $ This ');' in the comment does not mark the end of the declaration.
45 1.7 rillig void heuristics_semicolon_comment(/* ); */) {}
46 1.7 rillig void heuristics_semicolon_no_comm(/* -- */) {}
47 1.7 rillig void heuristics_comma_comment(/* ), */) {}
48 1.7 rillig void heuristics_comma_no_comm(/* -- */) {}
49 1.7 rillig //indent end
50 1.7 rillig
51 1.7 rillig //indent run -di0
52 1.7 rillig void heuristics_semicolon_comment(/* ); */) {
53 1.7 rillig }
54 1.7 rillig void
55 1.7 rillig heuristics_semicolon_no_comm(/* -- */)
56 1.7 rillig {
57 1.7 rillig }
58 1.7 rillig void heuristics_comma_comment(/* ), */) {
59 1.7 rillig }
60 1.7 rillig void
61 1.7 rillig heuristics_comma_no_comm(/* -- */)
62 1.7 rillig {
63 1.7 rillig }
64 1.7 rillig //indent end
65