lint: replace segmentation fault with assertion failure

This commit is contained in:
rillig 2021-03-20 08:16:30 +00:00
parent d312f2c65b
commit 88e315e145
2 changed files with 14 additions and 3 deletions

View File

@ -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.

View File

@ -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) {