From 077df7145836eb86278db2ad31316841940babe4 Mon Sep 17 00:00:00 2001 From: Michael Forney Date: Sat, 23 Mar 2024 11:43:34 -0700 Subject: Change type of u8 string literals to unsigned char for C23 --- expr.c | 5 +++-- test/string-u8-type.c | 1 + test/string-u8-type.qbe | 0 3 files changed, 4 insertions(+), 2 deletions(-) create mode 100644 test/string-u8-type.c create mode 100644 test/string-u8-type.qbe diff --git a/expr.c b/expr.c index 20b943e..9a168de 100644 --- a/expr.c +++ b/expr.c @@ -531,11 +531,12 @@ stringconcat(struct stringlit *str, bool forceutf8) len += strlen(src) - 2; next(); } while (tok.kind == TSTRINGLIT); - if (forceutf8 || kind == '8') - kind = 0; + if (forceutf8) + kind = '8'; ++len; /* null byte */ switch (kind) { case 0: t = &typechar; break; + case '8': t = &typeuchar; break; case 'u': t = &typeushort; break; case 'U': t = &typeuint; break; case 'L': t = targ->typewchar; break; diff --git a/test/string-u8-type.c b/test/string-u8-type.c new file mode 100644 index 0000000..d7fe074 --- /dev/null +++ b/test/string-u8-type.c @@ -0,0 +1 @@ +_Static_assert(__builtin_types_compatible_p(__typeof__(u8"abc"), unsigned char[])); diff --git a/test/string-u8-type.qbe b/test/string-u8-type.qbe new file mode 100644 index 0000000..e69de29 -- cgit v1.2.3