public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc/devel/rust/master] macros: fix an infinite loop ...
@ 2022-06-08 12:28 Thomas Schwinge
0 siblings, 0 replies; only message in thread
From: Thomas Schwinge @ 2022-06-08 12:28 UTC (permalink / raw)
To: gcc-cvs
https://gcc.gnu.org/g:2fe4048f7f1d10ce9928eb7611179ee8ff7f17f8
commit 2fe4048f7f1d10ce9928eb7611179ee8ff7f17f8
Author: liushuyu <liushuyu011@gmail.com>
Date: Mon Apr 11 15:20:41 2022 -0600
macros: fix an infinite loop ...
... introduced in fed5a41fb1c2c91b77297fdd6d3731078f480441, should fix #1102
Signed-off-by: Zixing Liu <liushuyu011@gmail.com>
Diff:
---
gcc/rust/expand/rust-macro-builtins.cc | 5 ++++-
gcc/testsuite/rust/compile/builtin_macro_concat.rs | 9 +++++----
2 files changed, 9 insertions(+), 5 deletions(-)
diff --git a/gcc/rust/expand/rust-macro-builtins.cc b/gcc/rust/expand/rust-macro-builtins.cc
index 85520ec60a4..1f41545ba38 100644
--- a/gcc/rust/expand/rust-macro-builtins.cc
+++ b/gcc/rust/expand/rust-macro-builtins.cc
@@ -287,9 +287,12 @@ MacroBuiltin::concat (Location invoc_locus, AST::MacroInvocData &invoc)
}
else
{
- rust_error_at (parser.peek_current_token ()->get_locus (),
+ auto current_token = parser.peek_current_token ();
+ rust_error_at (current_token->get_locus (),
"argument must be a constant literal");
has_error = true;
+ // Just crash if the current token can't be skipped
+ rust_assert (parser.skip_token (current_token->get_id ()));
}
parser.maybe_skip_token (COMMA);
}
diff --git a/gcc/testsuite/rust/compile/builtin_macro_concat.rs b/gcc/testsuite/rust/compile/builtin_macro_concat.rs
index 17c42e31c30..b37f80fc299 100644
--- a/gcc/testsuite/rust/compile/builtin_macro_concat.rs
+++ b/gcc/testsuite/rust/compile/builtin_macro_concat.rs
@@ -3,13 +3,14 @@ macro_rules! concat {
}
fn main() {
- // let not_literal = "identifier";
+ let not_literal = "identifier";
concat!();
- // concat! (,); // { error "argument must be a constant literal" }
- // concat!(not_literal); // { error "argument must be a constant literal" }
+ concat! (,); // { dg-error "argument must be a constant literal" }
+ concat!(not_literal); // { dg-error "argument must be a constant literal" }
concat!("message");
concat!("message",);
concat!("message", 1, true, false, 1.0, 10usize, 2000u64);
concat!("message", 1, true, false, 1.0, 10usize, 2000u64,);
- // concat! ("m", not_literal); // { error "argument must be a constant literal" }
+ concat! ("m", not_literal); // { dg-error "argument must be a constant literal" }
+ concat!(not_literal invalid 'm' !!,); // { dg-error "argument must be a constant literal" }
}
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2022-06-08 12:28 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-06-08 12:28 [gcc/devel/rust/master] macros: fix an infinite loop Thomas Schwinge
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).