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.
This commit is contained in:
rillig 2021-06-29 21:05:32 +00:00
parent b6ad7b596e
commit 1b367b1b6c
1 changed files with 7 additions and 4 deletions

View File

@ -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 @@ static void
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;