aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJason Merrill <jason@redhat.com>2019-02-21 18:07:12 -0500
committerJason Merrill <jason@gcc.gnu.org>2019-02-21 18:07:12 -0500
commit5498361c0f4822b2c48f19835963afa5a630175b (patch)
tree7668aef3c0488b46384790be0adb6de7e947dfd5
parenteeb20b969684d4c502ee168cdffd67cc491cd354 (diff)
downloadgcc-5498361c0f4822b2c48f19835963afa5a630175b.zip
gcc-5498361c0f4822b2c48f19835963afa5a630175b.tar.gz
gcc-5498361c0f4822b2c48f19835963afa5a630175b.tar.bz2
PR c++/88419 - C++17 ICE with class template arg deduction.
Just like in make_constrained_auto, we need to defer setting TYPE_CANONICAL until we've set fields that will affect structural_comptypes. * pt.c (make_template_placeholder): Set TYPE_CANONICAL after CLASS_PLACEHOLDER_TEMPLATE. From-SVN: r269080
-rw-r--r--gcc/cp/ChangeLog6
-rw-r--r--gcc/cp/pt.c4
-rw-r--r--gcc/testsuite/g++.dg/cpp1z/class-deduction62.C22
3 files changed, 31 insertions, 1 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index 824d007..228100a 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -1,3 +1,9 @@
+2019-02-21 Jason Merrill <jason@redhat.com>
+
+ PR c++/88419 - C++17 ICE with class template arg deduction.
+ * pt.c (make_template_placeholder): Set TYPE_CANONICAL after
+ CLASS_PLACEHOLDER_TEMPLATE.
+
2019-02-21 Jakub Jelinek <jakub@redhat.com>
PR c++/89285
diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c
index a212be8..bd0a3d1 100644
--- a/gcc/cp/pt.c
+++ b/gcc/cp/pt.c
@@ -26619,8 +26619,10 @@ make_auto (void)
tree
make_template_placeholder (tree tmpl)
{
- tree t = make_auto_1 (auto_identifier, true);
+ tree t = make_auto_1 (auto_identifier, false);
CLASS_PLACEHOLDER_TEMPLATE (t) = tmpl;
+ /* Our canonical type depends on the placeholder. */
+ TYPE_CANONICAL (t) = canonical_type_parameter (t);
return t;
}
diff --git a/gcc/testsuite/g++.dg/cpp1z/class-deduction62.C b/gcc/testsuite/g++.dg/cpp1z/class-deduction62.C
new file mode 100644
index 0000000..2baa3ac
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cpp1z/class-deduction62.C
@@ -0,0 +1,22 @@
+// PR c++/88419
+// { dg-do compile { target c++17 } }
+
+template<class> struct ref_view {
+ template<class T> ref_view(T&&);
+};
+
+template<class R> ref_view(R&) -> ref_view<R>;
+
+struct ref_fn {
+ template<class R> auto operator()(R r) const
+ noexcept(noexcept(ref_view{r}));
+};
+
+template<class R> struct indirect_view {
+ indirect_view(R);
+};
+
+struct indirect_fn {
+ template<class R> auto operator()(R r) const
+ noexcept(noexcept(indirect_view{r}));
+};