raw_str += current_char; // x, o, b
skip_input ();
- int length = 1;
+ int length = 2;
+ bool has_valid_digit = false;
current_char = peek_input ();
- length++;
-
// loop through to add entire number to string
- while (is_digit_func (current_char.value) || current_char == '_')
+ while (true)
{
+ if (is_digit_func (current_char.value))
+ {
+ has_valid_digit = true;
+ }
+ else if (current_char != '_')
+ {
+ break;
+ }
length++;
raw_str += current_char;
current_column += length;
+ if (!has_valid_digit)
+ {
+ rust_error_at (loc, ErrorCode::E0768, "no valid digits found for number");
+ }
+
loc += length - 1;
return Token::make_int (loc, std::move (raw_str), suffix_start, base,
--- /dev/null
+#![feature(no_core)]
+#![no_core]
+
+fn main() {
+ let _a = 0x; // { dg-error "no valid digits found for number" }
+ let _b = 0b; // { dg-error "no valid digits found for number" }
+ let _c = 0o; // { dg-error "no valid digits found for number" }
+ let _d = 0x_; // { dg-error "no valid digits found for number" }
+ let _e = 0x_u32; // { dg-error "no valid digits found for number" }
+}