diff options
author | bors[bot] <26634292+bors[bot]@users.noreply.github.com> | 2021-05-21 10:25:20 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-05-21 10:25:20 +0000 |
commit | 6e808c647e53bf3805c47a8ae699091c3a4919bf (patch) | |
tree | ce5aa93f5be8ed4c92af2cc15b035de4aa174c46 /gcc | |
parent | 937352288b3ef8d54ff3edc1ef7153369b564d36 (diff) | |
parent | 41fbeec90c31a0e13e2884b63633919f73e10a08 (diff) | |
download | gcc-6e808c647e53bf3805c47a8ae699091c3a4919bf.zip gcc-6e808c647e53bf3805c47a8ae699091c3a4919bf.tar.gz gcc-6e808c647e53bf3805c47a8ae699091c3a4919bf.tar.bz2 |
Merge #436
436: Fixed #419: only parse inner_attributes if it starts with "#!" not only "#" r=philberty a=thomasyonug
Fixed #419
only parse inner_attributes if it starts with "#!" not only "#"
Co-authored-by: Thomas Young <wenzhang5800@gmail.com>
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/rust/parse/rust-parse-impl.h | 4 | ||||
-rw-r--r-- | gcc/testsuite/rust.test/compile/top_attr.rs | 5 |
2 files changed, 8 insertions, 1 deletions
diff --git a/gcc/rust/parse/rust-parse-impl.h b/gcc/rust/parse/rust-parse-impl.h index 5dcb458..dc8c773 100644 --- a/gcc/rust/parse/rust-parse-impl.h +++ b/gcc/rust/parse/rust-parse-impl.h @@ -442,7 +442,9 @@ Parser<ManagedTokenSource>::parse_inner_attributes () { std::vector<AST::Attribute> inner_attributes; - while (lexer.peek_token ()->get_id () == HASH) + // only try to parse it if it starts with "#!" not only "#" + while (lexer.peek_token ()->get_id () == HASH + && lexer.peek_token (1)->get_id () == EXCLAM) { AST::Attribute inner_attr = parse_inner_attribute (); diff --git a/gcc/testsuite/rust.test/compile/top_attr.rs b/gcc/testsuite/rust.test/compile/top_attr.rs new file mode 100644 index 0000000..0671369 --- /dev/null +++ b/gcc/testsuite/rust.test/compile/top_attr.rs @@ -0,0 +1,5 @@ +#![crate_name = "name"] + + +#[allow(dead_code)] +fn main() {}
\ No newline at end of file |