Home | History | Annotate | Line # | Download | only in lint1
      1  1.9  rillig /*	$NetBSD: msg_280.c,v 1.9 2023/08/02 18:51:25 rillig Exp $	*/
      2  1.1  rillig # 3 "msg_280.c"
      3  1.1  rillig 
      4  1.6  rillig // Test for message: comment /* %s */ must be outside function [280]
      5  1.1  rillig 
      6  1.7  rillig /* lint1-extra-flags: -X 351 */
      7  1.7  rillig 
      8  1.3  rillig /* VARARGS */
      9  1.3  rillig void
     10  1.3  rillig varargs_ok(const char *str, ...)
     11  1.3  rillig {
     12  1.3  rillig 	(void)str;
     13  1.3  rillig }
     14  1.3  rillig 
     15  1.5  rillig /*
     16  1.5  rillig  * In the following example, the comment looks misplaced, but lint does not
     17  1.5  rillig  * warn about it.
     18  1.5  rillig  *
     19  1.5  rillig  * This is due to the implementation of the parser and the C grammar.  When
     20  1.5  rillig  * the parser sees the token T_LPAREN, it has to decide whether the following
     21  1.5  rillig  * tokens will form a parameter type list or an identifier list.  For that,
     22  1.5  rillig  * it needs to look at the next token to see whether it is a T_NAME (in which
     23  1.5  rillig  * case the T_LPAREN belongs to an id_list_lparen) or something else (in
     24  1.5  rillig  * which case the T_LPAREN belongs to an abstract_decl_lparen).  This token
     25  1.5  rillig  * lookahead happens just before either of these grammar rules is reduced.
     26  1.5  rillig  * During that reduction, the current declaration context switches from
     27  1.9  rillig  * DLK_EXTERN to DLK_PROTO_PARAMS, which makes this exact position the very
     28  1.5  rillig  * last possible.  Everything later would already be in the wrong context.
     29  1.5  rillig  *
     30  1.5  rillig  * As of cgram.y 1.360 from 2021-09-04, the implementation of these grammar
     31  1.5  rillig  * rules is exactly the same, which makes it tempting to join them into a
     32  1.5  rillig  * single rule.
     33  1.5  rillig  */
     34  1.3  rillig void
     35  1.3  rillig varargs_bad_param(/* VARARGS */ const char *str, ...)
     36  1.3  rillig {
     37  1.3  rillig 	(void)str;
     38  1.3  rillig }
     39  1.3  rillig 
     40  1.3  rillig void
     41  1.6  rillig /* expect+1: warning: comment ** VARARGS ** must be outside function [280] */
     42  1.3  rillig varargs_bad_ellipsis(const char *str, /* VARARGS */ ...)
     43  1.3  rillig {
     44  1.3  rillig 	(void)str;
     45  1.3  rillig }
     46  1.3  rillig 
     47  1.3  rillig void
     48  1.3  rillig varargs_bad_body(const char *str, ...)
     49  1.3  rillig {
     50  1.6  rillig 	/* expect+1: warning: comment ** VARARGS ** must be outside function [280] */
     51  1.3  rillig 	/* VARARGS */
     52  1.3  rillig 	(void)str;
     53  1.3  rillig }
     54  1.3  rillig 
     55  1.3  rillig void
     56  1.8  rillig /* expect+1: warning: parameter 'str' unused in function 'argsused_bad_body' [231] */
     57  1.3  rillig argsused_bad_body(const char *str)
     58  1.3  rillig {
     59  1.6  rillig 	/* expect+1: warning: comment ** ARGSUSED ** must be outside function [280] */
     60  1.3  rillig 	/* ARGSUSED */
     61  1.3  rillig }
     62  1.3  rillig 
     63  1.3  rillig void
     64  1.3  rillig printflike_bad_body(const char *fmt, ...)
     65  1.3  rillig {
     66  1.6  rillig 	/* expect+1: warning: comment ** PRINTFLIKE ** must be outside function [280] */
     67  1.3  rillig 	/* PRINTFLIKE */
     68  1.3  rillig 	(void)fmt;
     69  1.3  rillig }
     70  1.3  rillig 
     71  1.3  rillig void
     72  1.3  rillig scanflike_bad_body(const char *fmt, ...)
     73  1.3  rillig {
     74  1.6  rillig 	/* expect+1: warning: comment ** SCANFLIKE ** must be outside function [280] */
     75  1.3  rillig 	/* SCANFLIKE */
     76  1.3  rillig 	(void)fmt;
     77  1.3  rillig }
     78