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 test for assertion failure in ...
details: https://anonhg.NetBSD.org/src/rev/9445dac535a5
branches: trunk
changeset: 954077:9445dac535a5
user: rillig <rillig%NetBSD.org@localhost>
date: Sun Mar 28 19:53:58 2021 +0000
description:
lint: add test for assertion failure in initialization
The 'cnt = level->bl_type->t_tspec == STRUCT ? 2 : 1;' in
initialization_push_struct_or_union is obviously wrong since not every
struct has exactly 1 remaining member after the first member that has an
initializer with designation.
This bug started its life in init.c 1.12 from 2002-10-21, a little over
18 years ago.
diffstat:
tests/usr.bin/xlint/lint1/d_c99_init.c | 23 ++++++++++++++++++++++-
usr.bin/xlint/lint1/init.c | 14 +++++++-------
2 files changed, 29 insertions(+), 8 deletions(-)
diffs (85 lines):
diff -r b17f7485cbd9 -r 9445dac535a5 tests/usr.bin/xlint/lint1/d_c99_init.c
--- a/tests/usr.bin/xlint/lint1/d_c99_init.c Sun Mar 28 19:30:08 2021 +0000
+++ b/tests/usr.bin/xlint/lint1/d_c99_init.c Sun Mar 28 19:53:58 2021 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: d_c99_init.c,v 1.18 2021/03/28 18:48:32 rillig Exp $ */
+/* $NetBSD: d_c99_init.c,v 1.19 2021/03/28 19:53:58 rillig Exp $ */
# 3 "d_c99_init.c"
/*
@@ -243,3 +243,24 @@
/* expect+1: too many array initializers */
'\n',
};
+
+struct ten {
+ int i0;
+ int i1;
+ int i2;
+ int i3;
+ int i4;
+ int i5;
+ int i6;
+ int i7;
+ int i8;
+ int i9;
+};
+
+struct ten ten = {
+ .i3 = 3,
+ 4,
+ // FIXME: assertion "level->bl_type->t_tspec == ARRAY" failed in brace_level_extend_if_array_of_unknown_size
+ // 5,
+ // 6,
+};
diff -r b17f7485cbd9 -r 9445dac535a5 usr.bin/xlint/lint1/init.c
--- a/usr.bin/xlint/lint1/init.c Sun Mar 28 19:30:08 2021 +0000
+++ b/usr.bin/xlint/lint1/init.c Sun Mar 28 19:53:58 2021 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: init.c,v 1.172 2021/03/28 19:30:08 rillig Exp $ */
+/* $NetBSD: init.c,v 1.173 2021/03/28 19:53:58 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.172 2021/03/28 19:30:08 rillig Exp $");
+__RCSID("$NetBSD: init.c,v 1.173 2021/03/28 19:53:58 rillig Exp $");
#endif
#include <stdlib.h>
@@ -589,8 +589,8 @@
/* TODO: merge duplicate code */
static sym_t *
-brace_level_look_up_member_named(struct brace_level *level, const char *name,
- int *count)
+brace_level_look_up_first_member_named(struct brace_level *level,
+ const char *name, int *count)
{
sym_t *m;
@@ -609,7 +609,7 @@
/* TODO: merge duplicate code */
static sym_t *
-brace_level_look_up_member_unnamed(struct brace_level *level, int *count)
+brace_level_look_up_first_member_unnamed(struct brace_level *level, int *count)
{
sym_t *m;
@@ -830,10 +830,10 @@
level->bl_seen_named_member ? ", seen named member" : "");
if (in->designation.head != NULL)
- m = brace_level_look_up_member_named(level,
+ m = brace_level_look_up_first_member_named(level,
in->designation.head->name, &cnt);
else
- m = brace_level_look_up_member_unnamed(level, &cnt);
+ m = brace_level_look_up_first_member_unnamed(level, &cnt);
if (in->designation.head != NULL) {
if (m == NULL) {
Home |
Main Index |
Thread Index |
Old Index