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: extract code for handling statemen...
details: https://anonhg.NetBSD.org/src/rev/1dcaa05ba3a6
branches: trunk
changeset: 362039:1dcaa05ba3a6
user: rillig <rillig%NetBSD.org@localhost>
date: Sat Feb 26 19:01:09 2022 +0000
description:
lint: extract code for handling statement expressions from the grammar
This prepares the fix of the memory corruption bug that is demonstrated
in t_integration.sh, test case assertion_failures.
No functional change.
diffstat:
usr.bin/xlint/lint1/cgram.y | 15 ++++-----------
usr.bin/xlint/lint1/externs1.h | 5 ++++-
usr.bin/xlint/lint1/tree.c | 26 ++++++++++++++++++++++++--
3 files changed, 32 insertions(+), 14 deletions(-)
diffs (101 lines):
diff -r b09edd9089ef -r 1dcaa05ba3a6 usr.bin/xlint/lint1/cgram.y
--- a/usr.bin/xlint/lint1/cgram.y Sat Feb 26 18:49:42 2022 +0000
+++ b/usr.bin/xlint/lint1/cgram.y Sat Feb 26 19:01:09 2022 +0000
@@ -1,5 +1,5 @@
%{
-/* $NetBSD: cgram.y,v 1.379 2022/01/15 23:21:34 rillig Exp $ */
+/* $NetBSD: cgram.y,v 1.380 2022/02/26 19:01:09 rillig Exp $ */
/*
* Copyright (c) 1996 Christopher G. Demetriou. All Rights Reserved.
@@ -35,7 +35,7 @@
#include <sys/cdefs.h>
#if defined(__RCSID) && !defined(lint)
-__RCSID("$NetBSD: cgram.y,v 1.379 2022/01/15 23:21:34 rillig Exp $");
+__RCSID("$NetBSD: cgram.y,v 1.380 2022/02/26 19:01:09 rillig Exp $");
#endif
#include <limits.h>
@@ -518,16 +518,9 @@
end_initialization();
}
| T_LPAREN compound_statement_lbrace gcc_statement_expr_list {
- block_level--;
- mem_block_level--;
- begin_initialization(mktempsym(dup_type($3->tn_type)));
- mem_block_level++;
- block_level++;
- /* ({ }) is a GCC extension */
- gnuism(320);
+ do_statement_expr($3);
} compound_statement_rbrace T_RPAREN {
- $$ = build_name(*current_initsym(), false);
- end_initialization();
+ $$ = end_statement_expr();
}
;
diff -r b09edd9089ef -r 1dcaa05ba3a6 usr.bin/xlint/lint1/externs1.h
--- a/usr.bin/xlint/lint1/externs1.h Sat Feb 26 18:49:42 2022 +0000
+++ b/usr.bin/xlint/lint1/externs1.h Sat Feb 26 19:01:09 2022 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: externs1.h,v 1.144 2021/12/21 21:04:08 rillig Exp $ */
+/* $NetBSD: externs1.h,v 1.145 2022/02/26 19:01:09 rillig Exp $ */
/*
* Copyright (c) 1994, 1995 Jochen Pohl
@@ -262,6 +262,9 @@
extern strg_t *cat_strings(strg_t *, strg_t *);
extern unsigned int type_size_in_bits(const type_t *);
+void do_statement_expr(tnode_t *);
+tnode_t *end_statement_expr(void);
+
/*
* func.c
*/
diff -r b09edd9089ef -r 1dcaa05ba3a6 usr.bin/xlint/lint1/tree.c
--- a/usr.bin/xlint/lint1/tree.c Sat Feb 26 18:49:42 2022 +0000
+++ b/usr.bin/xlint/lint1/tree.c Sat Feb 26 19:01:09 2022 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: tree.c,v 1.402 2021/12/21 15:33:20 rillig Exp $ */
+/* $NetBSD: tree.c,v 1.403 2022/02/26 19:01:09 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.402 2021/12/21 15:33:20 rillig Exp $");
+__RCSID("$NetBSD: tree.c,v 1.403 2022/02/26 19:01:09 rillig Exp $");
#endif
#include <float.h>
@@ -4538,3 +4538,25 @@
warning(169);
}
}
+
+void
+do_statement_expr(tnode_t *tn)
+{
+ block_level--;
+ mem_block_level--;
+ /* Use the initialization code as temporary symbol storage. */
+ begin_initialization(mktempsym(dup_type(tn->tn_type)));
+ mem_block_level++;
+ block_level++;
+ /* ({ }) is a GCC extension */
+ gnuism(320);
+
+}
+
+tnode_t *
+end_statement_expr(void)
+{
+ tnode_t *tn = build_name(*current_initsym(), false);
+ end_initialization();
+ return tn;
+}
Home |
Main Index |
Thread Index |
Old Index