public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* C++ PATCH for c++/48557 (SFINAE failure with void operands)
@ 2011-04-14 14:57 Jason Merrill
  2011-04-14 14:58 ` Jason Merrill
  0 siblings, 1 reply; 2+ messages in thread
From: Jason Merrill @ 2011-04-14 14:57 UTC (permalink / raw)
  To: gcc-patches List

[-- Attachment #1: Type: text/plain, Size: 107 bytes --]

We were just failing to check complain for this one error.

Tested x86_64-pc-linux-gnu, applying to trunk.

[-- Attachment #2: 48557.patch --]
[-- Type: text/plain, Size: 1783 bytes --]

commit e807a327e3e667c8d79356cf644e493fbb82033f
Author: Jason Merrill <jason@redhat.com>
Date:   Wed Apr 13 18:14:45 2011 -0400

    	PR c++/48557
    	* typeck.c (cp_build_binary_op): Don't decay void operands.

diff --git a/gcc/cp/typeck.c b/gcc/cp/typeck.c
index ecd7d41..b0e2110 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/g++.dg/cpp0x/sfinae14.C b/gcc/testsuite/g++.dg/cpp0x/sfinae14.C
new file mode 100644
index 0000000..305f96e
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cpp0x/sfinae14.C
@@ -0,0 +1,27 @@
+// PR c++/48557
+// { dg-options -std=c++0x }
+
+template<class T>
+struct add_rval_ref
+{
+  typedef T&& type;
+};
+
+template<>
+struct add_rval_ref<void>
+{
+  typedef void type;
+};
+
+template<class T>
+typename add_rval_ref<T>::type create();
+
+template<class T, class U,
+  class = decltype(create<T>() + create<U>())
+>
+char f(int);
+
+template<class, class>
+char (&f(...))[2];
+
+static_assert(sizeof(f<void, int>(0)) != 1, "Error");  // (a)

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: C++ PATCH for c++/48557 (SFINAE failure with void operands)
  2011-04-14 14:57 C++ PATCH for c++/48557 (SFINAE failure with void operands) Jason Merrill
@ 2011-04-14 14:58 ` Jason Merrill
  0 siblings, 0 replies; 2+ messages in thread
From: Jason Merrill @ 2011-04-14 14:58 UTC (permalink / raw)
  To: gcc-patches List

On 04/14/2011 10:57 AM, Jason Merrill wrote:
> We were just failing to check complain for this one error.

Er, actually that's the next patch.  For this one, we were complaining 
in decay_conversion about misuse of void.  I noticed that some other 
places avoid calling that on void operands, so that's what I did here as 
well.

Jason

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2011-04-14 14:58 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-04-14 14:57 C++ PATCH for c++/48557 (SFINAE failure with void operands) Jason Merrill
2011-04-14 14:58 ` Jason Merrill

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).