aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJason Merrill <jason@redhat.com>2018-03-20 08:44:49 -0400
committerJason Merrill <jason@gcc.gnu.org>2018-03-20 08:44:49 -0400
commitd9bf40a181b32e4d5e581ec10d48803ea4a43f9d (patch)
tree816277b72976eec83436eba7bbab34438eeb4f38
parent79cf14ae15e78ac1845d6498a34a539a6eefa55a (diff)
downloadgcc-d9bf40a181b32e4d5e581ec10d48803ea4a43f9d.zip
gcc-d9bf40a181b32e4d5e581ec10d48803ea4a43f9d.tar.gz
gcc-d9bf40a181b32e4d5e581ec10d48803ea4a43f9d.tar.bz2
PR c++/84937 - ICE with class deduction and auto.
* pt.c (rewrite_template_parm): Fix auto handling. From-SVN: r258680
-rw-r--r--gcc/cp/ChangeLog7
-rw-r--r--gcc/cp/pt.c17
-rw-r--r--gcc/testsuite/g++.dg/cpp1z/class-deduction51.C11
3 files changed, 32 insertions, 3 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index 236ea21..fd7329f 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -1,3 +1,8 @@
+2018-03-19 Jason Merrill <jason@redhat.com>
+
+ PR c++/84937 - ICE with class deduction and auto.
+ * pt.c (rewrite_template_parm): Fix auto handling.
+
2018-03-19 Marek Polacek <polacek@redhat.com>
PR c++/84925
@@ -9,7 +14,7 @@
(cxx_eval_constant_expression): Verify constructor's flags
unconditionally.
-2018-03-16 Jason Merrill <jason@redhat.com>
+2018-03-19 Jason Merrill <jason@redhat.com>
PR c++/71834 - template-id with too few arguments.
* pt.c (coerce_template_parms): Check fixed_parameter_pack_p.
diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c
index 21a4de5..d7c0c7b 100644
--- a/gcc/cp/pt.c
+++ b/gcc/cp/pt.c
@@ -25781,8 +25781,21 @@ rewrite_template_parm (tree olddecl, unsigned index, unsigned level,
= TEMPLATE_TYPE_PARM_FOR_CLASS (oldtype);
}
else
- newtype = tsubst (TREE_TYPE (olddecl), tsubst_args,
- complain, NULL_TREE);
+ {
+ newtype = TREE_TYPE (olddecl);
+ if (type_uses_auto (newtype))
+ {
+ // Substitute once to fix references to other template parameters.
+ newtype = tsubst (newtype, tsubst_args,
+ complain|tf_partial, NULL_TREE);
+ // Now substitute again to reduce the level of the auto.
+ newtype = tsubst (newtype, current_template_args (),
+ complain, NULL_TREE);
+ }
+ else
+ newtype = tsubst (newtype, tsubst_args,
+ complain, NULL_TREE);
+ }
tree newdecl
= build_decl (DECL_SOURCE_LOCATION (olddecl), TREE_CODE (olddecl),
diff --git a/gcc/testsuite/g++.dg/cpp1z/class-deduction51.C b/gcc/testsuite/g++.dg/cpp1z/class-deduction51.C
new file mode 100644
index 0000000..eba7972
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cpp1z/class-deduction51.C
@@ -0,0 +1,11 @@
+// PR c++/84937
+// { dg-additional-options -std=c++17 }
+
+template<int, int> struct A {};
+
+template<int I> struct B
+{
+ template<auto J> B(A<I,J>);
+};
+
+B b(A<0,0>{});