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 init_using_assign from ini...



details:   https://anonhg.NetBSD.org/src/rev/dd7b89de65d0
branches:  trunk
changeset: 953903:dd7b89de65d0
user:      rillig <rillig%NetBSD.org@localhost>
date:      Tue Mar 23 20:21:07 2021 +0000

description:
lint: extract init_using_assign from init_using_expr

No functional change.

diffstat:

 usr.bin/xlint/lint1/init.c |  43 +++++++++++++++++++++++++++----------------
 1 files changed, 27 insertions(+), 16 deletions(-)

diffs (72 lines):

diff -r ffe53688075b -r dd7b89de65d0 usr.bin/xlint/lint1/init.c
--- a/usr.bin/xlint/lint1/init.c        Tue Mar 23 20:14:55 2021 +0000
+++ b/usr.bin/xlint/lint1/init.c        Tue Mar 23 20:21:07 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: init.c,v 1.113 2021/03/23 20:14:55 rillig Exp $        */
+/*     $NetBSD: init.c,v 1.114 2021/03/23 20:21:07 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.113 2021/03/23 20:14:55 rillig Exp $");
+__RCSID("$NetBSD: init.c,v 1.114 2021/03/23 20:21:07 rillig Exp $");
 #endif
 
 #include <stdlib.h>
@@ -966,6 +966,30 @@
        }
 }
 
+/*
+ * Local initialization of non-array-types with only one expression without
+ * braces is done by ASSIGN.
+ */
+static bool
+init_using_assign(tnode_t *rn)
+{
+       tnode_t *ln, *tn;
+
+       if (initsym->s_type->t_tspec == ARRAY)
+               return false;
+       if (initstk->i_enclosing != NULL)
+               return false;
+
+       debug_step("handing over to ASSIGN");
+       ln = new_name_node(initsym, 0);
+       ln->tn_type = tduptyp(ln->tn_type);
+       ln->tn_type->t_const = false;
+       tn = build(ASSIGN, ln, rn);
+       expr(tn, false, false, false, false);
+       /* XXX: why not clean up the initstack here already? */
+       return true;
+}
+
 void
 init_using_expr(tnode_t *tn)
 {
@@ -992,21 +1016,8 @@
         * be enclosed by braces.
         */
 
-       /*
-        * Local initialization of non-array-types with only one expression
-        * without braces is done by ASSIGN
-        */
-       if ((sclass == AUTO || sclass == REG) &&
-           initsym->s_type->t_tspec != ARRAY && initstk->i_enclosing == NULL) {
-               debug_step("handing over to ASSIGN");
-               ln = new_name_node(initsym, 0);
-               ln->tn_type = tduptyp(ln->tn_type);
-               ln->tn_type->t_const = false;
-               tn = build(ASSIGN, ln, tn);
-               expr(tn, false, false, false, false);
-               /* XXX: why not clean up the initstack here already? */
+       if ((sclass == AUTO || sclass == REG) && init_using_assign(tn))
                goto done;
-       }
 
        initstack_pop_nobrace();
 



Home | Main Index | Thread Index | Old Index