Module Name: src
Committed By: rillig
Date: Mon Jun 28 10:29:05 UTC 2021
Modified Files:
src/tests/usr.bin/xlint/lint1: msg_155.c msg_155.exp
src/usr.bin/xlint/common: tyname.c
Log Message:
lint: fix type name for prototype function without parameters
To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 src/tests/usr.bin/xlint/lint1/msg_155.c \
src/tests/usr.bin/xlint/lint1/msg_155.exp
cvs rdiff -u -r1.41 -r1.42 src/usr.bin/xlint/common/tyname.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.4 src/tests/usr.bin/xlint/lint1/msg_155.c:1.5
--- src/tests/usr.bin/xlint/lint1/msg_155.c:1.4 Mon Jun 28 10:23:50 2021
+++ src/tests/usr.bin/xlint/lint1/msg_155.c Mon Jun 28 10:29:05 2021
@@ -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' */
Index: src/tests/usr.bin/xlint/lint1/msg_155.exp
diff -u src/tests/usr.bin/xlint/lint1/msg_155.exp:1.4 src/tests/usr.bin/xlint/lint1/msg_155.exp:1.5
--- src/tests/usr.bin/xlint/lint1/msg_155.exp:1.4 Mon Jun 28 10:23:50 2021
+++ src/tests/usr.bin/xlint/lint1/msg_155.exp Mon Jun 28 10:29:05 2021
@@ -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]
Index: src/usr.bin/xlint/common/tyname.c
diff -u src/usr.bin/xlint/common/tyname.c:1.41 src/usr.bin/xlint/common/tyname.c:1.42
--- src/usr.bin/xlint/common/tyname.c:1.41 Fri Jun 4 20:54:18 2021
+++ src/usr.bin/xlint/common/tyname.c Mon Jun 28 10:29:05 2021
@@ -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));
}