Module Name:    src
Committed By:   rillig
Date:           Wed Jun 30 14:23:51 UTC 2021

Modified Files:
        src/tests/usr.bin/xlint/lint1: msg_155.c msg_155.exp msg_215.c
            msg_215.exp
        src/usr.bin/xlint/lint1: err.c tree.c

Log Message:
lint: mention the name of an implicitly declared function

In the regular NetBSD builds, this happened in swab.c:65.  That line
contains __predict_false, which may or may not be a macro.  In other
cases, there may be more than one function call in a single line.


To generate a diff of this commit:
cvs rdiff -u -r1.8 -r1.9 src/tests/usr.bin/xlint/lint1/msg_155.c \
    src/tests/usr.bin/xlint/lint1/msg_155.exp
cvs rdiff -u -r1.6 -r1.7 src/tests/usr.bin/xlint/lint1/msg_215.c \
    src/tests/usr.bin/xlint/lint1/msg_215.exp
cvs rdiff -u -r1.121 -r1.122 src/usr.bin/xlint/lint1/err.c
cvs rdiff -u -r1.300 -r1.301 src/usr.bin/xlint/lint1/tree.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/tests/usr.bin/xlint/lint1/msg_155.c
diff -u src/tests/usr.bin/xlint/lint1/msg_155.c:1.8 src/tests/usr.bin/xlint/lint1/msg_155.c:1.9
--- src/tests/usr.bin/xlint/lint1/msg_155.c:1.8	Wed Jun 30 12:26:35 2021
+++ src/tests/usr.bin/xlint/lint1/msg_155.c	Wed Jun 30 14:23:50 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: msg_155.c,v 1.8 2021/06/30 12:26:35 rillig Exp $	*/
+/*	$NetBSD: msg_155.c,v 1.9 2021/06/30 14:23:50 rillig Exp $	*/
 # 3 "msg_155.c"
 
 // Test for message: passing '%s' to incompatible '%s', arg #%d [155]
