]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
gccrs: Fix warnings
authorjjasmine <tanghocle456@gmail.com>
Sat, 1 Jun 2024 02:34:49 +0000 (19:34 -0700)
committerArthur Cohen <arthur.cohen@embecosm.com>
Mon, 17 Mar 2025 15:35:44 +0000 (16:35 +0100)
gcc/rust/ChangeLog:

* expand/rust-macro-builtins-asm.cc (parse_reg_operand):
Fix compile warnings.
(parse_options): Likewise.
(parse_asm): Likewise.

gcc/testsuite/ChangeLog:

* rust/compile/inline_asm_illegal_options.rs:

gcc/rust/expand/rust-macro-builtins-asm.cc
gcc/testsuite/rust/compile/inline_asm_illegal_options.rs

index dd053df04b2282b3ced29ad8b247301db29e9672..95a268a02de3e25b57c351c277a7ae8b41705cdc 100644 (file)
@@ -219,7 +219,6 @@ parse_reg_operand (Parser<MacroInvocLexer> &parser, TokenId last_token_id,
 
   token = parser.peek_current_token ();
 
-  bool is_explicit_reg = false;
   bool is_global_asm = inline_asm.is_global_asm;
   if (!is_global_asm && check_identifier (parser, "in"))
     {
@@ -354,7 +353,12 @@ parse_options (Parser<MacroInvocLexer> &parser, TokenId last_token_id,
        {
          // TODO: Unexpected error, please return the correct error
          rust_error_at (token->get_locus (),
-                        "Unexpected token encountered in parse_options");
+                        "expected one of %qs, %qs, %qs, %qs, %qs, %qs, %qs, "
+                        "%qs, %qs, or %qs, found %qs",
+                        ")", "att_syntax", "may_unwind", "nomem", "noreturn",
+                        "nostack", "preserves_flags", "pure", "raw",
+                        "readonly", token->as_string ().c_str ());
+         return -1;
        }
       if (parser.skip_token (RIGHT_PAREN))
        {
@@ -519,7 +523,7 @@ parse_asm (location_t invoc_locus, AST::MacroInvocData &invoc,
   if (fm_string == tl::nullopt)
     {
       rust_error_at (parser.peek_current_token ()->get_locus (),
-                    "asm template must be a string literal");
+                    "%s template must be a string literal", "asm");
       return tl::nullopt;
     }
 
index bf34c4489f1c55fc4755bbddc043695e25ddddd3..2cf354d6d12395a7dc54b5659f13c84326e6559d 100644 (file)
@@ -9,5 +9,8 @@ fn main() {
     unsafe {
         asm!("nop", options(nomem, nomem)); // { dg-error "the 'nomem' option was already provided" }
         asm!("nop", options(noreturn, noreturn)); // { dg-error "the 'noreturn' option was already provided" }
+        asm!("nop", options(xxx)); // { dg-error "expected one of '\\)', 'att_syntax', 'may_unwind', 'nomem', 'noreturn', 'nostack', 'preserves_flags', 'pure', 'raw', or 'readonly', found 'xxx'" }
+        asm!("nop", options(+)); // { dg-error "expected one of '\\)', 'att_syntax', 'may_unwind', 'nomem', 'noreturn', 'nostack', 'preserves_flags', 'pure', 'raw', or 'readonly', found '\\+'" }
+
     }
 }
\ No newline at end of file