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 for malforme...
details: https://anonhg.NetBSD.org/src/rev/c181bbc98b88
branches: trunk
changeset: 984496:c181bbc98b88
user: rillig <rillig%NetBSD.org@localhost>
date: Sat Jul 10 10:30:26 2021 +0000
description:
lint: fix assertion failure for malformed member declaration
diffstat:
tests/usr.bin/xlint/lint1/msg_249.c | 14 +++++++++++++-
tests/usr.bin/xlint/lint1/msg_249.exp | 1 +
usr.bin/xlint/lint1/cgram.y | 19 +++++++++++--------
3 files changed, 25 insertions(+), 9 deletions(-)
diffs (80 lines):
diff -r c325eda3d9d1 -r c181bbc98b88 tests/usr.bin/xlint/lint1/msg_249.c
--- a/tests/usr.bin/xlint/lint1/msg_249.c Sat Jul 10 09:53:00 2021 +0000
+++ b/tests/usr.bin/xlint/lint1/msg_249.c Sat Jul 10 10:30:26 2021 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: msg_249.c,v 1.5 2021/07/08 20:11:15 rillig Exp $ */
+/* $NetBSD: msg_249.c,v 1.6 2021/07/10 10:30:26 rillig Exp $ */
# 3 "msg_249.c"
// Test for message: syntax error '%s' [249]
@@ -45,3 +45,15 @@
{
return &recover_from_rparen;
}
+
+struct cover_member_declaration {
+ /* cover 'noclass_declmods ... notype_member_decls' */
+ const noclass_declmods;
+
+ /* cover 'noclass_declspecs ...' */
+ const int noclass_declspecs;
+
+ /* cover 'noclass_declmods deftyp ...' */
+ /* expect+1: error: syntax error 'unnamed member' [249] */
+ const;
+};
diff -r c325eda3d9d1 -r c181bbc98b88 tests/usr.bin/xlint/lint1/msg_249.exp
--- a/tests/usr.bin/xlint/lint1/msg_249.exp Sat Jul 10 09:53:00 2021 +0000
+++ b/tests/usr.bin/xlint/lint1/msg_249.exp Sat Jul 10 10:30:26 2021 +0000
@@ -1,3 +1,4 @@
msg_249.c(10): error: syntax error '"' [249]
msg_249.c(19): error: syntax error '"' [249]
msg_249.c(33): error: syntax error ')' [249]
+msg_249.c(58): error: syntax error 'unnamed member' [249]
diff -r c325eda3d9d1 -r c181bbc98b88 usr.bin/xlint/lint1/cgram.y
--- a/usr.bin/xlint/lint1/cgram.y Sat Jul 10 09:53:00 2021 +0000
+++ b/usr.bin/xlint/lint1/cgram.y Sat Jul 10 10:30:26 2021 +0000
@@ -1,5 +1,5 @@
%{
-/* $NetBSD: cgram.y,v 1.285 2021/07/10 09:53:00 rillig Exp $ */
+/* $NetBSD: cgram.y,v 1.286 2021/07/10 10:30:26 rillig Exp $ */
/*
* Copyright (c) 1996 Christopher G. Demetriou. All Rights Reserved.
@@ -35,7 +35,7 @@
#include <sys/cdefs.h>
#if defined(__RCSID) && !defined(lint)
-__RCSID("$NetBSD: cgram.y,v 1.285 2021/07/10 09:53:00 rillig Exp $");
+__RCSID("$NetBSD: cgram.y,v 1.286 2021/07/10 10:30:26 rillig Exp $");
#endif
#include <limits.h>
@@ -690,18 +690,21 @@
}
| noclass_declmods deftyp type_attribute_opt {
symtyp = FVFT;
- /* struct or union member must be named */
if (!Sflag)
/* anonymous struct/union members is a C9X feature */
warning(49);
- /* add all the members of the anonymous struct/union */
- lint_assert(is_struct_or_union(dcs->d_type->t_tspec));
- $$ = dcs->d_type->t_str->sou_first_member;
- anonymize($$);
+ if (is_struct_or_union(dcs->d_type->t_tspec)) {
+ $$ = dcs->d_type->t_str->sou_first_member;
+ /* add all the members of the anonymous struct/union */
+ anonymize($$);
+ } else {
+ /* syntax error '%s' */
+ error(249, "unnamed member");
+ $$ = NULL;
+ }
}
| noclass_declspecs deftyp type_attribute_opt {
symtyp = FVFT;
- /* struct or union member must be named */
if (!Sflag)
/* anonymous struct/union members is a C9X feature */
warning(49);
Home |
Main Index |
Thread Index |
Old Index