[prev in list] [next in list] [prev in thread] [next in thread] 

List:       gcc-patches
Subject:    [committed] d: Add always_inline to the internal attribute table.
From:       Iain Buclaw via Gcc-patches <gcc-patches () gcc ! gnu ! org>
Date:       2020-03-31 21:12:29
Message-ID: 20200331211229.22782-1-ibuclaw () gdcproject ! org
[Download RAW message or body]

Hi,

This patch adds always_inline to the d_langhook_common_attribute_table.
The attribute is not directly accessible from user code, rather it is
indirectly added from the @forceinline attribute.  Even so, a handler
should be present for it to prevent false positive warnings.

Said warnings are not something that could happen currently, but will
become a problem from fixing PR90136 later.

Bootstrapped and tested on x86_linux-gnu.  Committed to mainline.

Regards
Iain
---

gcc/d/ChangeLog:

	* d-attribs.cc (d_langhook_common_attribute_table): Add always_inline.
	(handle_always_inline_attribute): New function.

---
 gcc/d/d-attribs.cc | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)

diff --git a/gcc/d/d-attribs.cc b/gcc/d/d-attribs.cc
index c3b80ed5b9d..bba6f516ea3 100644
--- a/gcc/d/d-attribs.cc
+++ b/gcc/d/d-attribs.cc
@@ -52,6 +52,7 @@ static tree handle_type_generic_attribute (tree *, tree, tree, int, bool *);
 static tree handle_transaction_pure_attribute (tree *, tree, tree, int, bool *);
 static tree handle_returns_twice_attribute (tree *, tree, tree, int, bool *);
 static tree handle_fnspec_attribute (tree *, tree, tree, int, bool *);
+static tree handle_always_inline_attribute (tree *, tree, tree, int, bool *);
 
 /* D attribute handlers for user defined attributes.  */
 static tree d_handle_noinline_attribute (tree *, tree, tree, int, bool *);
@@ -137,6 +138,8 @@ const attribute_spec d_langhook_common_attribute_table[] =
 	     handle_type_generic_attribute, NULL),
   ATTR_SPEC ("fn spec", 1, 1, false, true, true, false,
 	     handle_fnspec_attribute, NULL),
+  ATTR_SPEC ("always_inline", 0, 0, true,  false, false, false,
+	     handle_always_inline_attribute, NULL),
   ATTR_SPEC (NULL, 0, 0, false, false, false, false, NULL, NULL),
 };
 
@@ -565,6 +568,19 @@ handle_fnspec_attribute (tree *node ATTRIBUTE_UNUSED, tree ARG_UNUSED (name),
   return NULL_TREE;
 }
 
+/* Handle a "always_inline" attribute; arguments as in
+   struct attribute_spec.handler.  */
+
+static tree
+handle_always_inline_attribute (tree *node, tree ARG_UNUSED (name),
+				tree ARG_UNUSED (args), int ARG_UNUSED (flags),
+				bool *no_add_attrs ATTRIBUTE_UNUSED)
+{
+  gcc_assert (TREE_CODE (*node) == FUNCTION_DECL);
+
+  return NULL_TREE;
+}
+
 /* Language specific attribute handlers.  */
 
 /* Handle a "noinline" attribute.  */
-- 
2.20.1

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic