diff options
author | Richard Smith <richard-llvm@metafoo.co.uk> | 2017-02-17 20:05:37 +0000 |
---|---|---|
committer | Richard Smith <richard-llvm@metafoo.co.uk> | 2017-02-17 20:05:37 +0000 |
commit | 0348cfe40e6ee913e81b65e2d353db5f6d66281d (patch) | |
tree | b792f599a95e9e9c99eafb9d341efb9c07a208cb /lib/Sema/SemaInit.cpp | |
parent | 71b73d0a5c75298cd26bb44ef502dbe77fbe1289 (diff) | |
download | clang-0348cfe40e6ee913e81b65e2d353db5f6d66281d.tar.gz |
Add an explicit derived class of FunctionDecl to model deduction guides rather
than just treating them as FunctionDecls with a funny name.
No functionality change intended.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@295491 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Sema/SemaInit.cpp')
-rw-r--r-- | lib/Sema/SemaInit.cpp | 21 |
1 files changed, 11 insertions, 10 deletions
diff --git a/lib/Sema/SemaInit.cpp b/lib/Sema/SemaInit.cpp index 151b974b41..6d20b01e4e 100644 --- a/lib/Sema/SemaInit.cpp +++ b/lib/Sema/SemaInit.cpp @@ -8296,10 +8296,10 @@ QualType Sema::DeduceTemplateSpecializationFromInitializer( if (D->isInvalidDecl()) continue; - FunctionTemplateDecl *TD = dyn_cast<FunctionTemplateDecl>(D); - FunctionDecl *FD = - TD ? TD->getTemplatedDecl() : dyn_cast<FunctionDecl>(D); - if (!FD) + auto *TD = dyn_cast<FunctionTemplateDecl>(D); + auto *GD = dyn_cast_or_null<CXXDeductionGuideDecl>( + TD ? TD->getTemplatedDecl() : dyn_cast<FunctionDecl>(D)); + if (!GD) continue; // C++ [over.match.ctor]p1: (non-list copy-initialization from non-class) @@ -8309,21 +8309,21 @@ QualType Sema::DeduceTemplateSpecializationFromInitializer( // The converting constructors of T are candidate functions. if (Kind.isCopyInit() && !ListInit) { // Only consider converting constructors. - if (FD->isExplicit()) + if (GD->isExplicit()) continue; // When looking for a converting constructor, deduction guides that // could never be called with one argument are not interesting to // check or note. - if (FD->getMinRequiredArguments() > 1 || - (FD->getNumParams() == 0 && !FD->isVariadic())) + if (GD->getMinRequiredArguments() > 1 || + (GD->getNumParams() == 0 && !GD->isVariadic())) continue; } // C++ [over.match.list]p1.1: (first phase list initialization) // Initially, the candidate functions are the initializer-list // constructors of the class T - if (OnlyListConstructors && !isInitListConstructor(FD)) + if (OnlyListConstructors && !isInitListConstructor(GD)) continue; // C++ [over.match.list]p1.2: (second phase list initialization) @@ -8345,7 +8345,7 @@ QualType Sema::DeduceTemplateSpecializationFromInitializer( Inits, Candidates, SuppressUserConversions); else - AddOverloadCandidate(FD, I.getPair(), Inits, Candidates, + AddOverloadCandidate(GD, I.getPair(), Inits, Candidates, SuppressUserConversions); } return Candidates.BestViableFunction(*this, Kind.getLocation(), Best); @@ -8416,7 +8416,8 @@ QualType Sema::DeduceTemplateSpecializationFromInitializer( // C++ [over.match.list]p1: // In copy-list-initialization, if an explicit constructor is chosen, the // initialization is ill-formed. - if (Kind.isCopyInit() && ListInit && Best->Function->isExplicit()) { + if (Kind.isCopyInit() && ListInit && + cast<CXXDeductionGuideDecl>(Best->Function)->isExplicit()) { bool IsDeductionGuide = !Best->Function->isImplicit(); Diag(Kind.getLocation(), diag::err_deduced_class_template_explicit) << TemplateName << IsDeductionGuide; |