re PR c++/49229 ([C++0x][SFINAE] ICE with variadics and depending non-type default...
authorJason Merrill <jason@redhat.com>
Thu, 16 Jun 2011 22:09:05 +0000 (18:09 -0400)
committerJason Merrill <jason@gcc.gnu.org>
Thu, 16 Jun 2011 22:09:05 +0000 (18:09 -0400)
PR c++/49229
* pt.c (tsubst_decl) [FUNCTION_DECL]: Handle substitution failure.

From-SVN: r175120

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

index a8baca2eb6539732005ef1494e7be80baf919729..000a78149a4198cea161129174a939320adc1c86 100644 (file)
@@ -1,5 +1,8 @@
 2011-06-16  Jason Merrill  <jason@redhat.com>
 
+       PR c++/49229
+       * pt.c (tsubst_decl) [FUNCTION_DECL]: Handle substitution failure.
+
        PR c++/49251
        * semantics.c (finish_id_expression): Mark even dependent
        variables as used.
index ff145a263fd397ce4c6e4f2628393cb025fcc11f..1008b3be399a810ec871ec5fe4bef8757b2d2434 100644 (file)
@@ -9548,6 +9548,8 @@ tsubst_decl (tree t, tree args, tsubst_flags_t complain)
                                           (DECL_TEMPLATE_RESULT
                                                  (DECL_TI_TEMPLATE (t))),
                                           args, complain, in_decl);
+           if (argvec == error_mark_node)
+             RETURN (error_mark_node);
 
            /* Check to see if we already have this specialization.  */
            hash = hash_tmpl_and_args (gen_tmpl, argvec);
index cc12e7bf27949dcff78cdc4d68b47df0e1c45b92..677ac710fda3b652ca702ca62b3df8433936a679 100644 (file)
@@ -1,5 +1,8 @@
 2011-06-16  Jason Merrill  <jason@redhat.com>
 
+       PR c++/49229
+       * g++.dg/cpp0x/sfinae26.C: New.
+
        PR c++/49251
        * g++.dg/cpp0x/variadic113.C: New.
 
diff --git a/gcc/testsuite/g++.dg/cpp0x/sfinae26.C b/gcc/testsuite/g++.dg/cpp0x/sfinae26.C
new file mode 100644 (file)
index 0000000..5b8cdd9
--- /dev/null
@@ -0,0 +1,38 @@
+// PR c++/49229
+// { dg-options -std=c++0x }
+
+extern void* enabler;
+
+template<bool, class = void>
+struct enable_if {};
+
+template<class T>
+struct enable_if<true, T> {
+  typedef T type;
+};
+
+template<class... Bn>
+struct and_;
+
+template<class B1>
+struct and_<B1> : B1 {};
+
+template<class, class>
+struct is_same {
+  static constexpr bool value = false;
+};
+
+template<class T>
+struct is_same<T, T> {
+  static constexpr bool value = true;
+};
+
+template<class... T>
+struct S {
+  template<class... U,
+    typename enable_if<and_<is_same<T, U>...>::value>::type*& = enabler
+  >
+  S(U...){} // #
+};
+
+S<bool> s(0);                  // { dg-error "no match" }