lint: add type information to message 155 (type mismatch)

This commit is contained in:
rillig 2021-06-28 10:23:49 +00:00
parent 3ce5ae23e6
commit 5953d76ca7
4 changed files with 26 additions and 22 deletions

View File

@ -1,8 +1,8 @@
/* $NetBSD: msg_155.c,v 1.3 2021/06/28 10:07:43 rillig Exp $ */
/* $NetBSD: msg_155.c,v 1.4 2021/06/28 10:23:50 rillig Exp $ */
# 3 "msg_155.c"
// Test for message: argument is incompatible with prototype, arg #%d [155]
// TODO: Add type information to the message
// Test for message: passing '%s' to incompatible '%s', arg #%d [155]
void c99_6_7_6_example_a(int);
void c99_6_7_6_example_b(int *);
@ -21,27 +21,31 @@ struct incompatible {
void
provoke_error_messages(struct incompatible arg)
{
/* expect+1: argument is incompatible with prototype, arg #1 */
/* expect+1: 'int' */
c99_6_7_6_example_a(arg);
/* expect+1: argument is incompatible with prototype, arg #1 */
/* expect+1: 'pointer to int' */
c99_6_7_6_example_b(arg);
/* expect+1: argument is incompatible with prototype, arg #1 */
/* C99 says 'array[3] of pointer to int', which is close enough. */
/* expect+1: 'pointer to pointer to int' */
c99_6_7_6_example_c(arg);
/* expect+1: argument is incompatible with prototype, arg #1 */
/* expect+1: 'pointer to array[3] of int' */
c99_6_7_6_example_d(arg);
/* TODO: C99 says 'pointer to a variable length array of an unspecified number of ints' */
/* FIXME: no warning or error at all for an undefined function? */
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);
/* expect+1: argument is incompatible with prototype, arg #1 */
/* TODO: fix type_name to generate '(void)' in this case */
/* expect+1: 'pointer to function() returning int' */
c99_6_7_6_example_g(arg);
/* expect+1: argument is incompatible with prototype, arg #1 */
/* expect+1: 'pointer to const pointer to function(unsigned int, ...) returning int' */
c99_6_7_6_example_h(arg);
}

View File

@ -1,7 +1,7 @@
msg_155.c(11): error: syntax error ']' [249]
msg_155.c(25): warning: argument is incompatible with prototype, arg #1 [155]
msg_155.c(28): warning: argument is incompatible with prototype, arg #1 [155]
msg_155.c(31): warning: argument is incompatible with prototype, arg #1 [155]
msg_155.c(34): warning: argument is incompatible with prototype, arg #1 [155]
msg_155.c(43): warning: argument is incompatible with prototype, arg #1 [155]
msg_155.c(46): warning: argument is incompatible with prototype, arg #1 [155]
msg_155.c(25): warning: passing 'struct incompatible' to incompatible 'int', arg #1 [155]
msg_155.c(28): warning: passing 'struct incompatible' to incompatible 'pointer to int', arg #1 [155]
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(47): warning: passing 'struct incompatible' to incompatible 'pointer to function() returning int', arg #1 [155]
msg_155.c(50): warning: passing 'struct incompatible' to incompatible 'pointer to const pointer to function(unsigned int, ...) returning int', arg #1 [155]

View File

@ -1,4 +1,4 @@
/* $NetBSD: err.c,v 1.120 2021/06/27 19:10:29 rillig Exp $ */
/* $NetBSD: err.c,v 1.121 2021/06/28 10:23:49 rillig Exp $ */
/*
* Copyright (c) 1994, 1995 Jochen Pohl
@ -37,7 +37,7 @@
#include <sys/cdefs.h>
#if defined(__RCSID) && !defined(lint)
__RCSID("$NetBSD: err.c,v 1.120 2021/06/27 19:10:29 rillig Exp $");
__RCSID("$NetBSD: err.c,v 1.121 2021/06/28 10:23:49 rillig Exp $");
#endif
#include <sys/types.h>
@ -209,7 +209,7 @@ const char *const msgs[] = {
"argument cannot have unknown size, arg #%d", /* 152 */
"converting '%s' to incompatible '%s' for argument %d", /* 153 */
"illegal combination of %s (%s) and %s (%s), arg #%d", /* 154 */
"argument is incompatible with prototype, arg #%d", /* 155 */
"passing '%s' to incompatible '%s', arg #%d", /* 155 */
"enum type mismatch, arg #%d (%s != %s)", /* 156 */
"ANSI C treats constant as unsigned", /* 157 */
"%s may be used before set", /* 158 */

View File

@ -1,4 +1,4 @@
/* $NetBSD: tree.c,v 1.292 2021/06/27 21:16:40 rillig Exp $ */
/* $NetBSD: tree.c,v 1.293 2021/06/28 10:23:49 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.292 2021/06/27 21:16:40 rillig Exp $");
__RCSID("$NetBSD: tree.c,v 1.293 2021/06/28 10:23:49 rillig Exp $");
#endif
#include <float.h>
@ -1490,8 +1490,8 @@ check_assign_types_compatible(op_t op, int arg,
error(211, type_name(ltp), type_name(rtp));
break;
case FARG:
/* argument is incompatible with prototype, arg #%d */
warning(155, arg);
/* passing '%s' to incompatible '%s', arg #%d */
warning(155, type_name(rtp), type_name(ltp), arg);
break;
default:
warn_incompatible_types(op, ltp, lt, rtp, rt);