public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
From: Arthur Cohen <cohenarthur@gcc.gnu.org>
To: gcc-cvs@gcc.gnu.org
Subject: [gcc r14-7922] gccrs: [E0534] inline attribute was malformed
Date: Tue, 16 Jan 2024 18:07:35 +0000 (GMT)	[thread overview]
Message-ID: <20240116180735.AE80038582B9@sourceware.org> (raw)

https://gcc.gnu.org/g:75853fdd29499cbe5e532f9472caefaa61ce4a69

commit r14-7922-g75853fdd29499cbe5e532f9472caefaa61ce4a69
Author: Muhammad Mahad <mahadtxt@gmail.com>
Date:   Tue Aug 15 18:52:10 2023 +0500

    gccrs: [E0534] inline attribute was malformed
    
    Inline attribute takes one argument, but
    more than one argument was found.
    
    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 case.
    
    Signed-off-by: Muhammad Mahad <mahadtxt@gmail.com>

Diff:
---
 gcc/rust/backend/rust-compile-base.cc  | 5 ++++-
 gcc/testsuite/rust/compile/inline_2.rs | 3 +++
 2 files changed, 7 insertions(+), 1 deletion(-)

diff --git a/gcc/rust/backend/rust-compile-base.cc b/gcc/rust/backend/rust-compile-base.cc
index 5a0d9a16efd..18673687538 100644
--- a/gcc/rust/backend/rust-compile-base.cc
+++ b/gcc/rust/backend/rust-compile-base.cc
@@ -247,7 +247,10 @@ HIRCompileBase::handle_inline_attribute_on_fndecl (tree fndecl,
   AST::AttrInputMetaItemContainer *meta_item = option.parse_to_meta_item ();
   if (meta_item->get_items ().size () != 1)
     {
-      rust_error_at (attr.get_locus (), "invalid number of arguments");
+      rich_location rich_locus (line_table, attr.get_locus ());
+      rich_locus.add_fixit_replace ("expected one argument");
+      rust_error_at (rich_locus, ErrorCode::E0534,
+		     "invalid number of arguments");
       return;
     }
 
diff --git a/gcc/testsuite/rust/compile/inline_2.rs b/gcc/testsuite/rust/compile/inline_2.rs
index 3665fdac804..1fa5862e10f 100644
--- a/gcc/testsuite/rust/compile/inline_2.rs
+++ b/gcc/testsuite/rust/compile/inline_2.rs
@@ -4,3 +4,6 @@ fn test_a() {}
 
 #[inline(A, B)] // { dg-error "invalid number of arguments" }
 fn test_b() {}
+
+#[inline()] // { dg-error "invalid number of arguments" }
+fn test_c() {}
\ No newline at end of file

                 reply	other threads:[~2024-01-16 18:07 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20240116180735.AE80038582B9@sourceware.org \
    --to=cohenarthur@gcc.gnu.org \
    --cc=gcc-cvs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).