aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--cc.h1
-rw-r--r--expr.c12
-rw-r--r--targ.c2
3 files changed, 12 insertions, 3 deletions
diff --git a/cc.h b/cc.h
index 8978d89..0c0d08b 100644
--- a/cc.h
+++ b/cc.h
@@ -410,6 +410,7 @@ extern struct type typevalist, typevalistptr;
struct target {
const char *name;
+ struct type *typewchar;
};
extern struct target *targ;
diff --git a/expr.c b/expr.c
index 2e74ba4..591d80a 100644
--- a/expr.c
+++ b/expr.c
@@ -415,6 +415,7 @@ primaryexpr(struct scope *s)
{
struct expr *e;
struct decl *d;
+ struct type *t;
char *src, *dst, *end;
int base;
@@ -453,10 +454,15 @@ primaryexpr(struct scope *s)
break;
case TCHARCONST:
src = tok.lit;
- if (*src != '\'')
- fatal("wide character constant not yet implemented");
+ t = &typeint;
+ switch (*src) {
+ case 'L': ++src; t = targ->typewchar; break;
+ case 'u': ++src; t = &typeushort; break;
+ case 'U': ++src; t = &typeuint; break;
+ }
+ assert(*src == '\'');
++src;
- e = mkconstexpr(&typeint, unescape(&src));
+ e = mkconstexpr(t, unescape(&src));
if (*src != '\'')
error(&tok.loc, "character constant contains more than one character: %c", *src);
next();
diff --git a/targ.c b/targ.c
index a3fd2f0..5a2f806 100644
--- a/targ.c
+++ b/targ.c
@@ -8,9 +8,11 @@ struct target *targ;
static struct target alltargs[] = {
{
.name = "x86_64",
+ .typewchar = &typeint,
},
{
.name = "aarch64",
+ .typewchar = &typeuint,
},
};