aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBernhard Schommer <bernhardschommer@gmail.com>2015-03-10 09:22:36 +0100
committerBernhard Schommer <bernhardschommer@gmail.com>2015-03-10 09:22:36 +0100
commit5a027c08f3fed3e52061978e1757ffb255422333 (patch)
tree92ceb94ef94aff3fe22ce11bb21452341f2dd717
parent7d84e131a37d008ac8d3e6b3112dd744bbab0378 (diff)
parent3e01154d693e1c457e1e974f5e9ebaa4601050aa (diff)
downloadcompcert-5a027c08f3fed3e52061978e1757ffb255422333.tar.gz
compcert-5a027c08f3fed3e52061978e1757ffb255422333.zip
Merge branch 'master' into backend_printer
-rw-r--r--Makefile.extr4
-rw-r--r--cparser/Elab.ml19
2 files changed, 12 insertions, 11 deletions
diff --git a/Makefile.extr b/Makefile.extr
index eb578fa9..fed2d78f 100644
--- a/Makefile.extr
+++ b/Makefile.extr
@@ -158,10 +158,6 @@ clean:
rm -f $(GENERATED)
for d in $(ALLDIRS); do rm -f $$d/*.cm[iox] $$d/*.o; done
-cleansource:
- rm -f $(EXECUTABLES)
- for d in $(ALLDIRS); do rm -f $$d/*.cm[iox] $$d/*.o; done
-
# Generation of .depend.extr
depend: $(GENERATED)
diff --git a/cparser/Elab.ml b/cparser/Elab.ml
index bad92cf6..612103a6 100644
--- a/cparser/Elab.ml
+++ b/cparser/Elab.ml
@@ -224,16 +224,21 @@ let elab_char_constant loc wide chars =
let v =
List.fold_left
(fun acc d ->
- if acc >= max_val then
+ if acc < 0L || acc >= max_val then
error loc "character constant overflows";
- if d >= max_digit then
- warning loc "escape sequence is out of range (code 0x%LX)" d;
+ if d < 0L || d >= max_digit then
+ error loc "escape sequence is out of range (code 0x%LX)" d;
Int64.add (Int64.shift_left acc nbits) d)
0L chars in
if not (integer_representable v IInt) then
warning loc "character constant cannot be represented at type 'int'";
- (* C99 6.4.4.4 item 10: single character -> represent at type char *)
- Ceval.normalize_int v (if List.length chars = 1 then IChar else IInt)
+ (* C99 6.4.4.4 item 10: single character -> represent at type char
+ or wchar_t *)
+ Ceval.normalize_int v
+ (if List.length chars = 1 then
+ if wide then wchar_ikind() else IChar
+ else
+ IInt)
let elab_string_literal loc wide chars =
let nbits = if wide then 8 * !config.sizeof_wchar else 8 in
@@ -241,14 +246,14 @@ let elab_string_literal loc wide chars =
List.iter
(fun c ->
if c < 0L || c >= char_max
- then warning loc "escape sequence is out of range (code 0x%LX)" c)
+ then error loc "escape sequence is out of range (code 0x%LX)" c)
chars;
if wide then
CWStr chars
else begin
let res = String.create (List.length chars) in
List.iteri
- (fun i c -> res.[i] <- Char.chr (Int64.to_int c))
+ (fun i c -> res.[i] <- Char.unsafe_chr (Int64.to_int c))
chars;
CStr res
end