commit ac1990af330c87012fed5d61a6f671a43ebb9fda
parent 7a251b3e45be287e356b111341b3a76c010e28d5
Author: Roberto E. Vargas Caballero <k0ga@shike2.net>
Date: Sat, 11 Apr 2026 00:05:49 +0200
cc1: Emit hidden wchar strings
Diffstat:
3 files changed, 21 insertions(+), 2 deletions(-)
diff --git a/src/cmd/scc-cc/cc1/init.c b/src/cmd/scc-cc/cc1/init.c
@@ -465,8 +465,8 @@ emitstrings(Node *np)
if (np->op == OSYM) {
sym = np->sym;
- f = sym->flags & (SSTRING|SEMITTED|SINITLST);
- if (f == SSTRING) {
+ f = sym->flags & (SSTRING|SRSTRING|SEMITTED|SINITLST);
+ if (f == SSTRING || f == SRSTRING) {
sym->flags |= SHASINIT;
emit(ODECL, sym);
emit(OINIT, constnode(sym));
diff --git a/tests/cc/execute/0266-wchar.c b/tests/cc/execute/0266-wchar.c
@@ -0,0 +1,18 @@
+#include <wchar.h>
+
+int
+main()
+{
+ wchar_t buf[30] = L"abc";
+
+ if (buf[0] != L'a')
+ return 1;
+ if (buf[1] != L'b')
+ return 2;
+ if (buf[2] != L'c')
+ return 3;
+ if (buf[3] != L'\0')
+ return 4;
+
+ return 0;
+}
diff --git a/tests/cc/execute/scc-tests.lst b/tests/cc/execute/scc-tests.lst
@@ -256,3 +256,4 @@
0263-macro.c
0264-wchar.c
0265-wchar.c
+0266-wchar.c