aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorbadumbatish <tanghocle456@gmail.com>2024-06-29 17:12:33 -0700
committerArthur Cohen <arthur.cohen@embecosm.com>2025-03-17 16:35:52 +0100
commit2f80f40a25fc5dc115680f044710403eb32bc656 (patch)
tree6e805d8fc7f29bb87ca9369a71af38b1e4e864e3 /gcc
parente3db0b39198500748007c298b3f1d45bdebe66a4 (diff)
downloadgcc-2f80f40a25fc5dc115680f044710403eb32bc656.zip
gcc-2f80f40a25fc5dc115680f044710403eb32bc656.tar.gz
gcc-2f80f40a25fc5dc115680f044710403eb32bc656.tar.bz2
gccrs: Store parse result of parse_format_string(s)
gcc/rust/ChangeLog: * ast/rust-expr.h (struct TupleTemplateStr): Store parse result of parse_format_string(s) * expand/rust-macro-builtins-asm.cc (parse_format_strings): Likewise Signed-off-by: badumbatish <tanghocle456@gmail.com>
Diffstat (limited to 'gcc')
-rw-r--r--gcc/rust/ast/rust-expr.h7
-rw-r--r--gcc/rust/expand/rust-macro-builtins-asm.cc17
2 files changed, 21 insertions, 3 deletions
diff --git a/gcc/rust/ast/rust-expr.h b/gcc/rust/ast/rust-expr.h
index 9787e9a..f3ebf0b 100644
--- a/gcc/rust/ast/rust-expr.h
+++ b/gcc/rust/ast/rust-expr.h
@@ -5057,9 +5057,12 @@ struct TupleClobber
struct TupleTemplateStr
{
// as gccrs still doesn't contain a symbol class I have put them as strings
- std::string symbol;
- std::string optional_symbol;
location_t loc;
+ std::string symbol;
+
+ TupleTemplateStr (location_t loc, const std::string &symbol)
+ : loc (loc), symbol (symbol)
+ {}
};
// Inline Assembly Node
diff --git a/gcc/rust/expand/rust-macro-builtins-asm.cc b/gcc/rust/expand/rust-macro-builtins-asm.cc
index 87c90a2..94927fd 100644
--- a/gcc/rust/expand/rust-macro-builtins-asm.cc
+++ b/gcc/rust/expand/rust-macro-builtins-asm.cc
@@ -784,12 +784,20 @@ parse_format_strings (InlineAsmContext inline_asm_ctx)
auto last_token_id = inline_asm_ctx.last_token_id;
auto fm_string = parse_format_string (inline_asm_ctx);
+ auto &inline_asm = inline_asm_ctx.inline_asm;
+ auto token = parser.peek_current_token ();
if (fm_string == tl::nullopt)
{
rust_error_at (parser.peek_current_token ()->get_locus (),
"%s template must be a string literal", "asm");
return tl::unexpected<InlineAsmParseError> (COMMITTED);
}
+ else
+ {
+ auto template_str
+ = AST::TupleTemplateStr (token->get_locus (), fm_string.value ());
+ inline_asm.template_strs.push_back (template_str);
+ }
// formatted string stream
@@ -803,15 +811,22 @@ parse_format_strings (InlineAsmContext inline_asm_ctx)
// in here, which is formatted string in ABNF
inline_asm_ctx.consumed_comma_without_formatted_string = false;
+ token = parser.peek_current_token ();
fm_string = parse_format_string (inline_asm_ctx);
if (fm_string == tl::nullopt)
{
inline_asm_ctx.consumed_comma_without_formatted_string = true;
break;
}
+ else
+ {
+ auto template_str
+ = AST::TupleTemplateStr (token->get_locus (), fm_string.value ());
+ inline_asm.template_strs.push_back (template_str);
+ }
}
- return tl::expected<InlineAsmContext, InlineAsmParseError> (inline_asm_ctx);
+ return inline_asm_ctx;
}
// bool