Module Name: src Committed By: rillig Date: Sat Apr 30 19:18:48 UTC 2022
Modified Files: src/usr.bin/xlint/lint1: cgram.y func.c tree.c Log Message: 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. To generate a diff of this commit: cvs rdiff -u -r1.407 -r1.408 src/usr.bin/xlint/lint1/cgram.y cvs rdiff -u -r1.132 -r1.133 src/usr.bin/xlint/lint1/func.c cvs rdiff -u -r1.436 -r1.437 src/usr.bin/xlint/lint1/tree.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/usr.bin/xlint/lint1/cgram.y diff -u src/usr.bin/xlint/lint1/cgram.y:1.407 src/usr.bin/xlint/lint1/cgram.y:1.408 --- src/usr.bin/xlint/lint1/cgram.y:1.407 Fri Apr 29 22:44:44 2022 +++ src/usr.bin/xlint/lint1/cgram.y Sat Apr 30 19:18:48 2022 @@ -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 @@ postfix_expression: 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 @@ enum_decl_lbrace: /* helper for C99 6.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_list: /* C99 6.7.8 "Initiali 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 @@ compound_statement_rbrace: 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; Index: src/usr.bin/xlint/lint1/func.c diff -u src/usr.bin/xlint/lint1/func.c:1.132 src/usr.bin/xlint/lint1/func.c:1.133 --- src/usr.bin/xlint/lint1/func.c:1.132 Sat Apr 9 23:41:22 2022 +++ src/usr.bin/xlint/lint1/func.c Sat Apr 30 19:18:48 2022 @@ -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 @@ check_missing_return_value(void) 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 */ Index: src/usr.bin/xlint/lint1/tree.c diff -u src/usr.bin/xlint/lint1/tree.c:1.436 src/usr.bin/xlint/lint1/tree.c:1.437 --- src/usr.bin/xlint/lint1/tree.c:1.436 Tue Apr 19 23:16:14 2022 +++ src/usr.bin/xlint/lint1/tree.c Sat Apr 30 19:18:48 2022 @@ -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 @@ fallback_symbol(sym_t *sym) } 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 @@ build_name_call(sym_t *sym) 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 @@ typeok_shl(const mod_t *mp, tspec_t lt, * 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 @@ check_integer_conversion(op_t op, int ar 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 &&