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 check_no_auto_aggregate



details:   https://anonhg.NetBSD.org/src/rev/4f50e58ee113
branches:  trunk
changeset: 954062:4f50e58ee113
user:      rillig <rillig%NetBSD.org@localhost>
date:      Sun Mar 28 15:39:25 2021 +0000

description:
lint: extract check_no_auto_aggregate

No functional change.

diffstat:

 usr.bin/xlint/lint1/init.c |  28 +++++++++++++++++++---------
 1 files changed, 19 insertions(+), 9 deletions(-)

diffs (56 lines):

diff -r 291788039329 -r 4f50e58ee113 usr.bin/xlint/lint1/init.c
--- a/usr.bin/xlint/lint1/init.c        Sun Mar 28 15:36:37 2021 +0000
+++ b/usr.bin/xlint/lint1/init.c        Sun Mar 28 15:39:25 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: init.c,v 1.163 2021/03/28 14:13:18 rillig Exp $        */
+/*     $NetBSD: init.c,v 1.164 2021/03/28 15:39:25 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.163 2021/03/28 14:13:18 rillig Exp $");
+__RCSID("$NetBSD: init.c,v 1.164 2021/03/28 15:39:25 rillig Exp $");
 #endif
 
 #include <stdlib.h>
@@ -1032,6 +1032,22 @@
 }
 
 static void
+check_no_auto_aggregate(scl_t sclass, const struct brace_level *level)
+{
+       if (!tflag)
+               return;
+       if (!(sclass == AUTO || sclass == REG))
+               return;
+       if (!(level->bl_enclosing == NULL))
+               return;
+       if (is_scalar(level->bl_subtype->t_tspec))
+               return;
+
+       /* no automatic aggregate initialization in trad. C */
+       warning(188);
+}
+
+static void
 initialization_lbrace(struct initialization *in)
 {
        if (in->initerr)
@@ -1040,13 +1056,7 @@
        debug_enter();
        initialization_debug(in);
 
-       if ((in->initsym->s_scl == AUTO || in->initsym->s_scl == REG) &&
-           in->brace_level->bl_enclosing == NULL) {
-               if (tflag &&
-                   !is_scalar(in->brace_level->bl_subtype->t_tspec))
-                       /* no automatic aggregate initialization in trad. C */
-                       warning(188);
-       }
+       check_no_auto_aggregate(in->initsym->s_scl, in->brace_level);
 
        /*
         * Remove all entries which cannot be used for further initializers



Home | Main Index | Thread Index | Old Index