mirror of
https://gcc.gnu.org/git/gcc.git
synced 2026-02-23 04:09:42 -05:00
gccrs: Do not crash on empty macros expand. Fixes #1712
This commit fixes a compiler crash when expanding an empty macro into an existing AST. gcc/rust/ChangeLog: * expand/rust-macro-expand.cc (transcribe_expression): Fix ICE when expanding empty macros. gcc/testsuite/ChangeLog: * rust/compile/macro45.rs: New test. Signed-off-by: Lyra Karenai <teromene@teromene.fr>
This commit is contained in:
@@ -839,6 +839,8 @@ static AST::Fragment
|
||||
transcribe_expression (Parser<MacroInvocLexer> &parser)
|
||||
{
|
||||
auto expr = parser.parse_expr ();
|
||||
if (expr == nullptr)
|
||||
return AST::Fragment::create_error ();
|
||||
|
||||
return AST::Fragment::complete ({std::move (expr)});
|
||||
}
|
||||
|
||||
7
gcc/testsuite/rust/compile/macro45.rs
Normal file
7
gcc/testsuite/rust/compile/macro45.rs
Normal file
@@ -0,0 +1,7 @@
|
||||
macro_rules! empty {
|
||||
() => {}; // { dg-error "found unexpected token '\}' in null denotation" }
|
||||
}
|
||||
|
||||
fn main() {
|
||||
let a = empty!();
|
||||
}
|
||||
Reference in New Issue
Block a user