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