PR c++/84785 - ICE with alias template and default targs.
authorJason Merrill <jason@redhat.com>
Sat, 10 Mar 2018 03:34:29 +0000 (22:34 -0500)
committerJason Merrill <jason@gcc.gnu.org>
Sat, 10 Mar 2018 03:34:29 +0000 (22:34 -0500)
* pt.c (type_unification_real): Set processing_template_decl if
saw_undeduced == 1.

From-SVN: r258407

gcc/cp/ChangeLog
gcc/cp/pt.c
gcc/testsuite/g++.dg/cpp0x/alias-decl-63.C [new file with mode: 0644]

index 05cfb768bc684ff565ba1a911c07afba5ad81f10..95ed64d464db41ab25905a892189c57d74d72063 100644 (file)
@@ -1,5 +1,9 @@
 2018-03-09  Jason Merrill  <jason@redhat.com>
 
+       PR c++/84785 - ICE with alias template and default targs.
+       * pt.c (type_unification_real): Set processing_template_decl if
+       saw_undeduced == 1.
+
        PR c++/84752 - ICE with capture of constexpr array.
        * call.c (standard_conversion): Set rvaluedness_matches_p on the
        identity conversion under ck_lvalue.
index bc815d2976453dced34fa3e7a3c373727eebacb2..d91e8bb559f8102a2f157d6f94b26c4f7f7db6ae 100644 (file)
@@ -19977,7 +19977,13 @@ type_unification_real (tree tparms,
          location_t save_loc = input_location;
          if (DECL_P (parm))
            input_location = DECL_SOURCE_LOCATION (parm);
+
+         if (saw_undeduced == 1)
+           ++processing_template_decl;
          arg = tsubst_template_arg (arg, full_targs, fcomplain, NULL_TREE);
+         if (saw_undeduced == 1)
+           --processing_template_decl;
+
          if (arg != error_mark_node && !uses_template_parms (arg))
            arg = convert_template_argument (parm, arg, full_targs, complain,
                                             i, NULL_TREE);
diff --git a/gcc/testsuite/g++.dg/cpp0x/alias-decl-63.C b/gcc/testsuite/g++.dg/cpp0x/alias-decl-63.C
new file mode 100644 (file)
index 0000000..04fb42d
--- /dev/null
@@ -0,0 +1,18 @@
+// PR c++/84785
+// { dg-do compile { target c++11 } }
+
+template <typename> struct A;
+template <bool> struct B;
+template <bool B, typename> using enable_if_t = typename B<B>::type;
+template <long> using type_pack_element = int;
+struct variant {
+  variant() {}
+  template <typename Arg, long I = Arg::type::value,
+            typename = type_pack_element<I>, enable_if_t<A<Arg>::value, int>>
+  variant(Arg &&);
+};
+
+struct S {
+  variant var;
+};
+int main() { S s; }