Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/usr.bin/xlint/lint1 lint: in C99 mode, complain about implic...
details: https://anonhg.NetBSD.org/src/rev/076bd7554915
branches: trunk
changeset: 379951:076bd7554915
user: rillig <rillig%NetBSD.org@localhost>
date: Mon Jun 28 11:27:00 2021 +0000
description:
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".
diffstat:
tests/usr.bin/xlint/lint1/msg_155.c | 5 ++---
tests/usr.bin/xlint/lint1/msg_155.exp | 5 +++--
tests/usr.bin/xlint/lint1/msg_215.c | 9 ++++++---
tests/usr.bin/xlint/lint1/msg_215.exp | 2 +-
usr.bin/xlint/lint1/tree.c | 9 ++++++---
5 files changed, 18 insertions(+), 12 deletions(-)
diffs (84 lines):
diff -r 7055636cb0c4 -r 076bd7554915 tests/usr.bin/xlint/lint1/msg_155.c
--- a/tests/usr.bin/xlint/lint1/msg_155.c Mon Jun 28 11:09:35 2021 +0000
+++ b/tests/usr.bin/xlint/lint1/msg_155.c Mon Jun 28 11:27:00 2021 +0000
@@ -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);
diff -r 7055636cb0c4 -r 076bd7554915 tests/usr.bin/xlint/lint1/msg_155.exp
--- a/tests/usr.bin/xlint/lint1/msg_155.exp Mon Jun 28 11:09:35 2021 +0000
+++ b/tests/usr.bin/xlint/lint1/msg_155.exp Mon Jun 28 11:27:00 2021 +0000
@@ -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]
diff -r 7055636cb0c4 -r 076bd7554915 tests/usr.bin/xlint/lint1/msg_215.c
--- a/tests/usr.bin/xlint/lint1/msg_215.c Mon Jun 28 11:09:35 2021 +0000
+++ b/tests/usr.bin/xlint/lint1/msg_215.c Mon Jun 28 11:27:00 2021 +0000
@@ -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] */
+}
diff -r 7055636cb0c4 -r 076bd7554915 tests/usr.bin/xlint/lint1/msg_215.exp
--- a/tests/usr.bin/xlint/lint1/msg_215.exp Mon Jun 28 11:09:35 2021 +0000
+++ b/tests/usr.bin/xlint/lint1/msg_215.exp Mon Jun 28 11:27:00 2021 +0000
@@ -1,1 +1,1 @@
-msg_215.c(6): error: syntax error ':' [249]
+msg_215.c(9): error: function implicitly declared to return int [215]
diff -r 7055636cb0c4 -r 076bd7554915 usr.bin/xlint/lint1/tree.c
--- a/usr.bin/xlint/lint1/tree.c Mon Jun 28 11:09:35 2021 +0000
+++ b/usr.bin/xlint/lint1/tree.c Mon Jun 28 11:27:00 2021 +0000
@@ -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);
}
Home |
Main Index |
Thread Index |
Old Index