Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/tests/usr.bin/xlint/lint1 tests/lint: extend and explain tes...



details:   https://anonhg.NetBSD.org/src/rev/e1c2234edb2c
branches:  trunk
changeset: 380005:e1c2234edb2c
user:      rillig <rillig%NetBSD.org@localhost>
date:      Wed Jun 30 13:50:15 2021 +0000

description:
tests/lint: extend and explain test for implicit function declaration

diffstat:

 tests/usr.bin/xlint/lint1/msg_215.c   |  23 ++++++++++++++++++++---
 tests/usr.bin/xlint/lint1/msg_215.exp |   4 +++-
 2 files changed, 23 insertions(+), 4 deletions(-)

diffs (42 lines):

diff -r b3f6cb8a4f2d -r e1c2234edb2c tests/usr.bin/xlint/lint1/msg_215.c
--- a/tests/usr.bin/xlint/lint1/msg_215.c       Wed Jun 30 12:28:03 2021 +0000
+++ b/tests/usr.bin/xlint/lint1/msg_215.c       Wed Jun 30 13:50:15 2021 +0000
@@ -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();
 }
diff -r b3f6cb8a4f2d -r e1c2234edb2c tests/usr.bin/xlint/lint1/msg_215.exp
--- a/tests/usr.bin/xlint/lint1/msg_215.exp     Wed Jun 30 12:28:03 2021 +0000
+++ b/tests/usr.bin/xlint/lint1/msg_215.exp     Wed Jun 30 13:50:15 2021 +0000
@@ -1,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]



Home | Main Index | Thread Index | Old Index