diff options
author | Arthur Cohen <arthur.cohen@embecosm.com> | 2022-03-17 10:38:07 +0100 |
---|---|---|
committer | Arthur Cohen <arthur.cohen@embecosm.com> | 2022-03-17 10:38:07 +0100 |
commit | 1e873922f0d4fa08448d49c6f5333ffa67fe4704 (patch) | |
tree | 68f2a333968608cb17793de209d6e2e0109b1a12 /gcc | |
parent | b776c4953ca125855f37e381ad51ae8ae836247c (diff) | |
download | gcc-1e873922f0d4fa08448d49c6f5333ffa67fe4704.zip gcc-1e873922f0d4fa08448d49c6f5333ffa67fe4704.tar.gz gcc-1e873922f0d4fa08448d49c6f5333ffa67fe4704.tar.bz2 |
ast: Add Kind::MACRO_INVOCATION and cleanup fatal errors in lowering
macro invocations
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/rust/ast/rust-ast.h | 5 | ||||
-rw-r--r-- | gcc/rust/ast/rust-macro.h | 2 | ||||
-rw-r--r-- | gcc/rust/hir/rust-ast-lower-expr.h | 8 | ||||
-rw-r--r-- | gcc/rust/hir/rust-ast-lower-implitem.h | 16 | ||||
-rw-r--r-- | gcc/rust/hir/rust-ast-lower-item.h | 8 | ||||
-rw-r--r-- | gcc/rust/hir/rust-ast-lower-stmt.h | 8 | ||||
-rw-r--r-- | gcc/rust/hir/rust-ast-lower.cc | 7 |
7 files changed, 12 insertions, 42 deletions
diff --git a/gcc/rust/ast/rust-ast.h b/gcc/rust/ast/rust-ast.h index 6587142..4cb2410 100644 --- a/gcc/rust/ast/rust-ast.h +++ b/gcc/rust/ast/rust-ast.h @@ -41,6 +41,7 @@ enum Kind { UNKNOWN, MACRO_RULES_DEFINITION, + MACRO_INVOCATION, }; // Abstract base class for all AST elements @@ -900,7 +901,7 @@ protected: class ExprWithoutBlock; // Base expression AST node - abstract -class Expr +class Expr : public Node { public: // Unique pointer custom clone function @@ -1073,7 +1074,7 @@ protected: class TraitBound; // Base class for types as represented in AST - abstract -class Type +class Type : public Node { public: // Unique pointer custom clone function diff --git a/gcc/rust/ast/rust-macro.h b/gcc/rust/ast/rust-macro.h index 4adf467..1c5d102 100644 --- a/gcc/rust/ast/rust-macro.h +++ b/gcc/rust/ast/rust-macro.h @@ -507,6 +507,8 @@ public: return ExprWithoutBlock::get_node_id (); } + Kind get_ast_kind () const override { return Kind::MACRO_INVOCATION; } + NodeId get_macro_node_id () const { return node_id; } MacroInvocData &get_invoc_data () { return invoc_data; } diff --git a/gcc/rust/hir/rust-ast-lower-expr.h b/gcc/rust/hir/rust-ast-lower-expr.h index e316868..1915389 100644 --- a/gcc/rust/hir/rust-ast-lower-expr.h +++ b/gcc/rust/hir/rust-ast-lower-expr.h @@ -100,14 +100,6 @@ public: return resolver.translated; } - void visit (AST::MacroInvocation &expr) override - { - rust_fatal_error ( - expr.get_locus (), - "macro expansion failed: No macro invocation should get lowered to HIR " - "as they should disappear during expansion"); - } - void visit (AST::TupleIndexExpr &expr) override { HIR::Expr *tuple_expr diff --git a/gcc/rust/hir/rust-ast-lower-implitem.h b/gcc/rust/hir/rust-ast-lower-implitem.h index 5d674ca..c9dfd1b 100644 --- a/gcc/rust/hir/rust-ast-lower-implitem.h +++ b/gcc/rust/hir/rust-ast-lower-implitem.h @@ -52,14 +52,6 @@ public: return resolver.translated; } - void visit (AST::MacroInvocation &invoc) override - { - rust_fatal_error ( - invoc.get_locus (), - "macro expansion failed: No macro invocation should get lowered to HIR " - "as they should disappear during expansion"); - } - void visit (AST::TypeAlias &alias) override { std::vector<std::unique_ptr<HIR::WhereClauseItem> > where_clause_items; @@ -316,14 +308,6 @@ public: return resolver.translated; } - void visit (AST::MacroInvocation &invoc) override - { - rust_fatal_error ( - invoc.get_locus (), - "macro expansion failed: No macro invocation should get lowered to HIR " - "as they should disappear during expansion"); - } - void visit (AST::TraitItemFunc &func) override { AST::TraitFunctionDecl &ref = func.get_trait_function_decl (); diff --git a/gcc/rust/hir/rust-ast-lower-item.h b/gcc/rust/hir/rust-ast-lower-item.h index 50ecf7b..376e6c2 100644 --- a/gcc/rust/hir/rust-ast-lower-item.h +++ b/gcc/rust/hir/rust-ast-lower-item.h @@ -51,14 +51,6 @@ public: return resolver.translated; } - void visit (AST::MacroInvocation &invoc) override - { - rust_fatal_error ( - invoc.get_locus (), - "macro expansion failed: No macro invocation should get lowered to HIR " - "as they should disappear during expansion"); - } - void visit (AST::Module &module) override { auto crate_num = mappings->get_current_crate (); diff --git a/gcc/rust/hir/rust-ast-lower-stmt.h b/gcc/rust/hir/rust-ast-lower-stmt.h index d0a1d38..ede72bd 100644 --- a/gcc/rust/hir/rust-ast-lower-stmt.h +++ b/gcc/rust/hir/rust-ast-lower-stmt.h @@ -45,14 +45,6 @@ public: return resolver.translated; } - void visit (AST::MacroInvocation &invoc) override - { - rust_fatal_error ( - invoc.get_locus (), - "macro expansion failed: No macro invocation should get lowered to HIR " - "as they should disappear during expansion"); - } - void visit (AST::ExprStmtWithBlock &stmt) override { HIR::ExprWithBlock *expr diff --git a/gcc/rust/hir/rust-ast-lower.cc b/gcc/rust/hir/rust-ast-lower.cc index 27f73e0..c373ae9 100644 --- a/gcc/rust/hir/rust-ast-lower.cc +++ b/gcc/rust/hir/rust-ast-lower.cc @@ -70,6 +70,13 @@ ASTLoweringBlock::visit (AST::BlockExpr &expr) if (s->get_ast_kind () == AST::Kind::MACRO_RULES_DEFINITION) continue; + if (s->get_ast_kind () == AST::Kind::MACRO_INVOCATION) + rust_fatal_error ( + s->get_locus (), + "macro invocations should not get lowered to HIR - At " + "this point in " + "the pipeline, they should all have been expanded"); + if (block_did_terminate) rust_warning_at (s->get_locus (), 0, "unreachable statement"); |