@@ -2152,6 +2152,9 @@ Lexer::parse_raw_string (location_t loc, int initial_hash_count)
str.reserve (16); // some sensible default
int length = 1 + initial_hash_count;
+ current_column += length;
+
+ const location_t string_begin_locus = get_current_location ();
if (initial_hash_count > 0)
skip_input (initial_hash_count - 1);
@@ -2162,10 +2165,11 @@ Lexer::parse_raw_string (location_t loc, int initial_hash_count)
rust_error_at (get_current_location (), "raw string has no opening %<\"%>");
length++;
+ current_column++;
skip_input ();
current_char = peek_input ();
- while (!current_char.is_eof ())
+ while (true)
{
if (current_char.value == '"')
{
@@ -2186,19 +2190,30 @@ Lexer::parse_raw_string (location_t loc, int initial_hash_count)
skip_input (initial_hash_count);
current_char = peek_input ();
length += initial_hash_count + 1;
+ current_column += initial_hash_count + 1;
break;
}
}
+ else if (current_char.is_eof ())
+ {
+ rust_error_at (string_begin_locus, "unended raw string literal");
+ return Token::make (END_OF_FILE, get_current_location ());
+ }
length++;
+ current_column++;
+ if (current_char == '\n')
+ {
+ current_line++;
+ current_column = 1;
+ start_line (current_line, max_column_hint);
+ }
str += current_char.as_string ();
skip_input ();
current_char = peek_input ();
}
- current_column += length;
-
loc += length - 1;
str.shrink_to_fit ();
new file mode 100644
@@ -0,0 +1,6 @@
+const X: &'static str = r#"12
+12"#;
+
+BREAK
+// { dg-error "unrecognised token" "" { target *-*-* } .-1 }
+// { dg-excess-errors "error 'failed to parse item' does not have location" }