[gcc r14-7447] gccrs: ast: Fix attribute tokenstreams
Arthur Cohen
cohenarthur@gcc.gnu.org
Tue Jan 16 17:35:32 GMT 2024
https://gcc.gnu.org/g:21c46e84e8b461a2d80b6fb6c2a006a8552a52a6
commit r14-7447-g21c46e84e8b461a2d80b6fb6c2a006a8552a52a6
Author: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
Date: Tue Apr 4 15:56:02 2023 +0200
gccrs: ast: Fix attribute tokenstreams
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>
Diff:
---
gcc/rust/ast/rust-ast-tokenstream.cc | 16 ++++------------
1 file changed, 4 insertions(+), 12 deletions(-)
diff --git a/gcc/rust/ast/rust-ast-tokenstream.cc b/gcc/rust/ast/rust-ast-tokenstream.cc
index 761e899a06b..0db1e2ccfed 100644
--- a/gcc/rust/ast/rust-ast-tokenstream.cc
+++ b/gcc/rust/ast/rust-ast-tokenstream.cc
@@ -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:
More information about the Gcc-cvs
mailing list