summaryrefslogtreecommitdiff
path: root/libiberty
diff options
context:
space:
mode:
authorJason Merrill <jason@redhat.com>2018-11-05 02:47:02 -0500
committerJason Merrill <jason@gcc.gnu.org>2018-11-05 02:47:02 -0500
commit4be5c72cf3ea3ee98a97ac2e53d21122ad224b10 (patch)
tree074d1e84a17c188274a39b3a002dc5c265626a8e /libiberty
parent5dab8b11c41fe72ea606c38884f7730bd2aeafdc (diff)
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 'libiberty')
-rw-r--r--libiberty/ChangeLog8
-rw-r--r--libiberty/cp-demangle.c17
-rw-r--r--libiberty/testsuite/demangle-expected6
3 files changed, 30 insertions, 1 deletions
diff --git a/libiberty/ChangeLog b/libiberty/ChangeLog
index a5f8742cee7..91211c87e7d 100644
--- a/libiberty/ChangeLog
+++ b/libiberty/ChangeLog
@@ -1,3 +1,11 @@
+2018-10-23 Jason Merrill <jason@redhat.com>
+
+ Implement P0732R2, class types in non-type template parameters.
+ * 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.
+
2018-10-31 Joseph Myers <joseph@codesourcery.com>
PR bootstrap/82856
diff --git a/libiberty/cp-demangle.c b/libiberty/cp-demangle.c
index 3f2a097e7f2..a1f74a51c9c 100644
--- a/libiberty/cp-demangle.c
+++ b/libiberty/cp-demangle.c
@@ -625,6 +625,9 @@ d_dump (struct demangle_component *dc, int indent)
case DEMANGLE_COMPONENT_TEMPLATE_PARAM:
printf ("template parameter %ld\n", dc->u.s_number.number);
return;
+ case DEMANGLE_COMPONENT_TPARM_OBJ:
+ printf ("template parameter object\n");
+ break;
case DEMANGLE_COMPONENT_FUNCTION_PARAM:
printf ("function parameter %ld\n", dc->u.s_number.number);
return;
@@ -1007,6 +1010,7 @@ d_make_comp (struct d_info *di, enum demangle_component_type type,
case DEMANGLE_COMPONENT_GLOBAL_DESTRUCTORS:
case DEMANGLE_COMPONENT_NULLARY:
case DEMANGLE_COMPONENT_TRINARY_ARG2:
+ case DEMANGLE_COMPONENT_TPARM_OBJ:
if (left == NULL)
return NULL;
break;
@@ -2007,6 +2011,7 @@ d_java_resource (struct d_info *di)
::= TT <type>
::= TI <type>
::= TS <type>
+ ::= TA <template-arg>
::= GV <(object) name>
::= T <call-offset> <(base) encoding>
::= Tc <call-offset> <call-offset> <(base) encoding>
@@ -2099,6 +2104,10 @@ d_special_name (struct d_info *di)
return d_make_comp (di, DEMANGLE_COMPONENT_TLS_WRAPPER,
d_name (di), NULL);
+ case 'A':
+ return d_make_comp (di, DEMANGLE_COMPONENT_TPARM_OBJ,
+ d_template_arg (di), NULL);
+
default:
return NULL;
}
@@ -3327,11 +3336,11 @@ d_expression_1 (struct d_info *di)
{
/* Brace-enclosed initializer list, untyped or typed. */
struct demangle_component *type = NULL;
+ d_advance (di, 2);
if (peek == 't')
type = cplus_demangle_type (di);
if (!d_peek_next_char (di))
return NULL;
- d_advance (di, 2);
return d_make_comp (di, DEMANGLE_COMPONENT_INITIALIZER_LIST,
type, d_exprlist (di, 'E'));
}
@@ -4101,6 +4110,7 @@ d_count_templates_scopes (int *num_templates, int *num_scopes,
case DEMANGLE_COMPONENT_VECTOR_TYPE:
case DEMANGLE_COMPONENT_ARGLIST:
case DEMANGLE_COMPONENT_TEMPLATE_ARGLIST:
+ case DEMANGLE_COMPONENT_TPARM_OBJ:
case DEMANGLE_COMPONENT_INITIALIZER_LIST:
case DEMANGLE_COMPONENT_CAST:
case DEMANGLE_COMPONENT_CONVERSION:
@@ -4872,6 +4882,11 @@ d_print_comp_inner (struct d_print_info *dpi, int options,
}
return;
+ case DEMANGLE_COMPONENT_TPARM_OBJ:
+ d_append_string (dpi, "template parameter object for ");
+ d_print_comp (dpi, options, d_left (dc));
+ return;
+
case DEMANGLE_COMPONENT_CTOR:
d_print_comp (dpi, options, dc->u.s_ctor.name);
return;
diff --git a/libiberty/testsuite/demangle-expected b/libiberty/testsuite/demangle-expected
index b62561c6d4d..40038365c83 100644
--- a/libiberty/testsuite/demangle-expected
+++ b/libiberty/testsuite/demangle-expected
@@ -4667,6 +4667,12 @@ void eat<int*, Foo()::{lambda(auto:1*, auto:2*)#6}>(int*&, Foo()::{lambda(auto:1
_Z3eatIPiZ3BarIsEvvEUlPsPT_PT0_E0_EvRS3_RS5_
void eat<int*, Bar<short>()::{lambda(short*, auto:1*, auto:2*)#2}>(int*&, Bar<short>()::{lambda(short*, auto:1*, auto:2*)#2}&)
+_Z1fP1BIXtl1ALi1EEEE
+f(B<A{1}>*)
+
+_ZTAXtl1ALi1EEE
+template parameter object for A{1}
+
# PR 77489
_ZZ3foovE8localVar_9
foo()::localVar