diff options
author | Erich Keane <erich.keane@intel.com> | 2017-06-20 17:38:07 +0000 |
---|---|---|
committer | Erich Keane <erich.keane@intel.com> | 2017-06-20 17:38:07 +0000 |
commit | c9cb1c13bab07bd56ecf3ae9be92a393b53c859b (patch) | |
tree | 0dc41fbe386b29f72b70d50beff53f0b68f0210a /clang/lib/Sema/SemaLookup.cpp | |
parent | f5bb738f75000c8f40c35b59dddebd527a514de1 (diff) | |
download | bcm5719-llvm-c9cb1c13bab07bd56ecf3ae9be92a393b53c859b.tar.gz bcm5719-llvm-c9cb1c13bab07bd56ecf3ae9be92a393b53c859b.zip |
Fix for Bug 33471: Preventing operator auto from resolving to a template operator.
As the bug report says,
struct A
{
template<typename T> operator T();
};
void foo()
{
A().operator auto();
}
causes: "undeduced type in IR-generation
UNREACHABLE executed at llvm/tools/clang/lib/CodeGen/CodeGenFunction.cpp:208!"
The problem is that in this case, "T" is being deduced as "auto",
which I believe is incorrect.
The 'operator auto' implementation in Clang is standards compliant, however
there is a defect report against core (1670).
Differential Revision: https://reviews.llvm.org/D34370
llvm-svn: 305812
Diffstat (limited to 'clang/lib/Sema/SemaLookup.cpp')
-rw-r--r-- | clang/lib/Sema/SemaLookup.cpp | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/clang/lib/Sema/SemaLookup.cpp b/clang/lib/Sema/SemaLookup.cpp index 1fb25f4e0e7..9f657a446c0 100644 --- a/clang/lib/Sema/SemaLookup.cpp +++ b/clang/lib/Sema/SemaLookup.cpp @@ -862,6 +862,16 @@ static bool LookupDirect(Sema &S, LookupResult &R, const DeclContext *DC) { if (!Record->isCompleteDefinition()) return Found; + // For conversion operators, 'operator auto' should only match + // 'operator auto'. Since 'auto' is not a type, it shouldn't be considered + // as a candidate for template substitution. + auto *ContainedDeducedType = + R.getLookupName().getCXXNameType()->getContainedDeducedType(); + if (R.getLookupName().getNameKind() == + DeclarationName::CXXConversionFunctionName && + ContainedDeducedType && ContainedDeducedType->isUndeducedType()) + return Found; + for (CXXRecordDecl::conversion_iterator U = Record->conversion_begin(), UEnd = Record->conversion_end(); U != UEnd; ++U) { FunctionTemplateDecl *ConvTemplate = dyn_cast<FunctionTemplateDecl>(*U); |