public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Jason Merrill <jason@redhat.com>
To: gcc-patches List <gcc-patches@gcc.gnu.org>
Subject: C++ PATCH for c++/48557 (SFINAE failure with void operands)
Date: Thu, 14 Apr 2011 14:57:00 -0000	[thread overview]
Message-ID: <4DA70B4F.2000705@redhat.com> (raw)

[-- 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)

             reply	other threads:[~2011-04-14 14:57 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-04-14 14:57 Jason Merrill [this message]
2011-04-14 14:58 ` Jason Merrill

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4DA70B4F.2000705@redhat.com \
    --to=jason@redhat.com \
    --cc=gcc-patches@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).