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: add function for setting the initi...



details:   https://anonhg.NetBSD.org/src/rev/9e3b3621737d
branches:  trunk
changeset: 1019993:9e3b3621737d
user:      rillig <rillig%NetBSD.org@localhost>
date:      Sat Mar 27 21:56:51 2021 +0000

description:
lint: add function for setting the initialization error

No functional change.

diffstat:

 usr.bin/xlint/lint1/init.c |  22 ++++++++++++++--------
 1 files changed, 14 insertions(+), 8 deletions(-)

diffs (85 lines):

diff -r b303aa3ed162 -r 9e3b3621737d usr.bin/xlint/lint1/init.c
--- a/usr.bin/xlint/lint1/init.c        Sat Mar 27 21:23:14 2021 +0000
+++ b/usr.bin/xlint/lint1/init.c        Sat Mar 27 21:56:51 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: init.c,v 1.140 2021/03/27 19:59:22 rillig Exp $        */
+/*     $NetBSD: init.c,v 1.141 2021/03/27 21:56:51 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.140 2021/03/27 19:59:22 rillig Exp $");
+__RCSID("$NetBSD: init.c,v 1.141 2021/03/27 21:56:51 rillig Exp $");
 #endif
 
 #include <stdlib.h>
@@ -320,6 +320,12 @@
        free(in);
 }
 
+static void
+set_initerr(void)
+{
+       current_init()->initerr = true;
+}
+
 #define initerr                (*current_initerr())
 #define initsym                (*current_initsym())
 #define brace_level_rvalue     (current_brace_level())
@@ -607,7 +613,7 @@
            level->bl_type->t_tspec != UNION) {
                /* syntax error '%s' */
                error(249, "named member must only be used with struct/union");
-               initerr = true;
+               set_initerr();
                return;
        }
 
@@ -782,7 +788,7 @@
            level->bl_enclosing->bl_enclosing != NULL) {
                /* initialization of an incomplete type */
                error(175);
-               initerr = true;
+               set_initerr();
                return;
        }
 
@@ -847,7 +853,7 @@
        if (is_incomplete(level->bl_type)) {
                /* initialization of an incomplete type */
                error(175);
-               initerr = true;
+               set_initerr();
                return false;
        }
 
@@ -880,7 +886,7 @@
        if (cnt == 0) {
                /* cannot init. struct/union with no named member */
                error(179);
-               initerr = true;
+               set_initerr();
                return false;
        }
        level->bl_remaining = level->bl_type->t_tspec == STRUCT ? cnt : 1;
@@ -976,7 +982,7 @@
                /* too many initializers */
                error(174);
        }
-       initerr = true;
+       set_initerr();
 }
 
 /*
@@ -995,7 +1001,7 @@
            is_scalar(brace_level_rvalue->bl_type->t_tspec)) {
                /* invalid initializer type %s */
                error(176, type_name(brace_level_rvalue->bl_type));
-               initerr = true;
+               set_initerr();
        }
        if (!initerr)
                check_too_many_initializers();



Home | Main Index | Thread Index | Old Index