public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc r14-7926] gccrs: [E0535] Unknown argument given to inline attribute
@ 2024-01-16 18:07 Arthur Cohen
  0 siblings, 0 replies; only message in thread
From: Arthur Cohen @ 2024-01-16 18:07 UTC (permalink / raw)
  To: gcc-cvs

https://gcc.gnu.org/g:87ccd32da00e82584215c759e80bd092003c9efb

commit r14-7926-g87ccd32da00e82584215c759e80bd092003c9efb
Author: Muhammad Mahad <mahadtxt@gmail.com>
Date:   Tue Aug 15 19:07:52 2023 +0500

    gccrs: [E0535] Unknown argument given to inline attribute
    
    The inline attribute only supports two arguments:
     - always
     - never
    All other arguments given to the inline attribute will
    return error.
    
    gcc/rust/ChangeLog:
    
            * backend/rust-compile-base.cc (HIRCompileBase::handle_inline_attribute_on_fndecl):
            Added rich_location & error code.
    
    gcc/testsuite/ChangeLog:
    
            * rust/compile/inline_2.rs: Added new message.
    
    Signed-off-by: Muhammad Mahad <mahadtxt@gmail.com>

Diff:
---
 gcc/rust/backend/rust-compile-base.cc  | 6 +++++-
 gcc/testsuite/rust/compile/inline_2.rs | 2 +-
 2 files changed, 6 insertions(+), 2 deletions(-)

diff --git a/gcc/rust/backend/rust-compile-base.cc b/gcc/rust/backend/rust-compile-base.cc
index 18673687538..492588dfdf9 100644
--- a/gcc/rust/backend/rust-compile-base.cc
+++ b/gcc/rust/backend/rust-compile-base.cc
@@ -275,7 +275,11 @@ HIRCompileBase::handle_inline_attribute_on_fndecl (tree fndecl,
     }
   else
     {
-      rust_error_at (attr.get_locus (), "unknown inline option");
+      rich_location rich_locus (line_table, attr.get_locus ());
+      rich_locus.add_fixit_replace ("unknown inline option");
+      rust_error_at (rich_locus, ErrorCode::E0535,
+		     "invalid argument, %<inline%> attribute only accepts "
+		     "%<always%> or %<never%>");
     }
 }
 
diff --git a/gcc/testsuite/rust/compile/inline_2.rs b/gcc/testsuite/rust/compile/inline_2.rs
index 1fa5862e10f..b6cfc83be72 100644
--- a/gcc/testsuite/rust/compile/inline_2.rs
+++ b/gcc/testsuite/rust/compile/inline_2.rs
@@ -1,5 +1,5 @@
 // { dg-additional-options "-w" }
-#[inline(A)] // { dg-error "unknown inline option" }
+#[inline(A)] // { dg-error "invalid argument, .inline. attribute only accepts .always. or .never." }
 fn test_a() {}
 
 #[inline(A, B)] // { dg-error "invalid number of arguments" }

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2024-01-16 18:07 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-01-16 18:07 [gcc r14-7926] gccrs: [E0535] Unknown argument given to inline attribute Arthur Cohen

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).