]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
gccrs: ast: Support outer attributes for AST::RangeExpr
authorArthur Cohen <arthur.cohen@embecosm.com>
Wed, 9 Apr 2025 12:44:56 +0000 (14:44 +0200)
committerArthur Cohen <arthur.cohen@embecosm.com>
Mon, 14 Apr 2025 16:23:53 +0000 (18:23 +0200)
gcc/rust/ChangeLog:

* ast/rust-expr.h (class RangeExpr): Add empty outer attributes and allow getting them
and setting them.

gcc/rust/ast/rust-expr.h

index 84cdfdb467807a84c9d816953e280ea8cf911e27..69538df63e5cef8a26e58d472b0d683b83cee7b6 100644 (file)
@@ -3004,6 +3004,10 @@ class RangeExpr : public ExprWithoutBlock
 {
   location_t locus;
 
+  // Some visitors still check for attributes on RangeExprs, and they will need
+  // to be supported in the future - so keep that for now
+  std::vector<Attribute> empty_attributes = {};
+
 protected:
   // outer attributes not allowed before range expressions
   RangeExpr (location_t locus) : locus (locus) {}
@@ -3013,15 +3017,11 @@ public:
 
   std::vector<Attribute> &get_outer_attrs () override final
   {
-    // RangeExpr cannot have any outer attributes
-    rust_assert (false);
+    return empty_attributes;
   }
 
   // should never be called - error if called
-  void set_outer_attrs (std::vector<Attribute> /* new_attrs */) override
-  {
-    rust_assert (false);
-  }
+  void set_outer_attrs (std::vector<Attribute> /* new_attrs */) override {}
 
   Expr::Kind get_expr_kind () const override { return Expr::Kind::Range; }
 };