diff options
author | Jason Merrill <jason@redhat.com> | 2018-11-05 02:47:02 -0500 |
---|---|---|
committer | Jason Merrill <jason@gcc.gnu.org> | 2018-11-05 02:47:02 -0500 |
commit | 4be5c72cf3ea3ee98a97ac2e53d21122ad224b10 (patch) | |
tree | 074d1e84a17c188274a39b3a002dc5c265626a8e /gcc/cp/mangle.c | |
parent | 5dab8b11c41fe72ea606c38884f7730bd2aeafdc (diff) | |
download | gcc-4be5c72cf3ea3ee98a97ac2e53d21122ad224b10.zip gcc-4be5c72cf3ea3ee98a97ac2e53d21122ad224b10.tar.gz gcc-4be5c72cf3ea3ee98a97ac2e53d21122ad224b10.tar.bz2 |
Implement P0732R2, class types in non-type template parameters.
There is one significant piece of this that is not implemented yet: the
reliance on defaulted operator<=>, which someone else has been working on.
So, for the moment those lines are commented out of the testcases.
One tricky bit was treating template parameters of classtype as const
lvalues without making their decltype const; for this I used a
VIEW_CONVERT_EXPR wrapper, which previously could only appear in templates
as location wrappers.
The user-defined literal parts of P0732R2 are in the next patch.
gcc/cp/
* error.c (dump_simple_decl): Look through a template parm object.
* mangle.c (write_template_arg): Likewise.
(mangle_template_parm_object): New.
* pt.c (template_parm_object_p, get_template_parm_object): New.
(invalid_tparm_referent_p): Factor from convert_nontype_argument.
(convert_nontype_argument, invalid_nontype_parm_type_p): Handle
class-type template arguments.
* tree.c (lvalue_kind): Likewise.
gcc/c-family/
* c-cppbuiltin.c (c_cpp_builtins): Add
__cpp_nontype_template_parameter_class.
libiberty/
* cp-demangle.c (d_dump, d_make_comp, d_count_templates_scopes)
(d_print_comp_inner): Handle DEMANGLE_COMPONENT_TPARM_OBJ.
(d_special_name): Handle TA.
(d_expresion_1): Fix demangling of brace-enclosed initializer list.
include/
* demangle.h (enum demangle_component_type): Add
DEMANGLE_COMPONENT_TPARM_OBJ.
From-SVN: r265789
Diffstat (limited to 'gcc/cp/mangle.c')
-rw-r--r-- | gcc/cp/mangle.c | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/gcc/cp/mangle.c b/gcc/cp/mangle.c index 690d0bb..1b32301 100644 --- a/gcc/cp/mangle.c +++ b/gcc/cp/mangle.c @@ -3437,6 +3437,10 @@ write_template_arg (tree node) } } + if (template_parm_object_p (node)) + /* We want to mangle the argument, not the var we stored it in. */ + node = DECL_INITIAL (node); + /* Strip a conversion added by convert_nontype_argument. */ if (TREE_CODE (node) == IMPLICIT_CONV_EXPR) node = TREE_OPERAND (node, 0); @@ -4257,6 +4261,19 @@ mangle_ref_init_variable (const tree variable) write_unsigned_number (temp_count++); return finish_mangling_get_identifier (); } + +/* Return an identifier for the mangled name of a C++20 template parameter + object for template argument EXPR. */ + +tree +mangle_template_parm_object (tree expr) +{ + start_mangling (expr); + write_string ("_ZTAX"); + write_expression (expr); + write_char ('E'); + return finish_mangling_get_identifier (); +} /* Given a CLASS_TYPE, such as a record for std::bad_exception this function generates a mangled name for the vtable map variable of |