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: allow variables to be named 'pcs'



details:   https://anonhg.NetBSD.org/src/rev/8707f2494996
branches:  trunk
changeset: 378996:8707f2494996
user:      rillig <rillig%NetBSD.org@localhost>
date:      Mon May 03 07:08:54 2021 +0000

description:
lint: allow variables to be named 'pcs'

diffstat:

 tests/usr.bin/xlint/lint1/gcc_attribute.c   |  10 ++++++----
 tests/usr.bin/xlint/lint1/gcc_attribute.exp |   1 -
 usr.bin/xlint/lint1/func.c                  |  10 ++++++++--
 usr.bin/xlint/lint1/lex.c                   |   6 +++---
 4 files changed, 17 insertions(+), 10 deletions(-)

diffs (92 lines):

diff -r 390620b9aabb -r 8707f2494996 tests/usr.bin/xlint/lint1/gcc_attribute.c
--- a/tests/usr.bin/xlint/lint1/gcc_attribute.c Mon May 03 06:24:18 2021 +0000
+++ b/tests/usr.bin/xlint/lint1/gcc_attribute.c Mon May 03 07:08:54 2021 +0000
@@ -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;
 }
diff -r 390620b9aabb -r 8707f2494996 tests/usr.bin/xlint/lint1/gcc_attribute.exp
--- a/tests/usr.bin/xlint/lint1/gcc_attribute.exp       Mon May 03 06:24:18 2021 +0000
+++ b/tests/usr.bin/xlint/lint1/gcc_attribute.exp       Mon May 03 07:08:54 2021 +0000
@@ -1,2 +1,1 @@
 gcc_attribute.c(39): error: syntax error 'unknown_attribute' [249]
-gcc_attribute.c(51): error: syntax error 'pcs' [249]
diff -r 390620b9aabb -r 8707f2494996 usr.bin/xlint/lint1/func.c
--- a/usr.bin/xlint/lint1/func.c        Mon May 03 06:24:18 2021 +0000
+++ b/usr.bin/xlint/lint1/func.c        Mon May 03 07:08:54 2021 +0000
@@ -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;
 }
 
 /*
diff -r 390620b9aabb -r 8707f2494996 usr.bin/xlint/lint1/lex.c
--- a/usr.bin/xlint/lint1/lex.c Mon May 03 06:24:18 2021 +0000
+++ b/usr.bin/xlint/lint1/lex.c Mon May 03 07:08:54 2021 +0000
@@ -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),



Home | Main Index | Thread Index | Old Index