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: do not modify tnode_t->tn_type in ...
details: https://anonhg.NetBSD.org/src/rev/4d5ffc5198e0
branches: trunk
changeset: 984257:4d5ffc5198e0
user: rillig <rillig%NetBSD.org@localhost>
date: Tue Jun 29 21:05:32 2021 +0000
description:
lint: do not modify tnode_t->tn_type in check_init_expr
This is a very small step towards having all shared type_t objects only
referenced via const pointers. Since the types may be shared, it is a
bad idea to try to modify them, so better let the compiler check this.
It's a long way to reach this goal, but this small step is already
possible.
No functional change.
diffstat:
usr.bin/xlint/lint1/init.c | 11 +++++++----
1 files changed, 7 insertions(+), 4 deletions(-)
diffs (38 lines):
diff -r 3c9bbfbd6327 -r 4d5ffc5198e0 usr.bin/xlint/lint1/init.c
--- a/usr.bin/xlint/lint1/init.c Tue Jun 29 21:04:02 2021 +0000
+++ b/usr.bin/xlint/lint1/init.c Tue Jun 29 21:05:32 2021 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: init.c,v 1.199 2021/06/19 15:23:57 rillig Exp $ */
+/* $NetBSD: init.c,v 1.200 2021/06/29 21:05:32 rillig Exp $ */
/*
* Copyright (c) 1994, 1995 Jochen Pohl
@@ -38,7 +38,7 @@
#include <sys/cdefs.h>
#if defined(__RCSID) && !defined(lint)
-__RCSID("$NetBSD: init.c,v 1.199 2021/06/19 15:23:57 rillig Exp $");
+__RCSID("$NetBSD: init.c,v 1.200 2021/06/29 21:05:32 rillig Exp $");
#endif
#include <stdlib.h>
@@ -381,14 +381,17 @@
check_init_expr(const type_t *tp, sym_t *sym, tnode_t *tn)
{
tnode_t *ln;
+ type_t *ltp;
tspec_t lt, rt;
struct memory_block *tmem;
+ ltp = expr_dup_type(tp);
+ ltp->t_const = false;
+
/* Create a temporary node for the left side. */
ln = expr_zalloc(sizeof(*ln));
ln->tn_op = NAME;
- ln->tn_type = expr_dup_type(tp);
- ln->tn_type->t_const = false;
+ ln->tn_type = ltp;
ln->tn_lvalue = true;
ln->tn_sym = sym;
Home |
Main Index |
Thread Index |
Old Index