forked from Rust-GCC/gccrs
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Handle newlines during string parsing while lexing
If newline strings are encountered while lexing, the lexer now handles newline characters by incrementing current line number. This provides correct line number when displaying errors. If the lexer encounters end of file before string end, then it will use the start of the string as the location to an report error. gcc/rust/ChangeLog: * lex/rust-lex.cc (Lexer::parse_byte_string): Handle newline while parsing byte strings (Lexer::parse_string): Handle newline while parsing strings Signed-off-by: Nirmal Patel <[email protected]>
- Loading branch information
1 parent
a12143b
commit b864866
Showing
3 changed files
with
63 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
const A: &'static u8 = b" | ||
"; | ||
const B: &'static str = b" | ||
"; | ||
const C: &'static u8 = " | ||
"; | ||
const D: &'static str = " | ||
"; | ||
ERROR_TIME | ||
// { dg-error "unrecognised token" "" { target *-*-* } .-1 } | ||
// { dg-error "failed to parse item in crate" "" { target *-*-* } .-2 } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
/* { dg-output "L1\n\L2\nL3\nL4" } */ | ||
extern "C" { | ||
fn printf(s: *const i8, ...); | ||
} | ||
|
||
fn main() -> i32 { | ||
let A = b"L1 | ||
L2\0"; | ||
let B = "L3 | ||
L4\0"; | ||
|
||
unsafe { | ||
let a = "%s\n\0"; | ||
let b = a as *const str; | ||
let c = b as *const i8; | ||
|
||
printf(c, A); | ||
printf(c, B); | ||
} | ||
|
||
0 | ||
} | ||
|