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: add type information to message 15...



details:   https://anonhg.NetBSD.org/src/rev/6c98cacb20a1
branches:  trunk
changeset: 984226:6c98cacb20a1
user:      rillig <rillig%NetBSD.org@localhost>
date:      Mon Jun 28 10:23:49 2021 +0000

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

diffstat:

 tests/usr.bin/xlint/lint1/msg_155.c   |  22 +++++++++++++---------
 tests/usr.bin/xlint/lint1/msg_155.exp |  12 ++++++------
 usr.bin/xlint/lint1/err.c             |   6 +++---
 usr.bin/xlint/lint1/tree.c            |   8 ++++----
 4 files changed, 26 insertions(+), 22 deletions(-)

diffs (126 lines):

diff -r 96108da69c72 -r 6c98cacb20a1 tests/usr.bin/xlint/lint1/msg_155.c
--- a/tests/usr.bin/xlint/lint1/msg_155.c       Mon Jun 28 10:07:43 2021 +0000
+++ b/tests/usr.bin/xlint/lint1/msg_155.c       Mon Jun 28 10:23:49 2021 +0000
@@ -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 @@
 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);
 }
diff -r 96108da69c72 -r 6c98cacb20a1 tests/usr.bin/xlint/lint1/msg_155.exp
--- a/tests/usr.bin/xlint/lint1/msg_155.exp     Mon Jun 28 10:07:43 2021 +0000
+++ b/tests/usr.bin/xlint/lint1/msg_155.exp     Mon Jun 28 10:23:49 2021 +0000
@@ -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]
diff -r 96108da69c72 -r 6c98cacb20a1 usr.bin/xlint/lint1/err.c
--- a/usr.bin/xlint/lint1/err.c Mon Jun 28 10:07:43 2021 +0000
+++ b/usr.bin/xlint/lint1/err.c Mon Jun 28 10:23:49 2021 +0000
@@ -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 @@
        "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 */
diff -r 96108da69c72 -r 6c98cacb20a1 usr.bin/xlint/lint1/tree.c
--- a/usr.bin/xlint/lint1/tree.c        Mon Jun 28 10:07:43 2021 +0000
+++ b/usr.bin/xlint/lint1/tree.c        Mon Jun 28 10:23:49 2021 +0000
@@ -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 @@
                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);



Home | Main Index | Thread Index | Old Index