re PR c++/48452 ([C++0x][SFINAE] Failures with n-ary initialization expressions ...
authorJason Merrill <jason@redhat.com>
Thu, 7 Apr 2011 21:47:53 +0000 (17:47 -0400)
committerJason Merrill <jason@gcc.gnu.org>
Thu, 7 Apr 2011 21:47:53 +0000 (17:47 -0400)
PR c++/48452
* typeck.c (build_x_compound_expr_from_list): Return error_mark_node
in SFINAE context.

From-SVN: r172147

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

index 976c7fb6f653b77669bca83c25af481cde663e6a..04b9c402723d14fe32a0fafc3e3bea13e69053fb 100644 (file)
@@ -1,5 +1,9 @@
 2011-04-07  Jason Merrill  <jason@redhat.com>
 
+       PR c++/48452
+       * typeck.c (build_x_compound_expr_from_list): Return error_mark_node
+       in SFINAE context.
+
        PR c++/48450
        * call.c (resolve_args): Take complain.
        (build_new_function_call, build_operator_new_call): Pass it.
index 8e3796e2757179169b4ded2aaca934a9bdb3fe8b..ecd7d41fc72a4f6d3310084211304ffa9375de01 100644 (file)
@@ -5472,6 +5472,8 @@ build_x_compound_expr_from_list (tree list, expr_list_kind exp,
          default:
            gcc_unreachable ();
          }
+      else
+       return error_mark_node;
 
       for (list = TREE_CHAIN (list); list; list = TREE_CHAIN (list))
        expr = build_x_compound_expr (expr, TREE_VALUE (list), 
index dcdd32d9895bb7d9bfecf5cdfc0ee1026ea589b8..38f097208e53686a16898602a95e12108af4200a 100644 (file)
@@ -1,5 +1,7 @@
 2011-04-07  Jason Merrill  <jason@redhat.com>
 
+       * g++.dg/cpp0x/sfinae10.C: New.
+
        * g++.dg/cpp0x/sfinae9.C: New.
 
        * c-c++-common/Wcast-qual-1.c: Move here from...
diff --git a/gcc/testsuite/g++.dg/cpp0x/sfinae10.C b/gcc/testsuite/g++.dg/cpp0x/sfinae10.C
new file mode 100644 (file)
index 0000000..ede8b70
--- /dev/null
@@ -0,0 +1,18 @@
+// PR c++/48452
+// { dg-options -std=c++0x }
+namespace std {
+  template <class T> T&& declval();
+}
+
+template<class T, class... Args>
+decltype(T(std::declval<Args>()...), char()) f(int);
+
+template<class, class...>
+char (&f(...))[2];
+
+struct A { virtual ~A() = 0; };
+struct B {};
+
+static_assert(sizeof(f<A, int, int>(0)) != 1, "Error"); // a
+static_assert(sizeof(f<B, void, int>(0)) != 1, "Error"); // b
+static_assert(sizeof(f<void, int, int>(0)) != 1, "Error"); // c