Module Name: src
Committed By: rillig
Date: Mon May 3 07:08:54 UTC 2021
Modified Files:
src/tests/usr.bin/xlint/lint1: gcc_attribute.c gcc_attribute.exp
src/usr.bin/xlint/lint1: func.c lex.c
Log Message:
lint: allow variables to be named 'pcs'
To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 src/tests/usr.bin/xlint/lint1/gcc_attribute.c \
src/tests/usr.bin/xlint/lint1/gcc_attribute.exp
cvs rdiff -u -r1.106 -r1.107 src/usr.bin/xlint/lint1/func.c
cvs rdiff -u -r1.32 -r1.33 src/usr.bin/xlint/lint1/lex.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/tests/usr.bin/xlint/lint1/gcc_attribute.c
diff -u src/tests/usr.bin/xlint/lint1/gcc_attribute.c:1.4 src/tests/usr.bin/xlint/lint1/gcc_attribute.c:1.5
--- src/tests/usr.bin/xlint/lint1/gcc_attribute.c:1.4 Mon May 3 06:24:18 2021
+++ src/tests/usr.bin/xlint/lint1/gcc_attribute.c Mon May 3 07:08:54 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: gcc_attribute.c,v 1.4 2021/05/03 06:24:18 rillig Exp $ */
+/* $NetBSD: gcc_attribute.c,v 1.5 2021/05/03 07:08:54 rillig Exp $ */
# 3 "gcc_attribute.c"
/*
@@ -41,13 +41,15 @@ function_with_unknown_attribute(void);
/*
* There is an attribute called 'pcs', but that attribute must not prevent an
- * ordinary variable from being named the same.
+ * ordinary variable from being named the same. Starting with scan.l 1.77
+ * from 2017-01-07, that variable name generated a syntax error. Fixed in
+ * lex.c 1.33 from 2021-05-03.
*
* Seen in yds.c, function yds_allocate_slots.
*/
-void
+int
local_variable_pcs(void)
{
- int pcs = 3; /* expect: syntax error 'pcs' *//*FIXME*/
+ int pcs = 3;
return pcs;
}
Index: src/tests/usr.bin/xlint/lint1/gcc_attribute.exp
diff -u src/tests/usr.bin/xlint/lint1/gcc_attribute.exp:1.4 src/tests/usr.bin/xlint/lint1/gcc_attribute.exp:1.5
--- src/tests/usr.bin/xlint/lint1/gcc_attribute.exp:1.4 Mon May 3 06:24:18 2021
+++ src/tests/usr.bin/xlint/lint1/gcc_attribute.exp Mon May 3 07:08:54 2021
@@ -1,2 +1 @@
gcc_attribute.c(39): error: syntax error 'unknown_attribute' [249]
-gcc_attribute.c(51): error: syntax error 'pcs' [249]
Index: src/usr.bin/xlint/lint1/func.c
diff -u src/usr.bin/xlint/lint1/func.c:1.106 src/usr.bin/xlint/lint1/func.c:1.107
--- src/usr.bin/xlint/lint1/func.c:1.106 Mon Apr 19 13:18:43 2021
+++ src/usr.bin/xlint/lint1/func.c Mon May 3 07:08:54 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: func.c,v 1.106 2021/04/19 13:18:43 rillig Exp $ */
+/* $NetBSD: func.c,v 1.107 2021/05/03 07:08:54 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.106 2021/04/19 13:18:43 rillig Exp $");
+__RCSID("$NetBSD: func.c,v 1.107 2021/05/03 07:08:54 rillig Exp $");
#endif
#include <stdlib.h>
@@ -1120,6 +1120,12 @@ global_clean_up_decl(bool silent)
}
dcs->d_asm = false;
+
+ /*
+ * Needed for BSD yacc in case of parse errors; GNU Bison 3.0.4 is
+ * fine. See gcc_attribute.c, function_with_unknown_attribute.
+ */
+ attron = false;
}
/*
Index: src/usr.bin/xlint/lint1/lex.c
diff -u src/usr.bin/xlint/lint1/lex.c:1.32 src/usr.bin/xlint/lint1/lex.c:1.33
--- src/usr.bin/xlint/lint1/lex.c:1.32 Mon May 3 03:46:55 2021
+++ src/usr.bin/xlint/lint1/lex.c Mon May 3 07:08:54 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: lex.c,v 1.32 2021/05/03 03:46:55 rillig Exp $ */
+/* $NetBSD: lex.c,v 1.33 2021/05/03 07:08:54 rillig Exp $ */
/*
* Copyright (c) 1996 Christopher G. Demetriou. All Rights Reserved.
@@ -38,7 +38,7 @@
#include <sys/cdefs.h>
#if defined(__RCSID) && !defined(lint)
-__RCSID("$NetBSD: lex.c,v 1.32 2021/05/03 03:46:55 rillig Exp $");
+__RCSID("$NetBSD: lex.c,v 1.33 2021/05/03 07:08:54 rillig Exp $");
#endif
#include <ctype.h>
@@ -197,7 +197,7 @@ static struct kwtab {
kwdef_token( "optimize", T_AT_OPTIMIZE, 0,0,1,1,5),
kwdef_token( "packed", T_AT_PACKED, 0,0,1,1,5),
kwdef_token( "packed", T_PACKED, 0,0,0,0,2),
- kwdef_token( "pcs", T_AT_PCS, 0,0,0,0,5),
+ kwdef_token( "pcs", T_AT_PCS, 0,0,1,1,5),
kwdef_token( "printf", T_AT_FORMAT_PRINTF, 0,0,1,1,5),
kwdef_token( "pure", T_AT_PURE, 0,0,1,1,5),
kwdef_token( "real", T_REAL, 0,1,0,0,4),