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: fix assertion failure after error ...



details:   https://anonhg.NetBSD.org/src/rev/e11445a1cec1
branches:  trunk
changeset: 953757:e11445a1cec1
user:      rillig <rillig%NetBSD.org@localhost>
date:      Sat Mar 20 08:54:27 2021 +0000

description:
lint: fix assertion failure after error in designation

In d_c99_init.c, the initialization of array_with_designator failed.
The designator '.member' from that initialization was not cleaned up
before starting the next initialization.

diffstat:

 tests/usr.bin/xlint/lint1/d_c99_init.c   |  8 +++++---
 tests/usr.bin/xlint/lint1/d_c99_init.exp |  1 +
 usr.bin/xlint/lint1/init.c               |  6 ++++--
 3 files changed, 10 insertions(+), 5 deletions(-)

diffs (56 lines):

diff -r c913fe84ffa8 -r e11445a1cec1 tests/usr.bin/xlint/lint1/d_c99_init.c
--- a/tests/usr.bin/xlint/lint1/d_c99_init.c    Sat Mar 20 08:16:30 2021 +0000
+++ b/tests/usr.bin/xlint/lint1/d_c99_init.c    Sat Mar 20 08:54:27 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: d_c99_init.c,v 1.10 2021/03/20 08:16:30 rillig Exp $   */
+/*     $NetBSD: d_c99_init.c,v 1.11 2021/03/20 08:54:27 rillig Exp $   */
 # 3 "d_c99_init.c"
 
 /*
@@ -139,7 +139,9 @@
  * mean the "outermost initializer".  Both GCC 10 and Clang 8 already warn
  * about this, so there is no extra work for lint to do.
  */
-// FIXME: assertion failure 'istk->i_type != NULL'
-// struct point scalar_with_several_braces = {};
+struct point scalar_with_several_braces = {
+       {{{3}}},                /*FIXME*//* expect: invalid initializer type int */
+       {{{{4}}}},
+};
 
 // See d_struct_init_nested.c for a more complicated example.
diff -r c913fe84ffa8 -r e11445a1cec1 tests/usr.bin/xlint/lint1/d_c99_init.exp
--- a/tests/usr.bin/xlint/lint1/d_c99_init.exp  Sat Mar 20 08:16:30 2021 +0000
+++ b/tests/usr.bin/xlint/lint1/d_c99_init.exp  Sat Mar 20 08:54:27 2021 +0000
@@ -3,3 +3,4 @@
 d_c99_init.c(49): cannot initialize 'pointer to const void' from 'struct any' [185]
 d_c99_init.c(66): too many array initializers, expected 3 [173]
 d_c99_init.c(131): syntax error 'named member must only be used with struct/union' [249]
+d_c99_init.c(143): invalid initializer type int [176]
diff -r c913fe84ffa8 -r e11445a1cec1 usr.bin/xlint/lint1/init.c
--- a/usr.bin/xlint/lint1/init.c        Sat Mar 20 08:16:30 2021 +0000
+++ b/usr.bin/xlint/lint1/init.c        Sat Mar 20 08:54:27 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: init.c,v 1.107 2021/03/20 08:16:30 rillig Exp $        */
+/*     $NetBSD: init.c,v 1.108 2021/03/20 08:54:27 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.107 2021/03/20 08:16:30 rillig Exp $");
+__RCSID("$NetBSD: init.c,v 1.108 2021/03/20 08:54:27 rillig Exp $");
 #endif
 
 #include <stdlib.h>
@@ -411,6 +411,8 @@
                initstk = istk->i_enclosing;
                free(istk);
        }
+       while (namedmem != NULL)
+               designator_shift_name();
 
        debug_enter();
 



Home | Main Index | Thread Index | Old Index