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: fix storage class of compound lite...
details: https://anonhg.NetBSD.org/src/rev/2a79709324c1
branches: trunk
changeset: 961398:2a79709324c1
user: rillig <rillig%NetBSD.org@localhost>
date: Sun Apr 18 08:00:13 2021 +0000
description:
lint: fix storage class of compound literal in initializer
A compound literal that occurs at block_level 0 does not have storage
class AUTO. Instead, its storage class is either EXTERN or STATIC.
While removing the temporary objects from the symbol table had prevented
the assertion, it did not properly fix the underlying problem, which was
that since C99 the initializers can contain references to unnamed
objects that are created on-the-fly. For C90 it was correct to always
use AUTO as the storage class of a temporary symbol.
diffstat:
usr.bin/xlint/lint1/init.c | 18 ++----------------
usr.bin/xlint/lint1/lex.c | 11 ++++++++---
2 files changed, 10 insertions(+), 19 deletions(-)
diffs (85 lines):
diff -r dab1c40e80c2 -r 2a79709324c1 usr.bin/xlint/lint1/init.c
--- a/usr.bin/xlint/lint1/init.c Sun Apr 18 07:31:47 2021 +0000
+++ b/usr.bin/xlint/lint1/init.c Sun Apr 18 08:00:13 2021 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: init.c,v 1.195 2021/04/17 21:20:08 rillig Exp $ */
+/* $NetBSD: init.c,v 1.196 2021/04/18 08:00:13 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.195 2021/04/17 21:20:08 rillig Exp $");
+__RCSID("$NetBSD: init.c,v 1.196 2021/04/18 08:00:13 rillig Exp $");
#endif
#include <stdlib.h>
@@ -994,17 +994,6 @@
static struct initialization *init;
-static void
-discard_temporary_objects(void)
-{
- sym_t *sym;
-
- for (sym = dcs->d_dlsyms; sym != NULL; sym = sym->s_dlnxt)
- if (ch_isdigit(sym->s_name[0])) /* see mktempsym */
- rmsym(sym);
-}
-
-
static struct initialization *
current_init(void)
{
@@ -1048,9 +1037,6 @@
debug_indentation--;
#endif
debug_step0("end initialization");
-
- if (init == NULL)
- discard_temporary_objects();
}
void
diff -r dab1c40e80c2 -r 2a79709324c1 usr.bin/xlint/lint1/lex.c
--- a/usr.bin/xlint/lint1/lex.c Sun Apr 18 07:31:47 2021 +0000
+++ b/usr.bin/xlint/lint1/lex.c Sun Apr 18 08:00:13 2021 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: lex.c,v 1.27 2021/04/12 15:55:26 christos Exp $ */
+/* $NetBSD: lex.c,v 1.28 2021/04/18 08:00:13 rillig Exp $ */
/*
* Copyright (c) 1996 Christopher G. Demetriou. All Rights Reserved.
@@ -38,7 +38,7 @@
#include <sys/cdefs.h>
#if defined(__RCSID) && !defined(lint)
-__RCSID("$NetBSD: lex.c,v 1.27 2021/04/12 15:55:26 christos Exp $");
+__RCSID("$NetBSD: lex.c,v 1.28 2021/04/18 08:00:13 rillig Exp $");
#endif
#include <ctype.h>
@@ -1486,14 +1486,19 @@
int h;
char *s = getlblk(block_level, 64);
sym_t *sym = getblk(sizeof(*sym));
+ scl_t scl;
(void)snprintf(s, 64, "%.8d_tmp", n++);
h = hash(s);
+ scl = dcs->d_scl;
+ if (scl == NOSCL)
+ scl = block_level > 0 ? AUTO : EXTERN;
+
sym->s_name = s;
sym->s_type = t;
sym->s_block_level = block_level;
- sym->s_scl = AUTO;
+ sym->s_scl = scl;
sym->s_kind = FVFT;
sym->s_used = true;
sym->s_set = true;
Home |
Main Index |
Thread Index |
Old Index