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: remove outdated comments, clean up...
details: https://anonhg.NetBSD.org/src/rev/442deb8cbbf0
branches: trunk
changeset: 960811:442deb8cbbf0
user: rillig <rillig%NetBSD.org@localhost>
date: Mon Mar 29 20:39:18 2021 +0000
description:
lint: remove outdated comments, clean up style
No functional change.
diffstat:
usr.bin/xlint/lint1/cgram.y | 6 ++----
usr.bin/xlint/lint1/init.c | 43 ++++++++++++++++++++++++++++++++++---------
2 files changed, 36 insertions(+), 13 deletions(-)
diffs (227 lines):
diff -r 1756a64184fd -r 442deb8cbbf0 usr.bin/xlint/lint1/cgram.y
--- a/usr.bin/xlint/lint1/cgram.y Mon Mar 29 17:13:07 2021 +0000
+++ b/usr.bin/xlint/lint1/cgram.y Mon Mar 29 20:39:18 2021 +0000
@@ -1,5 +1,5 @@
%{
-/* $NetBSD: cgram.y,v 1.205 2021/03/28 10:09:34 rillig Exp $ */
+/* $NetBSD: cgram.y,v 1.206 2021/03/29 20:39:18 rillig Exp $ */
/*
* Copyright (c) 1996 Christopher G. Demetriou. All Rights Reserved.
@@ -35,7 +35,7 @@
#include <sys/cdefs.h>
#if defined(__RCSID) && !defined(lint)
-__RCSID("$NetBSD: cgram.y,v 1.205 2021/03/28 10:09:34 rillig Exp $");
+__RCSID("$NetBSD: cgram.y,v 1.206 2021/03/29 20:39:18 rillig Exp $");
#endif
#include <limits.h>
@@ -1889,7 +1889,6 @@
expr_statement_list {
block_level--;
mem_block_level--;
- /* XXX: probably does not need the full initialization code */
begin_initialization(mktempsym(duptyp($4->tn_type)));
mem_block_level++;
block_level++;
@@ -1902,7 +1901,6 @@
| T_LPAREN compound_statement_lbrace expr_statement_list {
block_level--;
mem_block_level--;
- /* XXX: probably does not need the full initialization code */
begin_initialization(mktempsym($3->tn_type));
mem_block_level++;
block_level++;
diff -r 1756a64184fd -r 442deb8cbbf0 usr.bin/xlint/lint1/init.c
--- a/usr.bin/xlint/lint1/init.c Mon Mar 29 17:13:07 2021 +0000
+++ b/usr.bin/xlint/lint1/init.c Mon Mar 29 20:39:18 2021 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: init.c,v 1.174 2021/03/28 20:35:58 rillig Exp $ */
+/* $NetBSD: init.c,v 1.175 2021/03/29 20:39:18 rillig Exp $ */
/*
* Copyright (c) 1994, 1995 Jochen Pohl
@@ -37,7 +37,7 @@
#include <sys/cdefs.h>
#if defined(__RCSID) && !defined(lint)
-__RCSID("$NetBSD: init.c,v 1.174 2021/03/28 20:35:58 rillig Exp $");
+__RCSID("$NetBSD: init.c,v 1.175 2021/03/29 20:39:18 rillig Exp $");
#endif
#include <stdlib.h>
@@ -260,6 +260,7 @@
static struct initialization *init;
+
#ifdef DEBUG
static int debug_ind = 0;
#endif
@@ -280,12 +281,14 @@
static void
debug_indent(void)
{
+
debug_printf("%*s", 2 * debug_ind, "");
}
static void
debug_enter(const char *func)
{
+
printf("%*s+ %s\n", 2 * debug_ind++, "", func);
}
@@ -304,11 +307,12 @@
static void
debug_leave(const char *func)
{
+
printf("%*s- %s\n", 2 * --debug_ind, "", func);
}
-#define debug_enter() (debug_enter)(__func__)
-#define debug_leave() (debug_leave)(__func__)
+#define debug_enter() (debug_enter)(__func__)
+#define debug_leave() (debug_leave)(__func__)
#else
@@ -321,9 +325,19 @@
#endif
+static void *
+unconst_cast(const void *p)
+{
+ void *r;
+
+ memcpy(&r, &p, sizeof r);
+ return r;
+}
+
static bool
is_struct_or_union(tspec_t t)
{
+
return t == STRUCT || t == UNION;
}
@@ -332,6 +346,7 @@
static void
check_bit_field_init(const tnode_t *ln, tspec_t lt, tspec_t rt)
{
+
if (tflag &&
is_integer(lt) &&
ln->tn_type->t_bitfield &&
@@ -344,12 +359,12 @@
static void
check_non_constant_initializer(const tnode_t *tn, scl_t sclass)
{
- /* TODO: rename CON to CONSTANT to avoid ambiguity with CONVERT */
+ const sym_t *sym;
+ ptrdiff_t offs;
+
if (tn == NULL || tn->tn_op == CON)
return;
- const sym_t *sym;
- ptrdiff_t offs;
if (constant_addr(tn, &sym, &offs))
return;
@@ -363,7 +378,7 @@
}
static void
-check_init_expr(scl_t sclass, type_t *tp, sym_t *sym, tnode_t *tn)
+check_init_expr(scl_t sclass, const type_t *tp, sym_t *sym, tnode_t *tn)
{
tnode_t *ln;
tspec_t lt, rt;
@@ -401,7 +416,7 @@
* XXX: Is it correct to do this conversion _after_ the typeok above?
*/
if (lt != rt || (tp->t_bitfield && tn->tn_op == CON))
- tn = convert(INIT, 0, tp, tn);
+ tn = convert(INIT, 0, unconst_cast(tp), tn);
check_non_constant_initializer(tn, sclass);
}
@@ -418,6 +433,7 @@
static void
designator_free(struct designator *d)
{
+
free(d);
}
@@ -1378,6 +1394,7 @@
static struct initialization *
current_init(void)
{
+
lint_assert(init != NULL);
return init;
}
@@ -1385,12 +1402,14 @@
bool *
current_initerr(void)
{
+
return ¤t_init()->initerr;
}
sym_t **
current_initsym(void)
{
+
return ¤t_init()->initsym;
}
@@ -1419,6 +1438,7 @@
void
add_designator_member(sbuf_t *sb)
{
+
designation_add(¤t_init()->designation,
designator_new(sb->sb_name));
}
@@ -1426,29 +1446,34 @@
void
add_designator_subscript(range_t range)
{
+
initialization_add_designator_subscript(current_init(), range);
}
void
initstack_init(void)
{
+
initialization_init(current_init());
}
void
init_lbrace(void)
{
+
initialization_lbrace(current_init());
}
void
init_using_expr(tnode_t *tn)
{
+
initialization_expr(current_init(), tn);
}
void
init_rbrace(void)
{
+
initialization_rbrace(current_init());
}
Home |
Main Index |
Thread Index |
Old Index