Module Name:    src
Committed By:   rillig
Date:           Mon Jun 28 11:27:00 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: tree.c

Log Message:
lint: in C99 mode, complain about implicitly declared functions

C99, foreword, p5, item 22 lists among the major changes from C90:
"remove implicit function declaration".


To generate a diff of this commit:
cvs rdiff -u -r1.6 -r1.7 src/tests/usr.bin/xlint/lint1/msg_155.c \
    src/tests/usr.bin/xlint/lint1/msg_155.exp
cvs rdiff -u -r1.2 -r1.3 src/tests/usr.bin/xlint/lint1/msg_215.c \
    src/tests/usr.bin/xlint/lint1/msg_215.exp
cvs rdiff -u -r1.293 -r1.294 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.6 src/tests/usr.bin/xlint/lint1/msg_155.c:1.7
--- src/tests/usr.bin/xlint/lint1/msg_155.c:1.6	Mon Jun 28 11:09:35 2021
+++ src/tests/usr.bin/xlint/lint1/msg_155.c	Mon Jun 28 11:27:00 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: msg_155.c,v 1.6 2021/06/28 11:09:35 rillig Exp $	*/
+/*	$NetBSD: msg_155.c,v 1.7 2021/06/28 11:27:00 rillig Exp $	*/
 # 3 "msg_155.c"
 
 // Test for message: passing '%s' to incompatible '%s', arg #%d [155]
@@ -38,8 +38,7 @@ 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' */
-	/* FIXME: no warning or error at all for an undefined function? */
-	c99_6_7_6_example_f(arg);
+	c99_6_7_6_example_f(arg);	/* expect: function implicitly declared */
 
 	/* 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.6 src/tests/usr.bin/xlint/lint1/msg_155.exp:1.7
--- src/tests/usr.bin/xlint/lint1/msg_155.exp:1.6	Mon Jun 28 11:09:35 2021
+++ src/tests/usr.bin/xlint/lint1/msg_155.exp	Mon Jun 28 11:27:00 2021
@@ -3,5 +3,6 @@ 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(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(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]

Index: src/tests/usr.bin/xlint/lint1/msg_215.c
diff -u src/tests/usr.bin/xlint/lint1/msg_215.c:1.2 src/tests/usr.bin/xlint/lint1/msg_215.c:1.3
--- src/tests/usr.bin/xlint/lint1/msg_215.c:1.2	Sun Feb 21 09:07:58 2021
+++ src/tests/usr.bin/xlint/lint1/msg_215.c	Mon Jun 28 11:27:00 2021
@@ -1,7 +1,10 @@
-/*	$NetBSD: msg_215.c,v 1.2 2021/02/21 09:07:58 rillig Exp $	*/
+/*	$NetBSD: msg_215.c,v 1.3 2021/06/28 11:27:00 rillig Exp $	*/
 # 3 "msg_215.c"
 
 // Test for message: function implicitly declared to return int [215]
 
-TODO: "Add example code that triggers the above message." /* expect: 249 */
-TODO: "Add example code that almost triggers the above message."
+void
+caller(void)
+{
+	callee(12345);		/* expect: [215] */
+}
Index: src/tests/usr.bin/xlint/lint1/msg_215.exp
diff -u src/tests/usr.bin/xlint/lint1/msg_215.exp:1.2 src/tests/usr.bin/xlint/lint1/msg_215.exp:1.3
--- src/tests/usr.bin/xlint/lint1/msg_215.exp:1.2	Sun Mar 21 20:45:00 2021
+++ src/tests/usr.bin/xlint/lint1/msg_215.exp	Mon Jun 28 11:27:00 2021
@@ -1 +1 @@
-msg_215.c(6): error: syntax error ':' [249]
+msg_215.c(9): error: function implicitly declared to return int [215]

Index: src/usr.bin/xlint/lint1/tree.c
diff -u src/usr.bin/xlint/lint1/tree.c:1.293 src/usr.bin/xlint/lint1/tree.c:1.294
--- src/usr.bin/xlint/lint1/tree.c:1.293	Mon Jun 28 10:23:49 2021
+++ src/usr.bin/xlint/lint1/tree.c	Mon Jun 28 11:27:00 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: tree.c,v 1.293 2021/06/28 10:23:49 rillig Exp $	*/
+/*	$NetBSD: tree.c,v 1.294 2021/06/28 11:27:00 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.293 2021/06/28 10:23:49 rillig Exp $");
+__RCSID("$NetBSD: tree.c,v 1.294 2021/06/28 11:27:00 rillig Exp $");
 #endif
 
 #include <float.h>
@@ -245,7 +245,10 @@ new_name_node(sym_t *sym, int follow_tok
 		sym->s_scl = EXTERN;
 		sym->s_def = DECL;
 		if (follow_token == T_LPAREN) {
-			if (sflag) {
+			if (Sflag) {
+				/* function implicitly declared to ... */
+				error(215);
+			} else if (sflag) {
 				/* function implicitly declared to ... */
 				warning(215);
 			}

Reply via email to