forked from OSchip/llvm-project
Always add the built-in overload candidates for operators &&, ||, and
!. Fixes PR9865. llvm-svn: 141537
This commit is contained in:
parent
3053586149
commit
877d4ebba4
|
@ -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.
|
||||
|
|
|
@ -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();
|
||||
}
|
Loading…
Reference in New Issue