Make sure we error out on overflow instead of truncating in all cases.
I've used as overflow string: "Integer literal is too large", based
on what I found at
<rust-lang/rust>/src/test/ui/parser/int-literal-too-large-span.rs
but perhaps someone has a better idea.
Tested on x86_64-linux, with a build with --enable-targets=all.
}
}
- value = strtoulst (number.c_str () + offset, NULL, radix);
+ const char *trailer;
+ value = strtoulst (number.c_str () + offset, &trailer, radix);
+ if (*trailer != '\0')
+ error ("Integer literal is too large");
if (implicit_i32 && value >= ((uint64_t) 1) << 31)
type = get_type ("i64");
return [list "i64" $n]
} else {
# Overflow.
- # Some truncated value, should be re_overflow.
- return [list i64 $any]
+ return [list $re_overflow $re_overflow]
}
} elseif { $lang == "d" } {
if { [fits_in_type $n 32 s] } {
set re_overflow "Overflow on numeric constant\\."
} elseif { $lang == "ada" } {
set re_overflow "Integer literal out of range"
+ } elseif { $lang == "rust" } {
+ set re_overflow "Integer literal is too large"
} else {
set re_overflow "Numeric constant too large\\."
}