Module Name: src Committed By: rillig Date: Sat Mar 20 08:16:30 UTC 2021
Modified Files: src/tests/usr.bin/xlint/lint1: d_c99_init.c src/usr.bin/xlint/lint1: init.c Log Message: lint: replace segmentation fault with assertion failure To generate a diff of this commit: cvs rdiff -u -r1.9 -r1.10 src/tests/usr.bin/xlint/lint1/d_c99_init.c cvs rdiff -u -r1.106 -r1.107 src/usr.bin/xlint/lint1/init.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/tests/usr.bin/xlint/lint1/d_c99_init.c diff -u src/tests/usr.bin/xlint/lint1/d_c99_init.c:1.9 src/tests/usr.bin/xlint/lint1/d_c99_init.c:1.10 --- src/tests/usr.bin/xlint/lint1/d_c99_init.c:1.9 Fri Mar 19 01:02:52 2021 +++ src/tests/usr.bin/xlint/lint1/d_c99_init.c Sat Mar 20 08:16:30 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: d_c99_init.c,v 1.9 2021/03/19 01:02:52 rillig Exp $ */ +/* $NetBSD: d_c99_init.c,v 1.10 2021/03/20 08:16:30 rillig Exp $ */ # 3 "d_c99_init.c" /* @@ -132,4 +132,14 @@ int array_with_designator[] = { 333, }; +/* + * C99 6.7.8p11 says that the initializer of a scalar can be "optionally + * enclosed in braces". It does not explicitly set an upper limit on the + * number of braces. It also doesn't restrict the term "initializer" to only + * 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 = {}; + // See d_struct_init_nested.c for a more complicated example. Index: src/usr.bin/xlint/lint1/init.c diff -u src/usr.bin/xlint/lint1/init.c:1.106 src/usr.bin/xlint/lint1/init.c:1.107 --- src/usr.bin/xlint/lint1/init.c:1.106 Fri Mar 19 18:17:46 2021 +++ src/usr.bin/xlint/lint1/init.c Sat Mar 20 08:16:30 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: init.c,v 1.106 2021/03/19 18:17:46 rillig Exp $ */ +/* $NetBSD: init.c,v 1.107 2021/03/20 08:16:30 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.106 2021/03/19 18:17:46 rillig Exp $"); +__RCSID("$NetBSD: init.c,v 1.107 2021/03/20 08:16:30 rillig Exp $"); #endif #include <stdlib.h> @@ -696,6 +696,7 @@ again: istk = initstk; debug_step("expecting type '%s'", type_name(istk->i_type)); + lint_assert(istk->i_type != NULL); switch (istk->i_type->t_tspec) { case ARRAY: if (namedmem != NULL) {