diff options
author | Douglas Gregor <dgregor@apple.com> | 2011-10-10 14:05:31 +0000 |
---|---|---|
committer | Douglas Gregor <dgregor@apple.com> | 2011-10-10 14:05:31 +0000 |
commit | 25aaff9cf8a66bc236e5ccaf6183d11c14674cd3 (patch) | |
tree | e902457050ebb6a37c087b1c2a2a2916d0b17cf3 | |
parent | 2b9e22005cb346f2573eea0f6a780645e41174e8 (diff) |
Always add the built-in overload candidates for operators &&, ||, and
!. Fixes PR9865.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@141537 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | lib/Sema/SemaOverload.cpp | 6 | ||||
-rw-r--r-- | test/CXX/over/over.built/p23.cpp | 25 |
2 files changed, 30 insertions, 1 deletions
diff --git a/lib/Sema/SemaOverload.cpp b/lib/Sema/SemaOverload.cpp index c968498d00..c931160f76 100644 --- a/lib/Sema/SemaOverload.cpp +++ b/lib/Sema/SemaOverload.cpp @@ -6375,7 +6375,11 @@ Sema::AddBuiltinOperatorCandidates(OverloadedOperatorKind Op, // 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. diff --git a/test/CXX/over/over.built/p23.cpp b/test/CXX/over/over.built/p23.cpp new file mode 100644 index 0000000000..c65b10804b --- /dev/null +++ b/test/CXX/over/over.built/p23.cpp @@ -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(); +} |