Module Name: src Committed By: rillig Date: Tue Jun 29 21:05:32 UTC 2021
Modified Files: src/usr.bin/xlint/lint1: init.c Log Message: 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. To generate a diff of this commit: cvs rdiff -u -r1.199 -r1.200 src/usr.bin/xlint/lint1/init.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/usr.bin/xlint/lint1/init.c diff -u src/usr.bin/xlint/lint1/init.c:1.199 src/usr.bin/xlint/lint1/init.c:1.200 --- src/usr.bin/xlint/lint1/init.c:1.199 Sat Jun 19 15:23:57 2021 +++ src/usr.bin/xlint/lint1/init.c Tue Jun 29 21:05:32 2021 @@ -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;