Module Name: src
Committed By: rillig
Date: Wed Jun 30 13:50:15 UTC 2021
Modified Files:
src/tests/usr.bin/xlint/lint1: msg_215.c msg_215.exp
Log Message:
tests/lint: extend and explain test for implicit function declaration
To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/tests/usr.bin/xlint/lint1/msg_215.c \
src/tests/usr.bin/xlint/lint1/msg_215.exp
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_215.c
diff -u src/tests/usr.bin/xlint/lint1/msg_215.c:1.3 src/tests/usr.bin/xlint/lint1/msg_215.c:1.4
--- src/tests/usr.bin/xlint/lint1/msg_215.c:1.3 Mon Jun 28 11:27:00 2021
+++ src/tests/usr.bin/xlint/lint1/msg_215.c Wed Jun 30 13:50:15 2021
@@ -1,10 +1,27 @@
-/* $NetBSD: msg_215.c,v 1.3 2021/06/28 11:27:00 rillig Exp $ */
+/* $NetBSD: msg_215.c,v 1.4 2021/06/30 13:50:15 rillig Exp $ */
# 3 "msg_215.c"
// Test for message: function implicitly declared to return int [215]
+/*
+ * In traditional C and C90, it was possible to implicitly declare a function
+ * by just calling it, without defining a prototype first. Such a function
+ * would then be defined as taking unspecified parameters and returning int.
+ */
+
+struct str {
+ int dummy;
+};
+
+/* ARGSUSED */
void
-caller(void)
+test(struct str str)
{
- callee(12345); /* expect: [215] */
+ /* expect+1: error: function implicitly declared to return int [215] */
+ name();
+
+ /* FIXME: "type 'int'" sounds wrong. */
+ /* expect+2: error: type 'int' does not have member 'member' [101] */
+ /* expect+1: error: illegal function (type int) [149] */
+ str.member();
}
Index: src/tests/usr.bin/xlint/lint1/msg_215.exp
diff -u src/tests/usr.bin/xlint/lint1/msg_215.exp:1.3 src/tests/usr.bin/xlint/lint1/msg_215.exp:1.4
--- src/tests/usr.bin/xlint/lint1/msg_215.exp:1.3 Mon Jun 28 11:27:00 2021
+++ src/tests/usr.bin/xlint/lint1/msg_215.exp Wed Jun 30 13:50:15 2021
@@ -1 +1,3 @@
-msg_215.c(9): error: function implicitly declared to return int [215]
+msg_215.c(21): error: function implicitly declared to return int [215]
+msg_215.c(26): error: type 'int' does not have member 'member' [101]
+msg_215.c(26): error: illegal function (type int) [149]