@@ -38,7 +38,8 @@ provoke_error_messages(struct incompatib
 	c99_6_7_6_example_e(arg);
 
 	/* TODO: C99 says 'function with no parameter specification returning a pointer to int' */
-	c99_6_7_6_example_f(arg);	/* expect: function implicitly declared */
+	/* expect+1: function 'c99_6_7_6_example_f' implicitly declared */
+	c99_6_7_6_example_f(arg);
 
 	/* expect+1: 'pointer to function(void) returning int' */
 	c99_6_7_6_example_g(arg);
Index: src/tests/usr.bin/xlint/lint1/msg_155.exp
diff -u src/tests/usr.bin/xlint/lint1/msg_155.exp:1.8 src/tests/usr.bin/xlint/lint1/msg_155.exp:1.9
--- src/tests/usr.bin/xlint/lint1/msg_155.exp:1.8	Wed Jun 30 12:26:35 2021
+++ src/tests/usr.bin/xlint/lint1/msg_155.exp	Wed Jun 30 14:23:50 2021
@@ -3,10 +3,10 @@ msg_155.c(28): warning: passing 'struct 
 msg_155.c(32): warning: passing 'struct incompatible' to incompatible 'pointer to pointer to int', arg #1 [155]
 msg_155.c(35): warning: passing 'struct incompatible' to incompatible 'pointer to array[3] of int', arg #1 [155]
 msg_155.c(38): warning: passing 'struct incompatible' to incompatible 'pointer to array[unknown_size] of int', arg #1 [155]
-msg_155.c(41): error: function implicitly declared to return int [215]
-msg_155.c(44): warning: passing 'struct incompatible' to incompatible 'pointer to function(void) returning int', arg #1 [155]
-msg_155.c(47): warning: passing 'struct incompatible' to incompatible 'pointer to const pointer to function(unsigned int, ...) returning int', arg #1 [155]
-msg_155.c(68): warning: passing 'enum Day' to incompatible 'struct incompatible', arg #1 [155]
-msg_155.c(71): warning: passing 'enum Day' to incompatible 'struct incompatible', arg #1 [155]
-msg_155.c(74): warning: passing 'int' to incompatible 'struct incompatible', arg #1 [155]
-msg_155.c(77): warning: passing 'int' to incompatible 'struct incompatible', arg #1 [155]
+msg_155.c(42): error: function 'c99_6_7_6_example_f' implicitly declared to return int [215]
+msg_155.c(45): warning: passing 'struct incompatible' to incompatible 'pointer to function(void) returning int', arg #1 [155]
+msg_155.c(48): warning: passing 'struct incompatible' to incompatible 'pointer to const pointer to function(unsigned int, ...) returning int', arg #1 [155]
+msg_155.c(69): warning: passing 'enum Day' to incompatible 'struct incompatible', arg #1 [155]
+msg_155.c(72): warning: passing 'enum Day' to incompatible 'struct incompatible', arg #1 [155]
+msg_155.c(75): warning: passing 'int' to incompatible 'struct incompatible', arg #1 [155]
+msg_155.c(78): warning: passing 'int' to incompatible 'struct incompatible', arg #1 [155]

Index: src/tests/usr.bin/xlint/lint1/msg_215.c
diff -u src/tests/usr.bin/xlint/lint1/msg_215.c:1.6 src/tests/usr.bin/xlint/lint1/msg_215.c:1.7
--- src/tests/usr.bin/xlint/lint1/msg_215.c:1.6	Wed Jun 30 14:15:39 2021
+++ src/tests/usr.bin/xlint/lint1/msg_215.c	Wed Jun 30 14:23:50 2021
@@ -1,7 +1,7 @@
-/*	$NetBSD: msg_215.c,v 1.6 2021/06/30 14:15:39 rillig Exp $	*/
+/*	$NetBSD: msg_215.c,v 1.7 2021/06/30 14:23:50 rillig Exp $	*/
 # 3 "msg_215.c"
 
-// Test for message: function implicitly declared to return int [215]
+// Test for message: function '%s' implicitly declared to return int [215]
 
 /*
  * In traditional C and C90, it was possible to implicitly declare a function
@@ -17,7 +17,7 @@ struct str {
 void
 test(struct str str)
 {
-	/* expect+1: error: function implicitly declared to return int [215] */
+	/* expect+1: error: function 'name' implicitly declared to return int [215] */
 	name();
 
 	/* expect+2: error: 'parenthesized' undefined [99] */
Index: src/tests/usr.bin/xlint/lint1/msg_215.exp
diff -u src/tests/usr.bin/xlint/lint1/msg_215.exp:1.6 src/tests/usr.bin/xlint/lint1/msg_215.exp:1.7
--- src/tests/usr.bin/xlint/lint1/msg_215.exp:1.6	Wed Jun 30 14:15:39 2021
+++ src/tests/usr.bin/xlint/lint1/msg_215.exp	Wed Jun 30 14:23:50 2021
@@ -1,4 +1,4 @@
-msg_215.c(21): error: function implicitly declared to return int [215]
+msg_215.c(21): error: function 'name' implicitly declared to return int [215]
 msg_215.c(25): error: 'parenthesized' undefined [99]
 msg_215.c(25): error: illegal function (type int) [149]
 msg_215.c(29): error: type 'struct str' does not have member 'member' [101]

Index: src/usr.bin/xlint/lint1/err.c
diff -u src/usr.bin/xlint/lint1/err.c:1.121 src/usr.bin/xlint/lint1/err.c:1.122
--- src/usr.bin/xlint/lint1/err.c:1.121	Mon Jun 28 10:23:49 2021
+++ src/usr.bin/xlint/lint1/err.c	Wed Jun 30 14:23:50 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: err.c,v 1.121 2021/06/28 10:23:49 rillig Exp $	*/
+/*	$NetBSD: err.c,v 1.122 2021/06/30 14:23:50 rillig Exp $	*/
 
 /*
  * Copyright (c) 1994, 1995 Jochen Pohl
@@ -37,7 +37,7 @@
 
 #include <sys/cdefs.h>
 #if defined(__RCSID) && !defined(lint)
-__RCSID("$NetBSD: err.c,v 1.121 2021/06/28 10:23:49 rillig Exp $");
+__RCSID("$NetBSD: err.c,v 1.122 2021/06/30 14:23:50 rillig Exp $");
 #endif
 
 #include <sys/types.h>
@@ -269,7 +269,7 @@ const char *const msgs[] = {
 	"cannot return incomplete type",			      /* 212 */
 	"void function %s cannot return value",			      /* 213 */
 	"function %s expects to return value",			      /* 214 */
-	"function implicitly declared to return int",		      /* 215 */
+	"function '%s' implicitly declared to return int",	      /* 215 */
 	"function %s has return (e); and return;",		      /* 216 */
 	"function %s falls off bottom without returning value",	      /* 217 */
 	"ANSI C treats constant as unsigned, op %s",		      /* 218 */

Index: src/usr.bin/xlint/lint1/tree.c
diff -u src/usr.bin/xlint/lint1/tree.c:1.300 src/usr.bin/xlint/lint1/tree.c:1.301
--- src/usr.bin/xlint/lint1/tree.c:1.300	Wed Jun 30 14:11:08 2021
+++ src/usr.bin/xlint/lint1/tree.c	Wed Jun 30 14:23:50 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: tree.c,v 1.300 2021/06/30 14:11:08 rillig Exp $	*/
+/*	$NetBSD: tree.c,v 1.301 2021/06/30 14:23:50 rillig Exp $	*/
 
 /*
  * Copyright (c) 1994, 1995 Jochen Pohl
@@ -37,7 +37,7 @@
 
 #include <sys/cdefs.h>
 #if defined(__RCSID) && !defined(lint)
-__RCSID("$NetBSD: tree.c,v 1.300 2021/06/30 14:11:08 rillig Exp $");
+__RCSID("$NetBSD: tree.c,v 1.301 2021/06/30 14:23:50 rillig Exp $");
 #endif
 
 #include <float.h>
@@ -246,11 +246,11 @@ new_name_node(sym_t *sym, int follow_tok
 		sym->s_def = DECL;
 		if (follow_token == T_LPAREN) {
 			if (Sflag) {
-				/* function implicitly declared to ... */
-				error(215);
+				/* function '%s' implicitly declared to ... */
+				error(215, sym->s_name);
 			} else if (sflag) {
-				/* function implicitly declared to ... */
-				warning(215);
+				/* function '%s' implicitly declared to ... */
+				warning(215, sym->s_name);
 			}
 			/*
 			 * XXX if tflag is set the symbol should be

Reply via email to