aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorAlexandre Oliva <aoliva@redhat.com>2019-01-17 07:32:16 +0000
committerAlexandre Oliva <aoliva@gcc.gnu.org>2019-01-17 07:32:16 +0000
commit33f746e5585fb4da99cded09a44efd49ef2f22c7 (patch)
treec288da29f73644c8455d8be816191d34f7524634 /gcc
parentb25a37564938313a6deed3b6518d03552431c160 (diff)
downloadgcc-33f746e5585fb4da99cded09a44efd49ef2f22c7.zip
gcc-33f746e5585fb4da99cded09a44efd49ef2f22c7.tar.gz
gcc-33f746e5585fb4da99cded09a44efd49ef2f22c7.tar.bz2
[PR86648] use auto identifier for class placeholder templates
dwarf2out recognizes unspecified auto types by the identifier. C++ template class placeholders are unspecified auto types that take the identifier of the class rather than those used by preexisting auto types, so dwarf2out ICEs when it finds one of those. Alas, they may be visible to dwarf2out, since the types of e.g. static data members of templates are only deduced at member instantiation, i.e., if the data member is actually referenced, but the data member is added as a field, still with unspecified auto placeholder type, when the enclosing class is instantiated. I've changed placeholder creator to use an auto identifier instead, which allowed dropping the placeholder test in C++'s is_auto (alas, it can't be used in dwarf2out, think LTO). To avoid losing information in error messages and dumps and whatnot, I've added code to recognize placeholders for template classes say A and print them out as A<...auto...>. for gcc/cp/ChangeLog PR c++/86648 * pt.c (make_template_placeholder): Use auto_identifier. (is_auto): Drop CLASS_PLACEHOLDER_TEMPLATE test. * error.c (dump_type): Handle template placeholders. * cxx-pretty-print.c (pp_cx_unqualified_id): Likewise. for gcc/testsuite/ChangeLog PR c++/86648 * gcc.dg/cpp1z/pr86648.C: New. From-SVN: r268005
Diffstat (limited to 'gcc')
-rw-r--r--gcc/cp/ChangeLog6
-rw-r--r--gcc/cp/cxx-pretty-print.c8
-rw-r--r--gcc/cp/error.c6
-rw-r--r--gcc/cp/pt.c5
-rw-r--r--gcc/testsuite/ChangeLog5
-rw-r--r--gcc/testsuite/g++.dg/cpp1z/pr86648.C5
6 files changed, 31 insertions, 4 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index 732aa53..73f1b76 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -1,5 +1,11 @@
2019-01-17 Alexandre Oliva <aoliva@redhat.com>
+ PR c++/86648
+ * pt.c (make_template_placeholder): Use auto_identifier.
+ (is_auto): Drop CLASS_PLACEHOLDER_TEMPLATE test.
+ * error.c (dump_type): Handle template placeholders.
+ * cxx-pretty-print.c (pp_cx_unqualified_id): Likewise.
+
PR c++/88146
* cvt.c (convert_to_void): Handle all cdtor calls as if
returning void.
diff --git a/gcc/cp/cxx-pretty-print.c b/gcc/cp/cxx-pretty-print.c
index 47eebd1..a114d66 100644
--- a/gcc/cp/cxx-pretty-print.c
+++ b/gcc/cp/cxx-pretty-print.c
@@ -187,7 +187,13 @@ pp_cxx_unqualified_id (cxx_pretty_printer *pp, tree t)
case TEMPLATE_TYPE_PARM:
case TEMPLATE_TEMPLATE_PARM:
- if (TYPE_IDENTIFIER (t))
+ if (template_placeholder_p (t))
+ {
+ t = TREE_TYPE (CLASS_PLACEHOLDER_TEMPLATE (t));
+ pp_cxx_unqualified_id (pp, TYPE_IDENTIFIER (t));
+ pp_string (pp, "<...auto...>");
+ }
+ else if (TYPE_IDENTIFIER (t))
pp_cxx_unqualified_id (pp, TYPE_IDENTIFIER (t));
else
pp_cxx_canonical_template_parameter (pp, t);
diff --git a/gcc/cp/error.c b/gcc/cp/error.c
index 3677213..f585d5f 100644
--- a/gcc/cp/error.c
+++ b/gcc/cp/error.c
@@ -546,6 +546,12 @@ dump_type (cxx_pretty_printer *pp, tree t, int flags)
pp_cxx_cv_qualifier_seq (pp, t);
if (tree c = PLACEHOLDER_TYPE_CONSTRAINTS (t))
pp_cxx_constrained_type_spec (pp, c);
+ else if (template_placeholder_p (t))
+ {
+ t = TREE_TYPE (CLASS_PLACEHOLDER_TEMPLATE (t));
+ pp_cxx_tree_identifier (pp, TYPE_IDENTIFIER (t));
+ pp_string (pp, "<...auto...>");
+ }
else if (TYPE_IDENTIFIER (t))
pp_cxx_tree_identifier (pp, TYPE_IDENTIFIER (t));
else
diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c
index 83bceb2..e4f7647 100644
--- a/gcc/cp/pt.c
+++ b/gcc/cp/pt.c
@@ -26458,7 +26458,7 @@ make_auto (void)
tree
make_template_placeholder (tree tmpl)
{
- tree t = make_auto_1 (DECL_NAME (tmpl), true);
+ tree t = make_auto_1 (auto_identifier, true);
CLASS_PLACEHOLDER_TEMPLATE (t) = tmpl;
return t;
}
@@ -27391,8 +27391,7 @@ is_auto (const_tree type)
{
if (TREE_CODE (type) == TEMPLATE_TYPE_PARM
&& (TYPE_IDENTIFIER (type) == auto_identifier
- || TYPE_IDENTIFIER (type) == decltype_auto_identifier
- || CLASS_PLACEHOLDER_TEMPLATE (type)))
+ || TYPE_IDENTIFIER (type) == decltype_auto_identifier))
return true;
else
return false;
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index cd20207..3ce3da7 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,8 @@
+2019-01-17 Alexandre Oliva <aoliva@redhat.com>
+
+ PR c++/86648
+ * gcc.dg/cpp1z/pr86648.C: New.
+
2019-01-17 Kewen Lin <linkw@gcc.gnu.org>
PR target/87306
diff --git a/gcc/testsuite/g++.dg/cpp1z/pr86648.C b/gcc/testsuite/g++.dg/cpp1z/pr86648.C
new file mode 100644
index 0000000..20ee4c8
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cpp1z/pr86648.C
@@ -0,0 +1,5 @@
+// { dg-do compile { target c++17 } }
+
+template <typename> class A;
+template <class T> struct B { static A a{T::a}; };
+void foo () { B<int> a; }