diff options
author | Xavier Leroy <xavierleroy@users.noreply.github.com> | 2022-09-19 16:37:17 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-09-19 16:37:17 +0200 |
commit | 994c6c34182606385140e5695e33c90507ce59ee (patch) | |
tree | e9291d64997dd3e2ac8660c0e6fbe1b9a597799e /cparser/Ceval.ml | |
parent | 103aa7074a9dd3b1bcb2864d52c89292a2ab7bff (diff) | |
download | compcert-994c6c34182606385140e5695e33c90507ce59ee.tar.gz compcert-994c6c34182606385140e5695e33c90507ce59ee.zip |
Support C11 Unicode string literals and character constants (#452)
* Support C11 Unicode string literals and character constants
* Add tests for C11 string literals and character constants
* Better error message for ill-formed universal character names
E.g. \u followed by fewer than 4 hex digits, or \U followed by fewer than 8 hex digits.
* Add new warning `invalid-utf8` for byte sequences that are not valid UTF8.
The warning is activated but not fatal by default.
* Warn on uses of C11 Unicode character constants and string literals
This uses the `c11-extensions` warning, which is off by default.
* Support preprocessing option -finput-charset= for GNU toolchains
Diffstat (limited to 'cparser/Ceval.ml')
-rw-r--r-- | cparser/Ceval.ml | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/cparser/Ceval.ml b/cparser/Ceval.ml index 14f61e06..0800e25b 100644 --- a/cparser/Ceval.ml +++ b/cparser/Ceval.ml @@ -72,7 +72,7 @@ let normalize_int n ik = type value = | I of int64 | S of string - | WS of int64 list + | WS of int64 list * ikind let boolean_value v = match v with @@ -83,7 +83,7 @@ let constant = function | CInt(v, ik, _) -> I (normalize_int v ik) | CFloat(v, fk) -> raise Notconst | CStr s -> S s - | CWStr s -> WS s + | CWStr(s, ik) -> WS(s, ik) | CEnum(id, v) -> I v let is_signed env ty = @@ -274,7 +274,7 @@ let constant_expr env ty e = | TInt(ik, _), I n -> Some(CInt(n, ik, "")) | TPtr(_, _), I n -> Some(CInt(n, ptr_t_ikind (), "")) | (TArray(_, _, _) | TPtr(_, _)), S s -> Some(CStr s) - | (TArray(_, _, _) | TPtr(_, _)), WS s -> Some(CWStr s) + | (TArray(_, _, _) | TPtr(_, _)), WS(s, ik) -> Some(CWStr(s, ik)) | TEnum(_, _), I n -> Some(CInt(n, enum_ikind, "")) | _ -> None with Notconst -> None |