Thu Jul 15 20:05:49 2021 UTC ()
lint: remove message 66 about missing semicolon in struct-declaration
(rillig)
diff -r1.1 -r1.2 src/tests/usr.bin/xlint/lint1/decl_struct_c90.c
diff -r1.1 -r1.2 src/tests/usr.bin/xlint/lint1/decl_struct_c90.exp
diff -r1.7 -r1.8 src/tests/usr.bin/xlint/lint1/decl_struct_member.c
diff -r1.6 -r1.7 src/tests/usr.bin/xlint/lint1/decl_struct_member.exp
diff -r1.3 -r1.4 src/tests/usr.bin/xlint/lint1/msg_066.c
diff -r1.2 -r1.3 src/tests/usr.bin/xlint/lint1/msg_066.exp
diff -r1.327 -r1.328 src/usr.bin/xlint/lint1/cgram.y
diff -r1.129 -r1.130 src/usr.bin/xlint/lint1/err.c
--- src/tests/usr.bin/xlint/lint1/decl_struct_c90.c 2021/07/15 19:51:29 1.1
+++ src/tests/usr.bin/xlint/lint1/decl_struct_c90.c 2021/07/15 20:05:49 1.2
@@ -1,4 +1,4 @@
-/* $NetBSD: decl_struct_c90.c,v 1.1 2021/07/15 19:51:29 rillig Exp $ */
+/* $NetBSD: decl_struct_c90.c,v 1.2 2021/07/15 20:05:49 rillig Exp $ */
# 3 "decl_struct_c90.c"
/*
@@ -9,10 +9,13 @@
/*
* All of K&R, C90, C99 require that a struct member declaration is
- * terminated with a semicolon. No idea why lint allows the missing
- * semicolon in non-C90 mode.
+ * terminated with a semicolon.
+ *
+ * Before cgram.y 1.328 from 2021-07-15, lint allowed the missing semicolon
+ * in non-C90 mode, no idea why.
*/
struct missing_semicolon {
int member
};
-/* expect-1: error: syntax requires ';' after last struct/union member [66] */
+/* expect-1: error: syntax error '}' [249] */
+/* expect+1: error: cannot recover from previous errors [224] */
--- src/tests/usr.bin/xlint/lint1/Attic/decl_struct_c90.exp 2021/07/15 19:51:29 1.1
+++ src/tests/usr.bin/xlint/lint1/Attic/decl_struct_c90.exp 2021/07/15 20:05:49 1.2
@@ -1 +1,2 @@
-decl_struct_c90.c(17): error: syntax requires ';' after last struct/union member [66]
+decl_struct_c90.c(19): error: syntax error '}' [249]
+decl_struct_c90.c(22): error: cannot recover from previous errors [224]
--- src/tests/usr.bin/xlint/lint1/decl_struct_member.c 2021/07/15 19:51:29 1.7
+++ src/tests/usr.bin/xlint/lint1/decl_struct_member.c 2021/07/15 20:05:49 1.8
@@ -1,4 +1,4 @@
-/* $NetBSD: decl_struct_member.c,v 1.7 2021/07/15 19:51:29 rillig Exp $ */
+/* $NetBSD: decl_struct_member.c,v 1.8 2021/07/15 20:05:49 rillig Exp $ */
# 3 "decl_struct_member.c"
struct multi_attributes {
@@ -52,7 +52,7 @@
*/
struct {
char a(_)0 /* expect: syntax error '0' */
-} /* expect: ';' after last */
+}
/*
* FIXME: adding a semicolon here triggers another assertion:
*
--- src/tests/usr.bin/xlint/lint1/Attic/decl_struct_member.exp 2021/07/15 19:51:29 1.6
+++ src/tests/usr.bin/xlint/lint1/Attic/decl_struct_member.exp 2021/07/15 20:05:49 1.7
@@ -4,5 +4,4 @@
decl_struct_member.c(38): warning: empty declaration [0]
decl_struct_member.c(47): error: syntax error 'unnamed member' [249]
decl_struct_member.c(54): error: syntax error '0' [249]
-decl_struct_member.c(55): warning: syntax requires ';' after last struct/union member [66]
decl_struct_member.c(62): error: cannot recover from previous errors [224]
--- src/tests/usr.bin/xlint/lint1/msg_066.c 2021/01/31 11:12:07 1.3
+++ src/tests/usr.bin/xlint/lint1/msg_066.c 2021/07/15 20:05:49 1.4
@@ -1,8 +1,15 @@
-/* $NetBSD: msg_066.c,v 1.3 2021/01/31 11:12:07 rillig Exp $ */
+/* $NetBSD: msg_066.c,v 1.4 2021/07/15 20:05:49 rillig Exp $ */
# 3 "msg_066.c"
// Test for message: syntax requires ';' after last struct/union member [66]
+/*
+ * This message was removed in cgram.y 1.328 from 2021-07-15 because all
+ * C standards and even K&R require a semicolon.
+ */
+
struct number {
int value
-}; /* expect: 66 */
+};
+/* expect-1: syntax error '}' [249] */
+/* expect+1: error: cannot recover from previous errors [224] */
--- src/tests/usr.bin/xlint/lint1/Attic/msg_066.exp 2021/01/08 21:25:03 1.2
+++ src/tests/usr.bin/xlint/lint1/Attic/msg_066.exp 2021/07/15 20:05:49 1.3
@@ -1 +1,2 @@
-msg_066.c(8): warning: syntax requires ';' after last struct/union member [66]
+msg_066.c(13): error: syntax error '}' [249]
+msg_066.c(16): error: cannot recover from previous errors [224]
--- src/usr.bin/xlint/lint1/cgram.y 2021/07/15 18:18:15 1.327
+++ src/usr.bin/xlint/lint1/cgram.y 2021/07/15 20:05:49 1.328
@@ -1,5 +1,5 @@
%{
-/* $NetBSD: cgram.y,v 1.327 2021/07/15 18:18:15 rillig Exp $ */
+/* $NetBSD: cgram.y,v 1.328 2021/07/15 20:05:49 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.327 2021/07/15 18:18:15 rillig Exp $");
+__RCSID("$NetBSD: cgram.y,v 1.328 2021/07/15 20:05:49 rillig Exp $");
#endif
#include <limits.h>
@@ -933,26 +933,17 @@
;
struct_declaration_list_with_rbrace: /* see C99 6.7.2.1 */
- struct_declaration_list T_SEMI T_RBRACE
- | struct_declaration_list T_RBRACE {
- if (sflag) {
- /* syntax req. ';' after last struct/union member */
- error(66);
- } else {
- /* syntax req. ';' after last struct/union member */
- warning(66);
- }
- $$ = $1;
- }
+ struct_declaration_list T_RBRACE
| T_RBRACE {
+ /* XXX: This is not allowed by any C standard. */
$$ = NULL;
}
;
struct_declaration_list: /* C99 6.7.2.1 */
struct_declaration
- | struct_declaration_list T_SEMI struct_declaration {
- $$ = lnklst($1, $3);
+ | struct_declaration_list struct_declaration {
+ $$ = lnklst($1, $2);
}
;
@@ -960,22 +951,22 @@
begin_type_noclass_declmods end_type {
/* too late, i know, but getsym() compensates it */
symtyp = FMEMBER;
- } notype_struct_declarators type_attribute_opt {
+ } notype_struct_declarators type_attribute_opt T_SEMI {
symtyp = FVFT;
$$ = $4;
}
| begin_type_noclass_declspecs end_type {
symtyp = FMEMBER;
- } type_struct_declarators type_attribute_opt {
+ } type_struct_declarators type_attribute_opt T_SEMI {
symtyp = FVFT;
$$ = $4;
}
- | begin_type_noclass_declmods end_type type_attribute_opt {
+ | begin_type_noclass_declmods end_type type_attribute_opt T_SEMI {
/* syntax error '%s' */
error(249, "member without type");
$$ = NULL;
}
- | begin_type_noclass_declspecs end_type type_attribute_opt {
+ | begin_type_noclass_declspecs end_type type_attribute_opt T_SEMI {
symtyp = FVFT;
if (!Sflag)
/* anonymous struct/union members is a C9X feature */
@@ -990,7 +981,7 @@
$$ = NULL;
}
}
- | error {
+ | error T_SEMI {
symtyp = FVFT;
$$ = NULL;
}
--- src/usr.bin/xlint/lint1/err.c 2021/07/13 22:01:34 1.129
+++ src/usr.bin/xlint/lint1/err.c 2021/07/15 20:05:49 1.130
@@ -1,4 +1,4 @@
-/* $NetBSD: err.c,v 1.129 2021/07/13 22:01:34 rillig Exp $ */
+/* $NetBSD: err.c,v 1.130 2021/07/15 20:05:49 rillig Exp $ */
/*
* Copyright (c) 1994, 1995 Jochen Pohl
@@ -37,7 +37,7 @@
#include <sys/cdefs.h>
#if defined(__RCSID) && !defined(lint)
-__RCSID("$NetBSD: err.c,v 1.129 2021/07/13 22:01:34 rillig Exp $");
+__RCSID("$NetBSD: err.c,v 1.130 2021/07/15 20:05:49 rillig Exp $");
#endif
#include <sys/types.h>
@@ -120,7 +120,7 @@
"prototype does not match old-style definition", /* 63 */
"()-less function definition", /* 64 */
"%s has no named members", /* 65 */
- "syntax requires ';' after last struct/union member", /* 66 */
+ "", /* 66 */
"cannot return incomplete type", /* 67 */
"typedef already qualified with '%s'", /* 68 */
"inappropriate qualifiers with 'void'", /* 69 */