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 | 877d4ebba49cc6b68cf8606d8192e2c23a2df4d7 (patch) | |
| tree | 54d71bb438af50b9c7a49766494b50291bf99e96 | |
| parent | 3053586149fe18a89980587b35105bffe48ef5de (diff) | |
| download | bcm5719-llvm-877d4ebba49cc6b68cf8606d8192e2c23a2df4d7.tar.gz bcm5719-llvm-877d4ebba49cc6b68cf8606d8192e2c23a2df4d7.zip | |
Always add the built-in overload candidates for operators &&, ||, and
!. Fixes PR9865.
llvm-svn: 141537
| -rw-r--r-- | clang/lib/Sema/SemaOverload.cpp | 6 | ||||
| -rw-r--r-- | clang/test/CXX/over/over.built/p23.cpp | 25 |
2 files changed, 30 insertions, 1 deletions
diff --git a/clang/lib/Sema/SemaOverload.cpp b/clang/lib/Sema/SemaOverload.cpp index c968498d00b..c931160f76c 100644 --- a/clang/lib/Sema/SemaOverload.cpp +++ b/clang/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/clang/test/CXX/over/over.built/p23.cpp b/clang/test/CXX/over/over.built/p23.cpp new file mode 100644 index 00000000000..c65b10804b2 --- /dev/null +++ b/clang/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(); +} |

