]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
c++: add DECL_IMPLICIT_TEMPLATE_PARM_P macro
authorJason Merrill <jason@redhat.com>
Tue, 17 Oct 2023 22:01:28 +0000 (18:01 -0400)
committerJason Merrill <jason@redhat.com>
Mon, 20 Nov 2023 02:52:35 +0000 (21:52 -0500)
Let's use a more informative name instead of DECL_VIRTUAL_P directly.

gcc/cp/ChangeLog:

* cp-tree.h (DECL_TEMPLATE_PARM_CHECK): New.
(DECL_IMPLICIT_TEMPLATE_PARM_P): New.
(decl_template_parm_check): New.
* mangle.cc (write_closure_template_head): Use it.
* parser.cc (synthesize_implicit_template_parm): Likewise.
* pt.cc (template_parameters_equivalent_p): Likewise.

gcc/cp/cp-tree.h
gcc/cp/mangle.cc
gcc/cp/parser.cc
gcc/cp/pt.cc

index c7a1cf610c815096a9bf41df30db6c4c1105af47..7b0b7c6a17ead6546ecef93cf46e35d16ff17704 100644 (file)
@@ -677,10 +677,14 @@ template_info_decl_check (const_tree t, const char* f, int l, const char* fn)
       tree_check_failed (__t, __FILE__, __LINE__, __FUNCTION__, 0);    \
      __t; })
 
+#define DECL_TEMPLATE_PARM_CHECK(NODE) \
+  decl_template_parm_check ((NODE), __FILE__, __LINE__, __FUNCTION__)
+
 #else /* ENABLE_TREE_CHECKING */
 
 #define TEMPLATE_INFO_DECL_CHECK(NODE) (NODE)
 #define THUNK_FUNCTION_CHECK(NODE) (NODE)
+#define DECL_TEMPLATE_PARM_CHECK(NODE) (NODE)
 
 #endif /* ENABLE_TREE_CHECKING */
 \f
@@ -3577,6 +3581,11 @@ struct GTY(()) lang_decl {
    need.  But we want a more descriptive name.  */
 #define DECL_VTABLE_OR_VTT_P(NODE) DECL_VIRTUAL_P (VAR_DECL_CHECK (NODE))
 
+/* 1 iff a _DECL for a template parameter came from
+   synthesize_implicit_template_parm.  */
+#define DECL_IMPLICIT_TEMPLATE_PARM_P(NODE) \
+  DECL_VIRTUAL_P (DECL_TEMPLATE_PARM_CHECK (NODE))
+
 /* 1 iff FUNCTION_TYPE or METHOD_TYPE has a ref-qualifier (either & or &&). */
 #define FUNCTION_REF_QUALIFIED(NODE) \
   TREE_LANG_FLAG_4 (FUNC_OR_METHOD_CHECK (NODE))
@@ -5057,6 +5066,16 @@ get_vec_init_expr (tree t)
        || TREE_CODE (NODE) == TYPE_DECL                \
        || TREE_CODE (NODE) == TEMPLATE_DECL))
 
+#if ENABLE_TREE_CHECKING
+inline tree
+decl_template_parm_check (const_tree t, const char *f, int l, const char *fn)
+{
+  if (!DECL_TEMPLATE_PARM_P (t))
+    tree_check_failed (t, f, l, fn, 0);
+  return const_cast<tree>(t);
+}
+#endif
+
 /* Nonzero for a raw template parameter node.  */
 #define TEMPLATE_PARM_P(NODE)                                  \
   (TREE_CODE (NODE) == TEMPLATE_TYPE_PARM                      \
index afa68da871c2bbe07cac33ea9c4fd98f0560ae19..5137305ed0753b2504313a64ecfb7dc6ae8ff4fd 100644 (file)
@@ -1744,7 +1744,7 @@ write_closure_template_head (tree tmpl)
        continue;
       parm = TREE_VALUE (parm);
 
-      if (DECL_VIRTUAL_P (parm))
+      if (DECL_IMPLICIT_TEMPLATE_PARM_P (parm))
        // A synthetic parm, we're done.
        break;
 
index d110433621500f752d5d4f51653c201902176fa7..f556b8f3c0157958f70e8d44cabc90e533eb287c 100644 (file)
@@ -50895,7 +50895,7 @@ synthesize_implicit_template_parm  (cp_parser *parser, tree constr)
      Note that DECL_ARTIFICIAL is used elsewhere for template
      parameters.  */
   if (TREE_VALUE (new_parm) != error_mark_node)
-    DECL_VIRTUAL_P (TREE_VALUE (new_parm)) = true;
+    DECL_IMPLICIT_TEMPLATE_PARM_P (TREE_VALUE (new_parm)) = true;
 
   tree new_decl = get_local_decls ();
   if (non_type)
index 324f6f01555b85a6aa27ca2dab01ee77d4e4bb35..1de9d3eb44f3583392a9e777ce6ab371d593e98c 100644 (file)
@@ -3359,7 +3359,8 @@ template_parameters_equivalent_p (const_tree parm1, const_tree parm2)
   /* ... one parameter was introduced by a parameter declaration, then
      both are. This case arises as a result of eagerly rewriting declarations
      during parsing.  */
-  if (DECL_VIRTUAL_P (decl1) != DECL_VIRTUAL_P (decl2))
+  if (DECL_IMPLICIT_TEMPLATE_PARM_P (decl1)
+      != DECL_IMPLICIT_TEMPLATE_PARM_P (decl2))
     return false;
 
   /* ... if either declares a pack, they both do.  */