Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/usr.bin/xlint/common lint: fix type name for prototype funct...



details:   https://anonhg.NetBSD.org/src/rev/4438aa7f0982
branches:  trunk
changeset: 379949:4438aa7f0982
user:      rillig <rillig%NetBSD.org@localhost>
date:      Mon Jun 28 10:29:05 2021 +0000

description:
lint: fix type name for prototype function without parameters

diffstat:

 tests/usr.bin/xlint/lint1/msg_155.c   |   5 ++---
 tests/usr.bin/xlint/lint1/msg_155.exp |   4 ++--
 usr.bin/xlint/common/tyname.c         |  14 ++++++++++----
 3 files changed, 14 insertions(+), 9 deletions(-)

diffs (71 lines):

diff -r 4f5a21dfb6cd -r 4438aa7f0982 tests/usr.bin/xlint/lint1/msg_155.c
--- a/tests/usr.bin/xlint/lint1/msg_155.c       Mon Jun 28 10:23:49 2021 +0000
+++ b/tests/usr.bin/xlint/lint1/msg_155.c       Mon Jun 28 10:29:05 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: msg_155.c,v 1.4 2021/06/28 10:23:50 rillig Exp $       */
+/*     $NetBSD: msg_155.c,v 1.5 2021/06/28 10:29:05 rillig Exp $       */
 # 3 "msg_155.c"
 
 // Test for message: passing '%s' to incompatible '%s', arg #%d [155]
@@ -42,8 +42,7 @@ provoke_error_messages(struct incompatib
        /* FIXME: no warning or error at all for an undefined function? */
        c99_6_7_6_example_f(arg);
 
-       /* TODO: fix type_name to generate '(void)' in this case */
-       /* expect+1: 'pointer to function() returning int' */
+       /* expect+1: 'pointer to function(void) returning int' */
        c99_6_7_6_example_g(arg);
 
        /* expect+1: 'pointer to const pointer to function(unsigned int, ...) returning int' */
diff -r 4f5a21dfb6cd -r 4438aa7f0982 tests/usr.bin/xlint/lint1/msg_155.exp
--- a/tests/usr.bin/xlint/lint1/msg_155.exp     Mon Jun 28 10:23:49 2021 +0000
+++ b/tests/usr.bin/xlint/lint1/msg_155.exp     Mon Jun 28 10:29:05 2021 +0000
@@ -3,5 +3,5 @@ msg_155.c(25): warning: passing 'struct 
 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]
+msg_155.c(46): warning: passing 'struct incompatible' to incompatible 'pointer to function(void) returning int', arg #1 [155]
+msg_155.c(49): warning: passing 'struct incompatible' to incompatible 'pointer to const pointer to function(unsigned int, ...) returning int', arg #1 [155]
diff -r 4f5a21dfb6cd -r 4438aa7f0982 usr.bin/xlint/common/tyname.c
--- a/usr.bin/xlint/common/tyname.c     Mon Jun 28 10:23:49 2021 +0000
+++ b/usr.bin/xlint/common/tyname.c     Mon Jun 28 10:29:05 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: tyname.c,v 1.41 2021/06/04 20:54:18 rillig Exp $       */
+/*     $NetBSD: tyname.c,v 1.42 2021/06/28 10:29:05 rillig Exp $       */
 
 /*-
  * Copyright (c) 2005 The NetBSD Foundation, Inc.
@@ -35,7 +35,7 @@
 
 #include <sys/cdefs.h>
 #if defined(__RCSID) && !defined(lint)
-__RCSID("$NetBSD: tyname.c,v 1.41 2021/06/04 20:54:18 rillig Exp $");
+__RCSID("$NetBSD: tyname.c,v 1.42 2021/06/28 10:29:05 rillig Exp $");
 #endif
 
 #include <limits.h>
@@ -263,14 +263,20 @@ type_name_of_function(buffer *buf, const
 #ifdef t_enum /* lint1 */
                sym_t *arg;
 
-               for (arg = tp->t_args; arg != NULL; arg = arg->s_next) {
+               arg = tp->t_args;
+               if (arg == NULL)
+                       buf_add(buf, "void");
+               for (; arg != NULL; arg = arg->s_next) {
                        buf_add(buf, sep), sep = ", ";
                        buf_add(buf, type_name(arg->s_type));
                }
 #else /* lint2 */
                type_t **argtype;
 
-               for (argtype = tp->t_args; *argtype != NULL; argtype++) {
+               argtype = tp->t_args;
+               if (argtype == NULL)
+                       buf_add(buf, "void");
+               for (; *argtype != NULL; argtype++) {
                        buf_add(buf, sep), sep = ", ";
                        buf_add(buf, type_name(*argtype));
                }



Home | Main Index | Thread Index | Old Index