aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
Diffstat (limited to 'gcc')
-rw-r--r--gcc/cp/cp-tree.h7
-rw-r--r--gcc/cp/cxx-pretty-print.cc2
-rw-r--r--gcc/cp/error.cc2
-rw-r--r--gcc/cp/mangle.cc2
-rw-r--r--gcc/cp/pt.cc35
5 files changed, 26 insertions, 22 deletions
diff --git a/gcc/cp/cp-tree.h b/gcc/cp/cp-tree.h
index 19bbfbc..d0f1b18 100644
--- a/gcc/cp/cp-tree.h
+++ b/gcc/cp/cp-tree.h
@@ -518,6 +518,7 @@ extern GTY(()) tree cp_global_trees[CPTI_MAX];
CALL_EXPR_REVERSE_ARGS (in CALL_EXPR, AGGR_INIT_EXPR)
CONSTRUCTOR_PLACEHOLDER_BOUNDARY (in CONSTRUCTOR)
OVL_EXPORT_P (in OVERLOAD)
+ DECL_NTTP_OBJECT_P (in VAR_DECL)
6: TYPE_MARKED_P (in _TYPE)
DECL_NONTRIVIALLY_INITIALIZED_P (in VAR_DECL)
RANGE_FOR_IVDEP (in RANGE_FOR_STMT)
@@ -3548,6 +3549,10 @@ struct GTY(()) lang_decl {
#define DECL_TINFO_P(NODE) \
TREE_LANG_FLAG_4 (TREE_CHECK2 (NODE,VAR_DECL,TYPE_DECL))
+/* true iff VAR_DECL node NODE is a NTTP object decl. */
+#define DECL_NTTP_OBJECT_P(NODE) \
+ TREE_LANG_FLAG_5 (TREE_CHECK (NODE,VAR_DECL))
+
/* 1 iff VAR_DECL node NODE is virtual table or VTT. We forward to
DECL_VIRTUAL_P from the common code, as that has the semantics we
need. But we want a more descriptive name. */
@@ -7414,7 +7419,7 @@ extern bool alias_type_or_template_p (tree);
enum { nt_opaque = false, nt_transparent = true };
extern tree alias_template_specialization_p (const_tree, bool);
extern tree dependent_alias_template_spec_p (const_tree, bool);
-extern bool template_parm_object_p (const_tree);
+extern tree get_template_parm_object (tree expr, tree mangle);
extern tree tparm_object_argument (tree);
extern bool explicit_class_specialization_p (tree);
extern bool push_tinst_level (tree);
diff --git a/gcc/cp/cxx-pretty-print.cc b/gcc/cp/cxx-pretty-print.cc
index e18143e3..bbd51bb 100644
--- a/gcc/cp/cxx-pretty-print.cc
+++ b/gcc/cp/cxx-pretty-print.cc
@@ -1956,7 +1956,7 @@ pp_cxx_template_argument_list (cxx_pretty_printer *pp, tree t)
if (TYPE_P (arg) || (TREE_CODE (arg) == TEMPLATE_DECL
&& TYPE_P (DECL_TEMPLATE_RESULT (arg))))
pp->type_id (arg);
- else if (template_parm_object_p (arg))
+ else if (TREE_CODE (arg) == VAR_DECL && DECL_NTTP_OBJECT_P (arg))
pp->expression (DECL_INITIAL (arg));
else
pp->expression (arg);
diff --git a/gcc/cp/error.cc b/gcc/cp/error.cc
index 0389f35..53904e3 100644
--- a/gcc/cp/error.cc
+++ b/gcc/cp/error.cc
@@ -1129,7 +1129,7 @@ dump_global_iord (cxx_pretty_printer *pp, tree t)
static void
dump_simple_decl (cxx_pretty_printer *pp, tree t, tree type, int flags)
{
- if (template_parm_object_p (t))
+ if (TREE_CODE (t) == VAR_DECL && DECL_NTTP_OBJECT_P (t))
return dump_expr (pp, DECL_INITIAL (t), flags);
if (flags & TFF_DECL_SPECIFIERS)
diff --git a/gcc/cp/mangle.cc b/gcc/cp/mangle.cc
index 00d283f..1a45585 100644
--- a/gcc/cp/mangle.cc
+++ b/gcc/cp/mangle.cc
@@ -3672,7 +3672,7 @@ write_template_arg (tree node)
}
}
- if (template_parm_object_p (node))
+ if (TREE_CODE (node) == VAR_DECL && DECL_NTTP_OBJECT_P (node))
/* We want to mangle the argument, not the var we stored it in. */
node = tparm_object_argument (node);
diff --git a/gcc/cp/pt.cc b/gcc/cp/pt.cc
index 2d83dfd..c7adaef 100644
--- a/gcc/cp/pt.cc
+++ b/gcc/cp/pt.cc
@@ -7112,16 +7112,6 @@ unify_template_argument_mismatch (bool explain_p, tree parm, tree arg)
return unify_invalid (explain_p);
}
-/* True if T is a C++20 template parameter object to store the argument for a
- template parameter of class type. */
-
-bool
-template_parm_object_p (const_tree t)
-{
- return (TREE_CODE (t) == VAR_DECL && DECL_ARTIFICIAL (t) && DECL_NAME (t)
- && startswith (IDENTIFIER_POINTER (DECL_NAME (t)), "_ZTA"));
-}
-
/* Subroutine of convert_nontype_argument, to check whether EXPR, as an
argument for TYPE, points to an unsuitable object.
@@ -7256,16 +7246,11 @@ invalid_tparm_referent_p (tree type, tree expr, tsubst_flags_t complain)
}
-/* The template arguments corresponding to template parameter objects of types
- that contain pointers to members. */
-
-static GTY(()) hash_map<tree, tree> *tparm_obj_values;
-
/* Return a VAR_DECL for the C++20 template parameter object corresponding to
template argument EXPR. */
static tree
-get_template_parm_object (tree expr, tsubst_flags_t complain)
+create_template_parm_object (tree expr, tsubst_flags_t complain)
{
if (TREE_CODE (expr) == TARGET_EXPR)
expr = TARGET_EXPR_INITIAL (expr);
@@ -7283,13 +7268,27 @@ get_template_parm_object (tree expr, tsubst_flags_t complain)
/* This is no longer a compound literal. */
gcc_assert (!TREE_HAS_CONSTRUCTOR (expr));
- tree name = mangle_template_parm_object (expr);
+ return get_template_parm_object (expr, mangle_template_parm_object (expr));
+}
+
+/* The template arguments corresponding to template parameter objects of types
+ that contain pointers to members. */
+
+static GTY(()) hash_map<tree, tree> *tparm_obj_values;
+
+/* Find or build an nttp object for (already-validated) EXPR with name
+ NAME. */
+
+tree
+get_template_parm_object (tree expr, tree name)
+{
tree decl = get_global_binding (name);
if (decl)
return decl;
tree type = cp_build_qualified_type (TREE_TYPE (expr), TYPE_QUAL_CONST);
decl = create_temporary_var (type);
+ DECL_NTTP_OBJECT_P (decl) = true;
DECL_CONTEXT (decl) = NULL_TREE;
TREE_STATIC (decl) = true;
DECL_DECLARED_CONSTEXPR_P (decl) = true;
@@ -7776,7 +7775,7 @@ convert_nontype_argument (tree type, tree expr, tsubst_flags_t complain)
/* Replace the argument with a reference to the corresponding template
parameter object. */
if (!val_dep_p)
- expr = get_template_parm_object (expr, complain);
+ expr = create_template_parm_object (expr, complain);
if (expr == error_mark_node)
return NULL_TREE;
}