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 extend_if_array_of_unknown...
details: https://anonhg.NetBSD.org/src/rev/bc19b9eea7b6
branches: trunk
changeset: 960420:bc19b9eea7b6
user: rillig <rillig%NetBSD.org@localhost>
date: Thu Mar 18 23:23:40 2021 +0000
description:
lint: extract extend_if_array_of_unknown_size from initstack_push
No functional change.
diffstat:
usr.bin/xlint/lint1/init.c | 50 ++++++++++++++++++++++++++-------------------
1 files changed, 29 insertions(+), 21 deletions(-)
diffs (79 lines):
diff -r 55ee04d0917f -r bc19b9eea7b6 usr.bin/xlint/lint1/init.c
--- a/usr.bin/xlint/lint1/init.c Thu Mar 18 23:18:36 2021 +0000
+++ b/usr.bin/xlint/lint1/init.c Thu Mar 18 23:23:40 2021 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: init.c,v 1.96 2021/03/18 22:51:32 rillig Exp $ */
+/* $NetBSD: init.c,v 1.97 2021/03/18 23:23:40 rillig Exp $ */
/*
* Copyright (c) 1994, 1995 Jochen Pohl
@@ -37,7 +37,7 @@
#include <sys/cdefs.h>
#if defined(__RCSID) && !defined(lint)
-__RCSID("$NetBSD: init.c,v 1.96 2021/03/18 22:51:32 rillig Exp $");
+__RCSID("$NetBSD: init.c,v 1.97 2021/03/18 23:23:40 rillig Exp $");
#endif
#include <stdlib.h>
@@ -519,6 +519,31 @@
debug_leave();
}
+/* Extend an array of unknown size by one element */
+static void
+extend_if_array_of_unknown_size(void)
+{
+ initstack_element *istk = initstk;
+
+ if (istk->i_remaining != 0)
+ return;
+
+ /*
+ * The only place where an incomplete array may appear is at the
+ * outermost aggregate level of the object to be initialized.
+ */
+ lint_assert(istk->i_enclosing->i_enclosing == NULL);
+ lint_assert(istk->i_type->t_tspec == ARRAY);
+
+ debug_step("extending array of unknown size '%s'",
+ type_name(istk->i_type));
+ istk->i_remaining = 1;
+ istk->i_type->t_dim++;
+ setcomplete(istk->i_type, true);
+
+ debug_step("extended type is '%s'", type_name(istk->i_type));
+}
+
static void
initstack_push(void)
{
@@ -528,26 +553,9 @@
debug_enter();
- istk = initstk;
+ extend_if_array_of_unknown_size();
- /* Extend an incomplete array type by one element */
- if (istk->i_remaining == 0) {
- /*
- * Inside of other aggregate types must not be an incomplete
- * type.
- */
- lint_assert(istk->i_enclosing->i_enclosing == NULL);
- lint_assert(istk->i_type->t_tspec == ARRAY);
-
- debug_step("extending array of unknown size '%s'",
- type_name(istk->i_type));
- istk->i_remaining = 1;
- istk->i_type->t_dim++;
- setcomplete(istk->i_type, true);
-
- debug_step("extended type is '%s'", type_name(istk->i_type));
- }
-
+ istk = initstk;
lint_assert(istk->i_remaining > 0);
lint_assert(istk->i_type == NULL || !is_scalar(istk->i_type->t_tspec));
Home |
Main Index |
Thread Index |
Old Index