From 365e4f999541d8c8796ccc7210ee8fbf279fb2f1 Mon Sep 17 00:00:00 2001 From: Timothy Bourke Date: Fri, 11 Nov 2016 10:53:03 +0100 Subject: Expose the kind of elaborated char constants --- cparser/Elab.ml | 8 ++++---- cparser/Elab.mli | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/cparser/Elab.ml b/cparser/Elab.ml index 9e17cb7e..73a80c6f 100644 --- a/cparser/Elab.ml +++ b/cparser/Elab.ml @@ -420,11 +420,12 @@ let elab_char_constant loc wide chars = warning loc Unnamed "character constant too long for its type"; (* C99 6.4.4.4 item 10: single character -> represent at type char or wchar_t *) - Ceval.normalize_int v + let k = (if List.length chars = 1 then if wide then wchar_ikind() else IChar else - IInt) + IInt) in + (Ceval.normalize_int v k, k) let elab_string_literal loc wide chars = let nbits = if wide then 8 * !config.sizeof_wchar else 8 in @@ -452,8 +453,7 @@ let elab_constant loc = function let (v, fk) = elab_float_constant f in CFloat(v, fk) | CONST_CHAR(wide, s) -> - let ikind = if wide then wchar_ikind () else IInt in - CInt(elab_char_constant loc wide s, ikind, "") + CInt(fst (elab_char_constant loc wide s), IInt, "") | CONST_STRING(wide, s) -> elab_string_literal loc wide s diff --git a/cparser/Elab.mli b/cparser/Elab.mli index 937e86bf..31d9b281 100644 --- a/cparser/Elab.mli +++ b/cparser/Elab.mli @@ -15,7 +15,7 @@ val elab_int_constant : Cabs.cabsloc -> string -> int64 * C.ikind val elab_float_constant : Cabs.floatInfo -> C.float_cst * C.fkind -val elab_char_constant : Cabs.cabsloc -> bool -> int64 list -> int64 +val elab_char_constant : Cabs.cabsloc -> bool -> int64 list -> int64 * C.ikind val elab_file : Cabs.definition list -> C.program (* This is the main entry point. It transforms a list of toplevel -- cgit