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>
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)});
}
--- /dev/null
+macro_rules! empty {
+ () => {}; // { dg-error "found unexpected token '\}' in null denotation" }
+}
+
+fn main() {
+ let a = empty!();
+}