aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorjjasmine <tanghocle456@gmail.com>2024-06-25 21:29:13 -0700
committerCohenArthur <arthur.cohen@embecosm.com>2024-06-28 09:59:34 +0000
commit69e06b2b6e44d6b66e29549014e37c812542bcab (patch)
treeaa2c143f57851f3c5bcdac00fd80dfe621ed1564
parent6749034ca960f6f4d7886cef229a325f0eab08ea (diff)
downloadgcc-69e06b2b6e44d6b66e29549014e37c812542bcab.zip
gcc-69e06b2b6e44d6b66e29549014e37c812542bcab.tar.gz
gcc-69e06b2b6e44d6b66e29549014e37c812542bcab.tar.bz2
Addresses warning, put warn unused in right place
gcc/rust/ChangeLog: * expand/rust-macro-builtins-asm.cc (parse_reg_operand): Addresses warning, put warn unused in right place (parse_reg_operand_inout): Likewise. (parse_asm_arg): Likewise. * expand/rust-macro-builtins-asm.h (enum WARN_UNUSED_RESULT): Likewise. (enum InlineAsmParseError): Likewise. (validate): Likewise. (parse_asm_arg): Likewise. (parse_format_strings): Likewise. (parse_clobber_abi): Likewise. (parse_reg_operand): Likewise. (parse_reg_operand_in): Likewise. (parse_reg_operand_out): Likewise. (parse_reg_operand_lateout): Likewise. (parse_reg_operand_inout): Likewise. (parse_reg_operand_inlateout): Likewise. (parse_reg_operand_const): Likewise. (parse_reg_operand_sym): Likewise. (parse_reg_operand_unexpected): Likewise. (parse_asm): Likewise. (check_and_set): Likewise. (parse_options): Likewise. (parse_reg): Likewise. (parse_format_string): Likewise. Signed-off-by: badumbatish <tanghocle456@gmail.com>
-rw-r--r--gcc/rust/expand/rust-macro-builtins-asm.cc24
-rw-r--r--gcc/rust/expand/rust-macro-builtins-asm.h21
2 files changed, 34 insertions, 11 deletions
diff --git a/gcc/rust/expand/rust-macro-builtins-asm.cc b/gcc/rust/expand/rust-macro-builtins-asm.cc
index c61fb10..9c2e8bb 100644
--- a/gcc/rust/expand/rust-macro-builtins-asm.cc
+++ b/gcc/rust/expand/rust-macro-builtins-asm.cc
@@ -16,6 +16,7 @@
// along with GCC; see the file COPYING3. If not see
// <http://www.gnu.org/licenses/>.
+#include "expected.h"
#include "rust-make-unique.h"
#include "rust-macro-builtins-asm.h"
#include "rust-ast-fragment.h"
@@ -208,15 +209,13 @@ parse_reg_operand (InlineAsmContext inline_asm_ctx)
else
{
rust_error_at (token->get_locus (),
- "expected operand, clobber_abi, options, or "
- "additional template string");
+ "expected operand, %s, options, or "
+ "additional template string",
+ "clobber_abi");
return tl::unexpected<InlineAsmParseError> (COMMITTED);
}
}
- tl::expected<InlineAsmContext, InlineAsmParseError> parsing_operand
- = tl::expected<InlineAsmContext, InlineAsmParseError> (inline_asm_ctx);
-
int slot = inline_asm_ctx.inline_asm.operands.size ();
// Here is all parse_reg_operand functions we're using in a for loop
@@ -230,7 +229,8 @@ parse_reg_operand (InlineAsmContext inline_asm_ctx)
// we propogate the result.
for (auto &parse_func : parse_funcs)
{
- parsing_operand.emplace (inline_asm_ctx);
+ auto parsing_operand
+ = tl::expected<InlineAsmContext, InlineAsmParseError> (inline_asm_ctx);
parsing_operand.map (parse_func);
// Per rust's asm.rs's structure
@@ -281,7 +281,7 @@ parse_reg_operand (InlineAsmContext inline_asm_ctx)
}
}
- return parsing_operand;
+ return inline_asm_ctx;
}
tl::expected<InlineAsmContext, InlineAsmParseError>
@@ -386,7 +386,10 @@ parse_reg_operand_inout (InlineAsmContext inline_asm_ctx)
{
if (!parser.skip_token (UNDERSCORE))
{
- parse_format_string (inline_asm_ctx);
+ auto result = parse_format_string (inline_asm_ctx);
+
+ if (!result.has_value ())
+ rust_unreachable ();
// out_expr = parser.parse_expr();
}
@@ -708,8 +711,9 @@ parse_asm_arg (InlineAsmContext inline_asm_ctx)
// committed to anything So that the error bubbles up and we recover from
// this error gracefully
rust_error_at (token->get_locus (),
- "expected operand, clobber_abi, options, or additional "
- "template string");
+ "expected operand, %s, options, or additional "
+ "template string",
+ "clobber_abi");
return tl::unexpected<InlineAsmParseError> (COMMITTED);
}
return tl::expected<InlineAsmContext, InlineAsmParseError> (inline_asm_ctx);
diff --git a/gcc/rust/expand/rust-macro-builtins-asm.h b/gcc/rust/expand/rust-macro-builtins-asm.h
index d3ca934..6997770 100644
--- a/gcc/rust/expand/rust-macro-builtins-asm.h
+++ b/gcc/rust/expand/rust-macro-builtins-asm.h
@@ -8,7 +8,7 @@
#include "system.h"
namespace Rust {
-enum WARN_UNUSED_RESULT InlineAsmParseError
+enum InlineAsmParseError
{
// Enum for InlineAsmParseError
@@ -77,50 +77,65 @@ public:
};
// Expected calls
+WARN_UNUSED_RESULT
tl::expected<InlineAsmContext, InlineAsmParseError>
validate (InlineAsmContext inline_asm_ctx);
+WARN_UNUSED_RESULT
tl::expected<InlineAsmContext, InlineAsmParseError>
parse_asm_arg (InlineAsmContext inline_asm_ctx);
+WARN_UNUSED_RESULT
tl::expected<InlineAsmContext, InlineAsmParseError>
parse_format_strings (InlineAsmContext inline_asm_ctx);
+WARN_UNUSED_RESULT
tl::expected<InlineAsmContext, InlineAsmParseError>
parse_clobber_abi (InlineAsmContext inline_asm_ctx);
// From rustc
+WARN_UNUSED_RESULT
tl::expected<InlineAsmContext, InlineAsmParseError>
parse_reg_operand (InlineAsmContext inline_asm_ctx);
+WARN_UNUSED_RESULT
tl::expected<InlineAsmContext, InlineAsmParseError>
parse_reg_operand_in (InlineAsmContext inline_asm_ctx);
+WARN_UNUSED_RESULT
tl::expected<InlineAsmContext, InlineAsmParseError>
parse_reg_operand_out (InlineAsmContext inline_asm_ctx);
+WARN_UNUSED_RESULT
tl::expected<InlineAsmContext, InlineAsmParseError>
parse_reg_operand_lateout (InlineAsmContext inline_asm_ctx);
+WARN_UNUSED_RESULT
tl::expected<InlineAsmContext, InlineAsmParseError>
parse_reg_operand_inout (InlineAsmContext inline_asm_ctx);
+WARN_UNUSED_RESULT
tl::expected<InlineAsmContext, InlineAsmParseError>
parse_reg_operand_inlateout (InlineAsmContext inline_asm_ctx);
+WARN_UNUSED_RESULT
tl::expected<InlineAsmContext, InlineAsmParseError>
parse_reg_operand_const (InlineAsmContext inline_asm_ctx);
+WARN_UNUSED_RESULT
tl::expected<InlineAsmContext, InlineAsmParseError>
parse_reg_operand_sym (InlineAsmContext inline_asm_ctx);
+WARN_UNUSED_RESULT
tl::expected<InlineAsmContext, InlineAsmParseError>
parse_reg_operand_unexpected (InlineAsmContext inline_asm_ctx);
+WARN_UNUSED_RESULT
tl::optional<AST::Fragment>
parse_asm (location_t invoc_locus, AST::MacroInvocData &invoc,
AST::InvocKind semicolon, AST::AsmKind is_global_asm);
+WARN_UNUSED_RESULT
bool
check_identifier (Parser<MacroInvocLexer> &parser, std::string ident);
@@ -128,16 +143,20 @@ void
check_and_set (InlineAsmContext &inline_asm_ctx, AST::InlineAsmOption option);
// From rustc
+WARN_UNUSED_RESULT
tl::expected<InlineAsmContext, InlineAsmParseError>
parse_options (InlineAsmContext &inline_asm_ctx);
// From rustc
+WARN_UNUSED_RESULT
tl::optional<AST::InlineAsmRegOrRegClass>
parse_reg (InlineAsmContext &inline_asm_ctx);
+WARN_UNUSED_RESULT
tl::optional<std::string>
parse_format_string (InlineAsmContext &inline_asm_ctx);
+WARN_UNUSED_RESULT
tl::optional<std::string>
parse_label (Parser<MacroInvocLexer> &parser, TokenId last_token_id,
InlineAsmContext &inline_asm_ctx);