Module Name: src Committed By: rillig Date: Mon Jun 28 10:23:50 UTC 2021
Modified Files: src/tests/usr.bin/xlint/lint1: msg_155.c msg_155.exp src/usr.bin/xlint/lint1: err.c tree.c Log Message: lint: add type information to message 155 (type mismatch) To generate a diff of this commit: cvs rdiff -u -r1.3 -r1.4 src/tests/usr.bin/xlint/lint1/msg_155.c \ src/tests/usr.bin/xlint/lint1/msg_155.exp cvs rdiff -u -r1.120 -r1.121 src/usr.bin/xlint/lint1/err.c cvs rdiff -u -r1.292 -r1.293 src/usr.bin/xlint/lint1/tree.c 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_155.c diff -u src/tests/usr.bin/xlint/lint1/msg_155.c:1.3 src/tests/usr.bin/xlint/lint1/msg_155.c:1.4 --- src/tests/usr.bin/xlint/lint1/msg_155.c:1.3 Mon Jun 28 10:07:43 2021 +++ src/tests/usr.bin/xlint/lint1/msg_155.c Mon Jun 28 10:23:50 2021 @@ -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); } Index: src/tests/usr.bin/xlint/lint1/msg_155.exp diff -u src/tests/usr.bin/xlint/lint1/msg_155.exp:1.3 src/tests/usr.bin/xlint/lint1/msg_155.exp:1.4 --- src/tests/usr.bin/xlint/lint1/msg_155.exp:1.3 Mon Jun 28 10:07:43 2021 +++ src/tests/usr.bin/xlint/lint1/msg_155.exp Mon Jun 28 10:23:50 2021 @@ -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] Index: src/usr.bin/xlint/lint1/err.c diff -u src/usr.bin/xlint/lint1/err.c:1.120 src/usr.bin/xlint/lint1/err.c:1.121 --- src/usr.bin/xlint/lint1/err.c:1.120 Sun Jun 27 19:10:29 2021 +++ src/usr.bin/xlint/lint1/err.c Mon Jun 28 10:23:49 2021 @@ -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 */ Index: src/usr.bin/xlint/lint1/tree.c diff -u src/usr.bin/xlint/lint1/tree.c:1.292 src/usr.bin/xlint/lint1/tree.c:1.293 --- src/usr.bin/xlint/lint1/tree.c:1.292 Sun Jun 27 21:16:40 2021 +++ src/usr.bin/xlint/lint1/tree.c Mon Jun 28 10:23:49 2021 @@ -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, i 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);