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: in C99 mode, allow trailing comma ...
details: https://anonhg.NetBSD.org/src/rev/f1a5364f1e70
branches: trunk
changeset: 365246:f1a5364f1e70
user: rillig <rillig%NetBSD.org@localhost>
date: Sat Apr 16 09:22:25 2022 +0000
description:
lint: in C99 mode, allow trailing comma in enum declarations
Adjust the test to be run in C90 mode instead of traditional mode, since
traditional C didn't have enums.
diffstat:
tests/usr.bin/xlint/lint1/accept.sh | 5 +++--
tests/usr.bin/xlint/lint1/decl_enum.c | 7 ++++++-
tests/usr.bin/xlint/lint1/msg_054.c | 7 ++++---
tests/usr.bin/xlint/lint1/msg_054.exp | 2 +-
usr.bin/xlint/lint1/cgram.y | 9 ++++++---
5 files changed, 20 insertions(+), 10 deletions(-)
diffs (102 lines):
diff -r cdb88a7b672e -r f1a5364f1e70 tests/usr.bin/xlint/lint1/accept.sh
--- a/tests/usr.bin/xlint/lint1/accept.sh Sat Apr 16 09:20:01 2022 +0000
+++ b/tests/usr.bin/xlint/lint1/accept.sh Sat Apr 16 09:22:25 2022 +0000
@@ -1,5 +1,5 @@
#! /bin/sh
-# $NetBSD: accept.sh,v 1.8 2021/08/26 19:23:25 rillig Exp $
+# $NetBSD: accept.sh,v 1.9 2022/04/16 09:22:25 rillig Exp $
#
# Copyright (c) 2021 The NetBSD Foundation, Inc.
# All rights reserved.
@@ -33,7 +33,8 @@
set -eu
-. './t_integration.sh'
+: "${archsubdir:=$(make -v ARCHSUBDIR)}"
+. './t_integration.sh' # for configure_test_case
for pattern in "$@"; do
# shellcheck disable=SC2231
diff -r cdb88a7b672e -r f1a5364f1e70 tests/usr.bin/xlint/lint1/decl_enum.c
--- a/tests/usr.bin/xlint/lint1/decl_enum.c Sat Apr 16 09:20:01 2022 +0000
+++ b/tests/usr.bin/xlint/lint1/decl_enum.c Sat Apr 16 09:22:25 2022 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: decl_enum.c,v 1.2 2022/04/08 21:29:29 rillig Exp $ */
+/* $NetBSD: decl_enum.c,v 1.3 2022/04/16 09:22:25 rillig Exp $ */
# 3 "decl_enum.c"
/*
@@ -58,3 +58,8 @@
typedef int reveal_o2[-o2];
/* expect+1: error: negative array dimension (-10002) [20] */
typedef int reveal_o3[-o3];
+
+/* Since C99, a trailing comma is allowed in an enum declaration. */
+enum trailing_comma {
+ constant,
+};
diff -r cdb88a7b672e -r f1a5364f1e70 tests/usr.bin/xlint/lint1/msg_054.c
--- a/tests/usr.bin/xlint/lint1/msg_054.c Sat Apr 16 09:20:01 2022 +0000
+++ b/tests/usr.bin/xlint/lint1/msg_054.c Sat Apr 16 09:22:25 2022 +0000
@@ -1,12 +1,13 @@
-/* $NetBSD: msg_054.c,v 1.3 2021/01/31 11:12:07 rillig Exp $ */
+/* $NetBSD: msg_054.c,v 1.4 2022/04/16 09:22:25 rillig Exp $ */
# 3 "msg_054.c"
/* Test for message: trailing ',' prohibited in enum declaration [54] */
-/* lint1-flags: -tw */
+/* lint1-flags: -sw */
enum color {
RED,
GREEN,
BLUE,
-}; /* expect: 54 */
+};
+/* expect-1: error: trailing ',' prohibited in enum declaration [54] */
diff -r cdb88a7b672e -r f1a5364f1e70 tests/usr.bin/xlint/lint1/msg_054.exp
--- a/tests/usr.bin/xlint/lint1/msg_054.exp Sat Apr 16 09:20:01 2022 +0000
+++ b/tests/usr.bin/xlint/lint1/msg_054.exp Sat Apr 16 09:22:25 2022 +0000
@@ -1,1 +1,1 @@
-msg_054.c(12): warning: trailing ',' prohibited in enum declaration [54]
+msg_054.c(12): error: trailing ',' prohibited in enum declaration [54]
diff -r cdb88a7b672e -r f1a5364f1e70 usr.bin/xlint/lint1/cgram.y
--- a/usr.bin/xlint/lint1/cgram.y Sat Apr 16 09:20:01 2022 +0000
+++ b/usr.bin/xlint/lint1/cgram.y Sat Apr 16 09:22:25 2022 +0000
@@ -1,5 +1,5 @@
%{
-/* $NetBSD: cgram.y,v 1.394 2022/04/10 12:14:10 rillig Exp $ */
+/* $NetBSD: cgram.y,v 1.395 2022/04/16 09:22:25 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.394 2022/04/10 12:14:10 rillig Exp $");
+__RCSID("$NetBSD: cgram.y,v 1.395 2022/04/16 09:22:25 rillig Exp $");
#endif
#include <limits.h>
@@ -1047,6 +1047,7 @@
}
;
+/* K&R ---, C90 6.5.2.2, C99 6.7.2.2, C11 6.7.2.2 */
enum_specifier: /* C99 6.7.2.2 */
enum gcc_attribute_list_opt identifier_sym {
$$ = mktag($3, ENUM, false, false);
@@ -1090,7 +1091,9 @@
enums_with_opt_comma: /* helper for C99 6.7.2.2 */
enumerator_list
| enumerator_list T_COMMA {
- if (sflag) {
+ if (Sflag) {
+ /* C99 6.7.2.2p1 allows trailing ',' */
+ } else if (sflag) {
/* trailing ',' prohibited in enum declaration */
error(54);
} else {
Home |
Main Index |
Thread Index |
Old Index