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: untangle nested variable assignments
details: https://anonhg.NetBSD.org/src/rev/516b5ab9655a
branches: trunk
changeset: 364643:516b5ab9655a
user: rillig <rillig%NetBSD.org@localhost>
date: Sat Apr 02 16:27:03 2022 +0000
description:
lint: untangle nested variable assignments
The code is buggy (see decl_direct_abstract.c), so at least make it
readable, making it hopefully easier to fix the bugs.
Before decl.c 1.18 from 2000-07-05, lint crashed when it parsed
'sizeof(int(double))', since that commit it has been hiding the bugs,
working with wrong type information instead.
Fix the logged type in add_function (had been wrong since today).
diffstat:
usr.bin/xlint/lint1/decl.c | 17 +++++++++++------
1 files changed, 11 insertions(+), 6 deletions(-)
diffs (51 lines):
diff -r b725b5e533a4 -r 516b5ab9655a usr.bin/xlint/lint1/decl.c
--- a/usr.bin/xlint/lint1/decl.c Sat Apr 02 14:35:47 2022 +0000
+++ b/usr.bin/xlint/lint1/decl.c Sat Apr 02 16:27:03 2022 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: decl.c,v 1.260 2022/04/02 14:35:47 rillig Exp $ */
+/* $NetBSD: decl.c,v 1.261 2022/04/02 16:27:03 rillig Exp $ */
/*
* Copyright (c) 1996 Christopher G. Demetriou. All Rights Reserved.
@@ -38,7 +38,7 @@
#include <sys/cdefs.h>
#if defined(__RCSID) && !defined(lint)
-__RCSID("$NetBSD: decl.c,v 1.260 2022/04/02 14:35:47 rillig Exp $");
+__RCSID("$NetBSD: decl.c,v 1.261 2022/04/02 16:27:03 rillig Exp $");
#endif
#include <sys/param.h>
@@ -1315,11 +1315,15 @@
}
while (p != NULL) {
- *tpp = tp = block_zero_alloc(sizeof(*tp));
+ tp = block_zero_alloc(sizeof(*tp));
tp->t_tspec = PTR;
tp->t_const = p->p_const;
tp->t_volatile = p->p_volatile;
- *(tpp = &tp->t_subt) = dcs->d_type;
+ tp->t_subt = dcs->d_type;
+
+ *tpp = tp;
+ tpp = &tp->t_subt;
+
next = p->p_next;
free(p);
p = next;
@@ -1429,11 +1433,12 @@
*tpp = tp = block_zero_alloc(sizeof(*tp));
tp->t_tspec = FUNC;
tp->t_subt = dcs->d_enclosing->d_type;
- if ((tp->t_proto = dcs->d_proto) != false)
+ tp->t_proto = dcs->d_proto;
+ if (tp->t_proto)
tp->t_args = args;
tp->t_vararg = dcs->d_vararg;
- debug_step("add_function: '%s'", type_name(tp));
+ debug_step("add_function: '%s'", type_name(decl->s_type));
debug_leave();
return decl;
}
Home |
Main Index |
Thread Index |
Old Index