Implement P0732R2, class types in non-type template parameters

Programming / Compilers / GCC - jason [138bc75d-0d04-0410-961f-82ee72b054a4] - 5 November 2018 07:47 EST

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.

95f798aaef2 Implement P0732R2, class types in non-type template parameters.
gcc/c-family/ChangeLog | 5 +
gcc/c-family/c-cppbuiltin.c | 1 +
gcc/cp/ChangeLog | 10 +
gcc/cp/cp-tree.h | 2 +
gcc/cp/error.c | 3 +
gcc/cp/mangle.c | 17 ++
gcc/cp/pt.c | 352 +++++++++++++++++++---------
gcc/cp/semantics.c | 16 +-
gcc/cp/tree.c | 6 +
gcc/testsuite/g++.dg/cpp2a/feat-cxx2a.C | 6 +
gcc/testsuite/g++.dg/cpp2a/nontype-class1.C | 33 +++
gcc/testsuite/g++.dg/cpp2a/nontype-class2.C | 17 ++
gcc/testsuite/g++.dg/cpp2a/nontype-class3.C | 16 ++
gcc/testsuite/g++.dg/cpp2a/nontype-class4.C | 18 ++
gcc/testsuite/g++.dg/cpp2a/nontype-class5.C | 12 +
gcc/testsuite/g++.dg/cpp2a/nontype-class7.C | 26 ++
gcc/testsuite/g++.dg/cpp2a/nontype-class8.C | 26 ++
gcc/testsuite/g++.dg/template/crash55.C | 2 +-
gcc/testsuite/g++.dg/template/nontype16.C | 2 +-
gcc/testsuite/g++.dg/template/nontype4.C | 2 +-
gcc/testsuite/g++.dg/template/nontype5.C | 2 +-
gcc/testsuite/g++.dg/template/operator10.C | 2 +-
include/ChangeLog | 5 +
include/demangle.h | 3 +
libiberty/ChangeLog | 8 +
libiberty/cp-demangle.c | 17 +-
libiberty/testsuite/demangle-expected | 6 +
27 files changed, 494 insertions(+), 121 deletions(-)

Upstream: gcc.gnu.org


  • Share