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 array creation from expr_de...
details: https://anonhg.NetBSD.org/src/rev/adfb8f5aa816
branches: trunk
changeset: 1023287:adfb8f5aa816
user: rillig <rillig%NetBSD.org@localhost>
date: Wed Sep 01 06:48:24 2021 +0000
description:
lint: remove array creation from expr_derive_type
It is only used for creating string types. The creation of other array
types happens in add_array.
This is a preparation to make all stored types const.
No functional change.
diffstat:
usr.bin/xlint/lint1/tree.c | 17 +++++++++++------
1 files changed, 11 insertions(+), 6 deletions(-)
diffs (51 lines):
diff -r 0aa7bc5a7200 -r adfb8f5aa816 usr.bin/xlint/lint1/tree.c
--- a/usr.bin/xlint/lint1/tree.c Wed Sep 01 06:12:50 2021 +0000
+++ b/usr.bin/xlint/lint1/tree.c Wed Sep 01 06:48:24 2021 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: tree.c,v 1.364 2021/08/31 19:17:45 rillig Exp $ */
+/* $NetBSD: tree.c,v 1.365 2021/09/01 06:48:24 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.364 2021/08/31 19:17:45 rillig Exp $");
+__RCSID("$NetBSD: tree.c,v 1.365 2021/09/01 06:48:24 rillig Exp $");
#endif
#include <float.h>
@@ -115,8 +115,8 @@
}
/*
- * Build 'pointer to tp', 'array of tp' or 'function returning tp'. The
- * memory is freed at the end of the current expression.
+ * Derive 'pointer to tp' or 'function returning tp'.
+ * The memory is freed at the end of the current expression.
*/
type_t *
expr_derive_type(type_t *tp, tspec_t t)
@@ -274,14 +274,19 @@
{
size_t len;
tnode_t *n;
+ type_t *tp;
len = strg->st_len;
n = expr_zalloc_tnode();
+ tp = expr_zalloc(sizeof(*tp));
+ tp->t_tspec = ARRAY;
+ tp->t_subt = gettyp(strg->st_tspec);
+ tp->t_dim = len + 1;
+
n->tn_op = STRING;
- n->tn_type = expr_derive_type(gettyp(strg->st_tspec), ARRAY);
- n->tn_type->t_dim = len + 1;
+ n->tn_type = tp;
n->tn_lvalue = true;
n->tn_string = expr_zalloc(sizeof(*n->tn_string));
Home |
Main Index |
Thread Index |
Old Index