[cfe-commits] r141537 - in /cfe/trunk: lib/Sema/SemaOverload.cpp test/CXX/over/over.built/p23.cpp

Douglas Gregor dgregor at apple.com
Mon Oct 10 07:05:31 PDT 2011


Author: dgregor
Date: Mon Oct 10 09:05:31 2011
New Revision: 141537

URL: http://llvm.org/viewvc/llvm-project?rev=141537&view=rev
Log:
Always add the built-in overload candidates for operators &&, ||, and
!. Fixes PR9865.

Added:
    cfe/trunk/test/CXX/over/over.built/p23.cpp   (with props)
Modified:
    cfe/trunk/lib/Sema/SemaOverload.cpp

Modified: cfe/trunk/lib/Sema/SemaOverload.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaOverload.cpp?rev=141537&r1=141536&r2=141537&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaOverload.cpp (original)
+++ cfe/trunk/lib/Sema/SemaOverload.cpp Mon Oct 10 09:05:31 2011
@@ -6375,7 +6375,11 @@
 
   // Exit early when no non-record types have been added to the candidate set
   // for any of the arguments to the operator.
-  if (!HasNonRecordCandidateType)
+  //
+  // We can't exit early for !, ||, or &&, since there we have always have
+  // 'bool' overloads.
+  if (!HasNonRecordCandidateType && 
+      !(Op == OO_Exclaim || Op == OO_AmpAmp || Op == OO_PipePipe))
     return;
 
   // Setup an object to manage the common state for building overloads.

Added: cfe/trunk/test/CXX/over/over.built/p23.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CXX/over/over.built/p23.cpp?rev=141537&view=auto
==============================================================================
--- cfe/trunk/test/CXX/over/over.built/p23.cpp (added)
+++ cfe/trunk/test/CXX/over/over.built/p23.cpp Mon Oct 10 09:05:31 2011
@@ -0,0 +1,25 @@
+// RUN: %clang_cc1 -fsyntax-only -std=c++0x -verify %s
+
+struct Variant {
+  template <typename T> operator T();
+};
+
+Variant getValue();
+
+void testVariant() {
+  bool ret1 = getValue() || getValue(); 
+  bool ret2 = getValue() && getValue(); 
+  bool ret3 = !getValue();
+}
+
+struct ExplicitVariant {
+  template <typename T> explicit operator T();
+};
+
+ExplicitVariant getExplicitValue();
+
+void testExplicitVariant() {
+  bool ret1 = getExplicitValue() || getExplicitValue(); 
+  bool ret2 = getExplicitValue() && getExplicitValue(); 
+  bool ret3 = !getExplicitValue();
+}

Propchange: cfe/trunk/test/CXX/over/over.built/p23.cpp
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: cfe/trunk/test/CXX/over/over.built/p23.cpp
------------------------------------------------------------------------------
    svn:keywords = Id

Propchange: cfe/trunk/test/CXX/over/over.built/p23.cpp
------------------------------------------------------------------------------
    svn:mime-type = text/plain





More information about the cfe-commits mailing list