From 6dab6cf121a173733b7d4a4519c8eb1c573fc7cb Mon Sep 17 00:00:00 2001 From: Jason Merrill Date: Thu, 7 Apr 2011 17:47:53 -0400 Subject: [PATCH] re PR c++/48452 ([C++0x][SFINAE] Failures with n-ary initialization expressions (in return type)) PR c++/48452 * typeck.c (build_x_compound_expr_from_list): Return error_mark_node in SFINAE context. From-SVN: r172147 --- gcc/cp/ChangeLog | 4 ++++ gcc/cp/typeck.c | 2 ++ gcc/testsuite/ChangeLog | 2 ++ gcc/testsuite/g++.dg/cpp0x/sfinae10.C | 18 ++++++++++++++++++ 4 files changed, 26 insertions(+) create mode 100644 gcc/testsuite/g++.dg/cpp0x/sfinae10.C diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 976c7fb6f65..04b9c402723 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,5 +1,9 @@ 2011-04-07 Jason Merrill + 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. diff --git a/gcc/cp/typeck.c b/gcc/cp/typeck.c index 8e3796e2757..ecd7d41fc72 100644 --- a/gcc/cp/typeck.c +++ b/gcc/cp/typeck.c @@ -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), diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index dcdd32d9895..38f097208e5 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,5 +1,7 @@ 2011-04-07 Jason Merrill + * 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 index 00000000000..ede8b704245 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/sfinae10.C @@ -0,0 +1,18 @@ +// PR c++/48452 +// { dg-options -std=c++0x } +namespace std { + template T&& declval(); +} + +template +decltype(T(std::declval()...), char()) f(int); + +template +char (&f(...))[2]; + +struct A { virtual ~A() = 0; }; +struct B {}; + +static_assert(sizeof(f(0)) != 1, "Error"); // a +static_assert(sizeof(f(0)) != 1, "Error"); // b +static_assert(sizeof(f(0)) != 1, "Error"); // c -- 2.30.2