From: Jason Merrill Date: Thu, 14 Apr 2011 15:00:07 +0000 (-0400) Subject: re PR c++/48557 ([C++0x][SFINAE] Hard errors with void as operand of binary built... X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=a66e8081b522edc78354e41ded044a597dc100d9;p=gcc.git re PR c++/48557 ([C++0x][SFINAE] Hard errors with void as operand of binary built-in operators) PR c++/48557 * typeck.c (cp_build_binary_op): Don't decay void operands. From-SVN: r172433 --- diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 0833125b470..1b60dd439dd 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,5 +1,8 @@ 2011-04-14 Jason Merrill + PR c++/48557 + * typeck.c (cp_build_binary_op): Don't decay void operands. + PR c++/48446 * decl.c (compute_array_index_type): Use get_temp_regvar instead of variable_size. diff --git a/gcc/cp/typeck.c b/gcc/cp/typeck.c index ecd7d41fc72..b0e211058f2 100644 --- a/gcc/cp/typeck.c +++ b/gcc/cp/typeck.c @@ -3646,16 +3646,16 @@ cp_build_binary_op (location_t location, || code == TRUTH_OR_EXPR || code == TRUTH_ORIF_EXPR || code == TRUTH_XOR_EXPR) { - if (!really_overloaded_fn (op0)) + if (!really_overloaded_fn (op0) && !VOID_TYPE_P (TREE_TYPE (op0))) op0 = decay_conversion (op0); - if (!really_overloaded_fn (op1)) + if (!really_overloaded_fn (op1) && !VOID_TYPE_P (TREE_TYPE (op1))) op1 = decay_conversion (op1); } else { - if (!really_overloaded_fn (op0)) + if (!really_overloaded_fn (op0) && !VOID_TYPE_P (TREE_TYPE (op0))) op0 = default_conversion (op0); - if (!really_overloaded_fn (op1)) + if (!really_overloaded_fn (op1) && !VOID_TYPE_P (TREE_TYPE (op1))) op1 = default_conversion (op1); } diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 080d29bc40f..8a5f5ae9069 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,5 +1,7 @@ 2011-04-14 Jason Merrill + * g++.dg/cpp0x/sfinae14.C: New. + * g++.dg/ext/vla10.C: New. 2011-04-14 Richard Guenther diff --git a/gcc/testsuite/g++.dg/cpp0x/sfinae14.C b/gcc/testsuite/g++.dg/cpp0x/sfinae14.C new file mode 100644 index 00000000000..305f96eddca --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/sfinae14.C @@ -0,0 +1,27 @@ +// PR c++/48557 +// { dg-options -std=c++0x } + +template +struct add_rval_ref +{ + typedef T&& type; +}; + +template<> +struct add_rval_ref +{ + typedef void type; +}; + +template +typename add_rval_ref::type create(); + +template() + create()) +> +char f(int); + +template +char (&f(...))[2]; + +static_assert(sizeof(f(0)) != 1, "Error"); // (a)