diff options
Diffstat (limited to 'gcc/cp/pt.cc')
| -rw-r--r-- | gcc/cp/pt.cc | 35 |
1 files changed, 17 insertions, 18 deletions
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; } |
