]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
gccrs: ast: Fix attribute tokenstreams
authorPierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
Tue, 4 Apr 2023 13:56:02 +0000 (15:56 +0200)
committerArthur Cohen <arthur.cohen@embecosm.com>
Tue, 16 Jan 2024 17:28:44 +0000 (18:28 +0100)
Attributes were not converted to a correct tokenstream, furthermore meta
items containers and token trees attribute arguments were not even
implemented. This commit fix the literal attribute type and implement
both unimplemented types.

gcc/rust/ChangeLog:

* ast/rust-ast-tokenstream.cc (TokenStream::visit): Fix existing
and implement remaining attribute visitors.

Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
gcc/rust/ast/rust-ast-tokenstream.cc

index 761e899a06b45203fd4b29adb0de1efca1886f97..0db1e2ccfed7d15122b9380e2951d3a619f68dbc 100644 (file)
@@ -159,27 +159,19 @@ TokenStream::visit (Attribute &attrib)
 
   if (attrib.has_attr_input ())
     {
-      tokens.push_back (Rust::Token::make (EQUAL, Location ()));
-
       switch (attrib.get_attr_input ().get_attr_input_type ())
        {
          case AST::AttrInput::AttrInputType::LITERAL: {
-           auto &literal
-             = static_cast<AST::AttrInputLiteral &> (attrib.get_attr_input ())
-                 .get_literal ();
-           auto value = literal.as_string ();
-           tokens.push_back (Rust::Token::make (DOUBLE_QUOTE, Location ()));
-           tokens.push_back (Rust::Token::make_string (literal.get_locus (),
-                                                       std::move (value)));
-           tokens.push_back (Rust::Token::make (DOUBLE_QUOTE, Location ()));
+           visit (static_cast<AttrInputLiteral &> (attrib.get_attr_input ()));
            break;
          }
          case AST::AttrInput::AttrInputType::META_ITEM: {
-           // FIXME: Implement this
+           visit (static_cast<AttrInputMetaItemContainer &> (
+             attrib.get_attr_input ()));
            break;
          }
          case AST::AttrInput::AttrInputType::TOKEN_TREE: {
-           // FIXME: Implement this
+           visit (static_cast<DelimTokenTree &> (attrib.get_attr_input ()));
            break;
          }
        default: