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: inline macro Sflag in cases of exp...
details: https://anonhg.NetBSD.org/src/rev/7317fc685e52
branches: trunk
changeset: 365881:7317fc685e52
user: rillig <rillig%NetBSD.org@localhost>
date: Sat Apr 30 19:18:48 2022 +0000
description:
lint: inline macro Sflag in cases of expected behavior
In the grammar rules 'enums_with_opt_comma' and 'block_item_list',
checking for allow_c99 was redundant since c99ism does not warn in C99
mode.
In the grammar rule 'designator', align the two actions structurally.
No functional change.
diffstat:
usr.bin/xlint/lint1/cgram.y | 18 ++++++++----------
usr.bin/xlint/lint1/func.c | 6 +++---
usr.bin/xlint/lint1/tree.c | 14 +++++++-------
3 files changed, 18 insertions(+), 20 deletions(-)
diffs (150 lines):
diff -r 1dd94e484f7d -r 7317fc685e52 usr.bin/xlint/lint1/cgram.y
--- a/usr.bin/xlint/lint1/cgram.y Sat Apr 30 18:51:00 2022 +0000
+++ b/usr.bin/xlint/lint1/cgram.y Sat Apr 30 19:18:48 2022 +0000
@@ -1,5 +1,5 @@
%{
-/* $NetBSD: cgram.y,v 1.407 2022/04/29 22:44:44 rillig Exp $ */
+/* $NetBSD: cgram.y,v 1.408 2022/04/30 19:18:48 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.407 2022/04/29 22:44:44 rillig Exp $");
+__RCSID("$NetBSD: cgram.y,v 1.408 2022/04/30 19:18:48 rillig Exp $");
#endif
#include <limits.h>
@@ -500,7 +500,7 @@
begin_initialization(tmp);
cgram_declare(tmp, true, NULL);
} init_lbrace initializer_list comma_opt init_rbrace {
- if (!Sflag)
+ if (!allow_c99)
/* compound literals are a C99/GCC extension */
gnuism(319);
$$ = build_name(*current_initsym(), false);
@@ -1103,9 +1103,7 @@
enums_with_opt_comma: /* helper for C99 6.7.2.2 */
enumerator_list
| enumerator_list T_COMMA {
- if (Sflag) {
- /* C99 6.7.2.2p1 allows trailing ',' */
- } else if (sflag) {
+ if (!allow_c99 && !allow_trad) {
/* trailing ',' prohibited in enum declaration */
error(54);
} else {
@@ -1581,13 +1579,13 @@
designator: /* C99 6.7.8 "Initialization" */
T_LBRACK range T_RBRACK {
- add_designator_subscript($2);
- if (!Sflag)
+ if (!allow_c99)
/* array initializer with designators is a C99 ... */
warning(321);
+ add_designator_subscript($2);
}
| T_POINT identifier {
- if (!Sflag)
+ if (!allow_c99)
/* struct or union member name in initializer is ... */
warning(313);
add_designator_member($2);
@@ -1704,7 +1702,7 @@
block_item_list: /* C99 6.8.2 */
block_item
| block_item_list block_item {
- if (!Sflag && $1 && !$2)
+ if ($1 && !$2)
/* declarations after statements is a C99 feature */
c99ism(327);
$$ = $1 || $2;
diff -r 1dd94e484f7d -r 7317fc685e52 usr.bin/xlint/lint1/func.c
--- a/usr.bin/xlint/lint1/func.c Sat Apr 30 18:51:00 2022 +0000
+++ b/usr.bin/xlint/lint1/func.c Sat Apr 30 19:18:48 2022 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: func.c,v 1.132 2022/04/09 23:41:22 rillig Exp $ */
+/* $NetBSD: func.c,v 1.133 2022/04/30 19:18:48 rillig Exp $ */
/*
* Copyright (c) 1994, 1995 Jochen Pohl
@@ -37,7 +37,7 @@
#include <sys/cdefs.h>
#if defined(__RCSID) && !defined(lint)
-__RCSID("$NetBSD: func.c,v 1.132 2022/04/09 23:41:22 rillig Exp $");
+__RCSID("$NetBSD: func.c,v 1.133 2022/04/30 19:18:48 rillig Exp $");
#endif
#include <stdlib.h>
@@ -359,7 +359,7 @@
return;
/* C99 5.1.2.2.3 "Program termination" p1 */
- if (Sflag && strcmp(funcsym->s_name, "main") == 0)
+ if (allow_c99 && strcmp(funcsym->s_name, "main") == 0)
return;
/* function %s falls off bottom without returning value */
diff -r 1dd94e484f7d -r 7317fc685e52 usr.bin/xlint/lint1/tree.c
--- a/usr.bin/xlint/lint1/tree.c Sat Apr 30 18:51:00 2022 +0000
+++ b/usr.bin/xlint/lint1/tree.c Sat Apr 30 19:18:48 2022 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: tree.c,v 1.436 2022/04/19 23:16:14 rillig Exp $ */
+/* $NetBSD: tree.c,v 1.437 2022/04/30 19:18:48 rillig Exp $ */
/*
* Copyright (c) 1994, 1995 Jochen Pohl
@@ -37,7 +37,7 @@
#include <sys/cdefs.h>
#if defined(__RCSID) && !defined(lint)
-__RCSID("$NetBSD: tree.c,v 1.436 2022/04/19 23:16:14 rillig Exp $");
+__RCSID("$NetBSD: tree.c,v 1.437 2022/04/30 19:18:48 rillig Exp $");
#endif
#include <float.h>
@@ -179,7 +179,7 @@
}
if (block_level > 0 && strcmp(sym->s_name, "__func__") == 0) {
- if (!Sflag)
+ if (!allow_c99)
/* __func__ is a C99 feature */
warning(317);
sym->s_type = block_derive_type(gettyp(CHAR), PTR);
@@ -248,10 +248,10 @@
if (allow_gcc && is_gcc_bool_builtin(sym->s_name))
sym->s_type = gettyp(BOOL);
- } else if (Sflag) {
+ } else if (allow_c99) {
/* function '%s' implicitly declared to return int */
error(215, sym->s_name);
- } else if (sflag) {
+ } else if (!allow_trad) {
/* function '%s' implicitly declared to return int */
warning(215, sym->s_name);
}
@@ -978,7 +978,7 @@
* that there is really a difference between
* ANSI C and traditional C.
*/
- if (hflag && !Sflag)
+ if (hflag && !allow_c99)
/* semantics of '%s' change in ANSI C; use ... */
warning(118, mp->m_name);
}
@@ -2220,7 +2220,7 @@
if (op == CVT)
return;
- if (Sflag && nt == BOOL)
+ if (allow_c99 && nt == BOOL)
return; /* See C99 6.3.1.2 */
if (Pflag && pflag && aflag > 0 &&
Home |
Main Index |
Thread Index |
Old Index