From 3f37e20a3775d71be2a2c557474c2133b8d27f16 Mon Sep 17 00:00:00 2001 From: Nala Ginrut Date: Tue, 5 May 2020 18:37:19 +0800 Subject: Fix params printing in DelimTokenTree --- gcc/rust/ast/rust-ast-full-test.cc | 40 ++++++++++++++++---------------------- 1 file changed, 17 insertions(+), 23 deletions(-) (limited to 'gcc') diff --git a/gcc/rust/ast/rust-ast-full-test.cc b/gcc/rust/ast/rust-ast-full-test.cc index 347ad54..550b7e0 100644 --- a/gcc/rust/ast/rust-ast-full-test.cc +++ b/gcc/rust/ast/rust-ast-full-test.cc @@ -200,33 +200,26 @@ DelimTokenTree::as_string () const end_delim = "}"; break; default: - // error - return ""; + fprintf (stderr, "Invalid delimiter type, " + "Should be PARENS, SQUARE, or CURLY."); + return "Invalid delimiter type"; } ::std::string str = start_delim; - if (token_trees.empty ()) + if (!token_trees.empty ()) { - str += "none"; - } - else - { - auto i = token_trees.begin (); - auto e = token_trees.end (); - - // DEBUG: null pointer check - if (*i == NULL) + for (const auto &tree : token_trees) { - fprintf (stderr, - "something really terrible has gone wrong - null pointer " - "token tree in delim token tree."); - return "NULL_POINTER_MARK"; - } + // DEBUG: null pointer check + if (tree == NULL) + { + fprintf ( + stderr, + "something really terrible has gone wrong - null pointer " + "token tree in delim token tree."); + return "NULL_POINTER_MARK"; + } - for (; i != e; i++) - { - str += (*i)->as_string (); - if (e != i + 1) - str += ", "; + str += tree->as_string (); } } str += end_delim; @@ -1529,7 +1522,8 @@ MacroRulesDefinition::as_string () const ::std::string MacroInvocation::as_string () const { - return path.as_string () + "!" + token_tree.as_string (); + return "MacroInvocation: " + path.as_string () + "!" + + token_tree.as_string (); } ::std::string -- cgit v1.1