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