diff options
author | Nala Ginrut <mulei@gnu.org> | 2020-05-05 18:37:19 +0800 |
---|---|---|
committer | Philip Herron <philip.herron@embecosm.com> | 2020-11-28 19:10:47 +0000 |
commit | 3f37e20a3775d71be2a2c557474c2133b8d27f16 (patch) | |
tree | 5197a05cd0a059f5ca21276ee378e631e07f1efc | |
parent | a4c6b7b751429b3cd7ed0804c2cab210bc9f00e9 (diff) | |
download | gcc-3f37e20a3775d71be2a2c557474c2133b8d27f16.zip gcc-3f37e20a3775d71be2a2c557474c2133b8d27f16.tar.gz gcc-3f37e20a3775d71be2a2c557474c2133b8d27f16.tar.bz2 |
Fix params printing in DelimTokenTree
-rw-r--r-- | gcc/rust/ast/rust-ast-full-test.cc | 40 |
1 files changed, 17 insertions, 23 deletions
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 |