public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
From: Thomas Schwinge <tschwinge@gcc.gnu.org>
To: gcc-cvs@gcc.gnu.org
Subject: [gcc/devel/rust/master] rust/backend: scan for any deprecated function calls ...
Date: Thu, 30 Jun 2022 18:50:37 +0000 (GMT)	[thread overview]
Message-ID: <20220630185037.D75F2383F97C@sourceware.org> (raw)

https://gcc.gnu.org/g:649d3c45afa9c65cad99c8d195e342b3c8bea43c

commit 649d3c45afa9c65cad99c8d195e342b3c8bea43c
Author: liushuyu <liushuyu011@gmail.com>
Date:   Sat Jun 11 20:02:54 2022 -0600

    rust/backend: scan for any deprecated function calls ...
    
    ... and emit warnings using GCC's own deprecation warning system

Diff:
---
 gcc/rust/backend/rust-compile-base.cc |  9 +++++++--
 gcc/rust/rust-gcc.cc                  | 10 ++++++++++
 2 files changed, 17 insertions(+), 2 deletions(-)

diff --git a/gcc/rust/backend/rust-compile-base.cc b/gcc/rust/backend/rust-compile-base.cc
index 335a6d411a5..066ef43ca23 100644
--- a/gcc/rust/backend/rust-compile-base.cc
+++ b/gcc/rust/backend/rust-compile-base.cc
@@ -209,8 +209,13 @@ HIRCompileBase::handle_deprecated_attribute_on_fndecl (
 	}
     }
 
-  DECL_ATTRIBUTES (fndecl) = tree_cons (get_identifier ("deprecated"), value,
-					DECL_ATTRIBUTES (fndecl));
+  if (value)
+    {
+      tree attr_list = build_tree_list (NULL_TREE, value);
+      DECL_ATTRIBUTES (fndecl)
+	= tree_cons (get_identifier ("deprecated"), attr_list,
+		     DECL_ATTRIBUTES (fndecl));
+    }
 }
 
 void
diff --git a/gcc/rust/rust-gcc.cc b/gcc/rust/rust-gcc.cc
index 445cb0da876..4fea6fbd7fc 100644
--- a/gcc/rust/rust-gcc.cc
+++ b/gcc/rust/rust-gcc.cc
@@ -51,6 +51,8 @@
 #include "rust-backend.h"
 #include "rust-object-export.h"
 
+#include "backend/rust-tree.h"
+
 // TODO: this will have to be significantly modified to work with Rust
 
 // Bvariable is a bit more complicated, because of zero-sized types.
@@ -1852,6 +1854,14 @@ Gcc_backend::call_expression (tree fn, const std::vector<tree> &fn_args,
 			    excess_type != NULL_TREE ? excess_type : rettype,
 			    fn, nargs, args);
 
+  // check for deprecated function usage
+  if (fndecl && TREE_DEPRECATED (fndecl))
+    {
+      // set up the call-site information for `warn_deprecated_use`
+      input_location = location.gcc_location ();
+      warn_deprecated_use (fndecl, NULL_TREE);
+    }
+
   if (chain_expr)
     CALL_EXPR_STATIC_CHAIN (ret) = chain_expr;


                 reply	other threads:[~2022-06-30 18:50 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=20220630185037.D75F2383F97C@sourceware.org \
    --to=tschwinge@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).