Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/tests/usr.bin/xlint/lint1 tests/lint1: reproduce parse error...



details:   https://anonhg.NetBSD.org/src/rev/2268bf3d36e9
branches:  trunk
changeset: 1026541:2268bf3d36e9
user:      rillig <rillig%NetBSD.org@localhost>
date:      Sun Nov 28 09:47:18 2021 +0000

description:
tests/lint1: reproduce parse error for accidentally exported name

Seen in usr.sbin/cpuctl/aarch64.c line 118.

error: aarch64.ln:857:
    not alnum or _:  (for '118d-1.0d1200000000_tmpA16PcC')

The name 00000000_tmp was not supposed to be exported.

diffstat:

 tests/usr.bin/xlint/lint1/emit.c      |  21 ++++++++++++++++++++-
 tests/usr.bin/xlint/lint1/emit.exp-ln |   3 +++
 2 files changed, 23 insertions(+), 1 deletions(-)

diffs (42 lines):

diff -r d3b5d6f92dc2 -r 2268bf3d36e9 tests/usr.bin/xlint/lint1/emit.c
--- a/tests/usr.bin/xlint/lint1/emit.c  Sun Nov 28 09:16:46 2021 +0000
+++ b/tests/usr.bin/xlint/lint1/emit.c  Sun Nov 28 09:47:18 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: emit.c,v 1.7 2021/09/10 20:02:51 rillig Exp $  */
+/*     $NetBSD: emit.c,v 1.8 2021/11/28 09:47:18 rillig Exp $  */
 # 3 "emit.c"
 
 /*
@@ -285,3 +285,22 @@
        declared_used_var++;
        defined_used_var++;
 }
+
+/*
+ * Since C99, an initializer may contain a compound expression. This allows
+ * to create trees of pointer data structures at compile time.
+ *
+ * The objects that are created for these compound literals are unnamed,
+ * therefore there is no point in exporting them to the .ln file.
+ *
+ * Before TODO, lint exported them.
+ */
+struct compound_expression_in_initializer {
+       const char * const *info;
+};
+
+struct compound_expression_in_initializer compound = {
+       .info = (const char *[16]){
+               [0] = "zero",
+       },
+};
diff -r d3b5d6f92dc2 -r 2268bf3d36e9 tests/usr.bin/xlint/lint1/emit.exp-ln
--- a/tests/usr.bin/xlint/lint1/emit.exp-ln     Sun Nov 28 09:16:46 2021 +0000
+++ b/tests/usr.bin/xlint/lint1/emit.exp-ln     Sun Nov 28 09:47:18 2021 +0000
@@ -81,3 +81,6 @@
 285u0.285x17declared_used_var
 286u0.286x16defined_used_var
 283d0.283d8use_varsF0V
+302d0.302d8compoundsT134compound_expression_in_initializer
+303d-1.0d1200000000_tmpA16PcC
+305u0.305x1200000000_tmp



Home | Main Index | Thread Index | Old Index