aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJason Merrill <jason@redhat.com>2023-10-17 18:01:28 -0400
committerJason Merrill <jason@redhat.com>2023-11-19 21:52:35 -0500
commitc51eafc1a185f7ad00820f11a7aa7bf4a82093fa (patch)
treee09871e7a86ce253d752dbdc7ed1dd19087d3c70
parent0d734c79387191005c909c54c7556a88254c401b (diff)
downloadgcc-c51eafc1a185f7ad00820f11a7aa7bf4a82093fa.zip
gcc-c51eafc1a185f7ad00820f11a7aa7bf4a82093fa.tar.gz
gcc-c51eafc1a185f7ad00820f11a7aa7bf4a82093fa.tar.bz2
c++: add DECL_IMPLICIT_TEMPLATE_PARM_P macro
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.
-rw-r--r--gcc/cp/cp-tree.h19
-rw-r--r--gcc/cp/mangle.cc2
-rw-r--r--gcc/cp/parser.cc2
-rw-r--r--gcc/cp/pt.cc3
4 files changed, 23 insertions, 3 deletions
diff --git a/gcc/cp/cp-tree.h b/gcc/cp/cp-tree.h
index c7a1cf6..7b0b7c6 100644
--- a/gcc/cp/cp-tree.h
+++ b/gcc/cp/cp-tree.h
@@ -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 */
@@ -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 \
diff --git a/gcc/cp/mangle.cc b/gcc/cp/mangle.cc
index afa68da..5137305 100644
--- a/gcc/cp/mangle.cc
+++ b/gcc/cp/mangle.cc
@@ -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;
diff --git a/gcc/cp/parser.cc b/gcc/cp/parser.cc
index d110433..f556b8f 100644
--- a/gcc/cp/parser.cc
+++ b/gcc/cp/parser.cc
@@ -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)
diff --git a/gcc/cp/pt.cc b/gcc/cp/pt.cc
index 324f6f0..1de9d3e 100644
--- a/gcc/cp/pt.cc
+++ b/gcc/cp/pt.cc
@@ -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. */