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: replace assertion in initializatio...
details: https://anonhg.NetBSD.org/src/rev/3f5ca01bce94
branches: trunk
changeset: 960428:3f5ca01bce94
user: rillig <rillig%NetBSD.org@localhost>
date: Fri Mar 19 01:02:52 2021 +0000
description:
lint: replace assertion in initialization with proper error message
diffstat:
tests/usr.bin/xlint/lint1/d_c99_init.c | 5 ++---
tests/usr.bin/xlint/lint1/d_c99_init.exp | 1 +
usr.bin/xlint/lint1/init.c | 14 ++++++++++----
3 files changed, 13 insertions(+), 7 deletions(-)
diffs (62 lines):
diff -r 1f7f091a7a45 -r 3f5ca01bce94 tests/usr.bin/xlint/lint1/d_c99_init.c
--- a/tests/usr.bin/xlint/lint1/d_c99_init.c Fri Mar 19 00:55:02 2021 +0000
+++ b/tests/usr.bin/xlint/lint1/d_c99_init.c Fri Mar 19 01:02:52 2021 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: d_c99_init.c,v 1.8 2021/03/18 22:51:32 rillig Exp $ */
+/* $NetBSD: d_c99_init.c,v 1.9 2021/03/19 01:02:52 rillig Exp $ */
# 3 "d_c99_init.c"
/*
@@ -128,8 +128,7 @@
int array_with_designator[] = {
111,
- // FIXME: assertion failure '== STRUCT'
- // .member = 222,
+ .member = 222, /* expect: 249 */
333,
};
diff -r 1f7f091a7a45 -r 3f5ca01bce94 tests/usr.bin/xlint/lint1/d_c99_init.exp
--- a/tests/usr.bin/xlint/lint1/d_c99_init.exp Fri Mar 19 00:55:02 2021 +0000
+++ b/tests/usr.bin/xlint/lint1/d_c99_init.exp Fri Mar 19 01:02:52 2021 +0000
@@ -2,3 +2,4 @@
d_c99_init.c(23): too many initializers [174]
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]
diff -r 1f7f091a7a45 -r 3f5ca01bce94 usr.bin/xlint/lint1/init.c
--- a/usr.bin/xlint/lint1/init.c Fri Mar 19 00:55:02 2021 +0000
+++ b/usr.bin/xlint/lint1/init.c Fri Mar 19 01:02:52 2021 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: init.c,v 1.103 2021/03/19 00:55:02 rillig Exp $ */
+/* $NetBSD: init.c,v 1.104 2021/03/19 01:02:52 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.103 2021/03/19 00:55:02 rillig Exp $");
+__RCSID("$NetBSD: init.c,v 1.104 2021/03/19 01:02:52 rillig Exp $");
#endif
#include <stdlib.h>
@@ -436,8 +436,14 @@
debug_step("initializing named member '%s'", namedmem->n_name);
- lint_assert(istk->i_type->t_tspec == STRUCT ||
- istk->i_type->t_tspec == UNION);
+ if (istk->i_type->t_tspec != STRUCT &&
+ istk->i_type->t_tspec != UNION) {
+ /* syntax error '%s' */
+ error(249, "named member must only be used with struct/union");
+ initerr = true;
+ return;
+ }
+
for (m = istk->i_type->t_str->sou_first_member;
m != NULL; m = m->s_next) {
Home |
Main Index |
Thread Index |
Old Index