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".
This commit is contained in:
rillig 2021-06-28 11:27:00 +00:00
parent d8a3f2eb44
commit 61e921f9ea
5 changed files with 18 additions and 12 deletions

View File

@ -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 incompatible arg)
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);

View File

@ -3,5 +3,6 @@ msg_155.c(28): warning: passing 'struct incompatible' to incompatible 'pointer t
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]

View File

@ -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] */
}

View File

@ -1 +1 @@
msg_215.c(6): error: syntax error ':' [249]
msg_215.c(9): error: function implicitly declared to return int [215]

View File

@ -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_token)
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);
}