aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorArthur Cohen <arthur.cohen@embecosm.com>2024-01-30 16:16:36 +0100
committerCohenArthur <arthur.cohen@embecosm.com>2024-02-26 17:32:38 +0000
commitbdba3fae4c02e483810e4acfa2b5d62f66d94c11 (patch)
tree54f9fa6f33e1a2db54abfc1741c6a1e7dccccac0 /gcc
parentad905fe5164bd4a7b41172708256fe04d0a80c8d (diff)
downloadgcc-bdba3fae4c02e483810e4acfa2b5d62f66d94c11.zip
gcc-bdba3fae4c02e483810e4acfa2b5d62f66d94c11.tar.gz
gcc-bdba3fae4c02e483810e4acfa2b5d62f66d94c11.tar.bz2
format_args: Parse format string properly
gcc/rust/ChangeLog: * expand/rust-macro-builtins.cc (MacroBuiltin::format_args_handler): Construct string to parser properly.
Diffstat (limited to 'gcc')
-rw-r--r--gcc/rust/expand/rust-macro-builtins.cc19
1 files changed, 18 insertions, 1 deletions
diff --git a/gcc/rust/expand/rust-macro-builtins.cc b/gcc/rust/expand/rust-macro-builtins.cc
index 0e57406..19ea910 100644
--- a/gcc/rust/expand/rust-macro-builtins.cc
+++ b/gcc/rust/expand/rust-macro-builtins.cc
@@ -947,7 +947,24 @@ tl::optional<AST::Fragment>
MacroBuiltin::format_args_handler (location_t invoc_locus,
AST::MacroInvocData &invoc)
{
- Fmt::Pieces::collect ("heyo this {is} what I {} want to {3}, {parse}");
+ auto fmt_expr
+ = parse_single_string_literal (BuiltinMacro::FormatArgs,
+ invoc.get_delim_tok_tree (), invoc_locus,
+ invoc.get_expander ());
+
+ if (!fmt_expr)
+ return AST::Fragment::create_error ();
+
+ // if it is not a literal, it's an eager macro invocation - return it
+ if (!fmt_expr->is_literal ())
+ {
+ auto token_tree = invoc.get_delim_tok_tree ();
+ return AST::Fragment ({AST::SingleASTNode (std::move (fmt_expr))},
+ token_tree.to_token_stream ());
+ }
+
+ auto format_string = fmt_expr->as_string ();
+ auto pieces = Fmt::Pieces::collect (format_string);
return AST::Fragment::create_empty ();
}