diff options
-rw-r--r-- | clang/include/clang/Sema/Sema.h | 6 | ||||
-rw-r--r-- | clang/lib/Sema/SemaExpr.cpp | 43 | ||||
-rw-r--r-- | clang/lib/Sema/SemaTemplateInstantiate.cpp | 8 | ||||
-rw-r--r-- | clang/test/SemaTemplate/instantiate-expr-6.cpp | 12 | ||||
-rw-r--r-- | clang/test/SemaTemplate/ms-lookup-template-base-classes.cpp | 10 |
5 files changed, 18 insertions, 61 deletions
diff --git a/clang/include/clang/Sema/Sema.h b/clang/include/clang/Sema/Sema.h index 1e949fcceb4..332f8eac449 100644 --- a/clang/include/clang/Sema/Sema.h +++ b/clang/include/clang/Sema/Sema.h @@ -6613,12 +6613,6 @@ public: friend class ArgumentPackSubstitutionRAII; - /// \brief The stack of calls expression undergoing template instantiation. - /// - /// The top of this stack is used by a fixit instantiating unresolved - /// function calls to fix the AST to match the textual change it prints. - SmallVector<CallExpr *, 8> CallsUndergoingInstantiation; - /// \brief For each declaration that involved template argument deduction, the /// set of diagnostics that were suppressed during that template argument /// deduction. diff --git a/clang/lib/Sema/SemaExpr.cpp b/clang/lib/Sema/SemaExpr.cpp index 88ed127f3b9..7bf1938b86a 100644 --- a/clang/lib/Sema/SemaExpr.cpp +++ b/clang/lib/Sema/SemaExpr.cpp @@ -1804,8 +1804,7 @@ Sema::DiagnoseEmptyLookup(Scope *S, CXXScopeSpec &SS, LookupResult &R, // unqualified lookup. This is useful when (for example) the // original lookup would not have found something because it was a // dependent name. - DeclContext *DC = (SS.isEmpty() && !CallsUndergoingInstantiation.empty()) - ? CurContext : nullptr; + DeclContext *DC = SS.isEmpty() ? CurContext : nullptr; while (DC) { if (isa<CXXRecordDecl>(DC)) { LookupQualifiedName(R, DC); @@ -1833,47 +1832,7 @@ Sema::DiagnoseEmptyLookup(Scope *S, CXXScopeSpec &SS, LookupResult &R, if (isInstance) { Diag(R.getNameLoc(), diagnostic) << Name << FixItHint::CreateInsertion(R.getNameLoc(), "this->"); - UnresolvedLookupExpr *ULE = cast<UnresolvedLookupExpr>( - CallsUndergoingInstantiation.back()->getCallee()); - - CXXMethodDecl *DepMethod; - if (CurMethod->isDependentContext()) { - DepMethod = CurMethod; - } else if (FunctionTemplateDecl *FTD = - CurMethod->getPrimaryTemplate()) { - // We have a member function template. It may be contained in a - // class template. If so, get the original pattern for the member - // function template. Otherwise, 'this' isn't dependent and we can - // use CurMethod as is. - if (FunctionTemplateDecl *MemberFTD = - FTD->getInstantiatedFromMemberTemplate()) - DepMethod = cast<CXXMethodDecl>(MemberFTD->getTemplatedDecl()); - else - DepMethod = CurMethod; - } else { - DepMethod = cast<CXXMethodDecl>( - CurMethod->getInstantiatedFromMemberFunction()); - } - assert(DepMethod && "No template pattern found"); - - QualType DepThisType = DepMethod->getThisType(Context); CheckCXXThisCapture(R.getNameLoc()); - CXXThisExpr *DepThis = new (Context) CXXThisExpr( - R.getNameLoc(), DepThisType, false); - TemplateArgumentListInfo TList; - if (ULE->hasExplicitTemplateArgs()) - ULE->copyTemplateArgumentsInto(TList); - - CXXScopeSpec SS; - SS.Adopt(ULE->getQualifierLoc()); - CXXDependentScopeMemberExpr *DepExpr = - CXXDependentScopeMemberExpr::Create( - Context, DepThis, DepThisType, true, SourceLocation(), - SS.getWithLocInContext(Context), - ULE->getTemplateKeywordLoc(), nullptr, - R.getLookupNameInfo(), - ULE->hasExplicitTemplateArgs() ? &TList : nullptr); - CallsUndergoingInstantiation.back()->setCallee(DepExpr); } else { Diag(R.getNameLoc(), diagnostic) << Name; } diff --git a/clang/lib/Sema/SemaTemplateInstantiate.cpp b/clang/lib/Sema/SemaTemplateInstantiate.cpp index 014fe1db7e7..3a3f6323d4b 100644 --- a/clang/lib/Sema/SemaTemplateInstantiate.cpp +++ b/clang/lib/Sema/SemaTemplateInstantiate.cpp @@ -817,14 +817,6 @@ namespace { QualType TransformSubstTemplateTypeParmPackType(TypeLocBuilder &TLB, SubstTemplateTypeParmPackTypeLoc TL); - ExprResult TransformCallExpr(CallExpr *CE) { - getSema().CallsUndergoingInstantiation.push_back(CE); - ExprResult Result = - TreeTransform<TemplateInstantiator>::TransformCallExpr(CE); - getSema().CallsUndergoingInstantiation.pop_back(); - return Result; - } - ExprResult TransformLambdaExpr(LambdaExpr *E) { LocalInstantiationScope Scope(SemaRef, /*CombineWithOuterScope=*/true); return TreeTransform<TemplateInstantiator>::TransformLambdaExpr(E); diff --git a/clang/test/SemaTemplate/instantiate-expr-6.cpp b/clang/test/SemaTemplate/instantiate-expr-6.cpp new file mode 100644 index 00000000000..e6f7fe3f660 --- /dev/null +++ b/clang/test/SemaTemplate/instantiate-expr-6.cpp @@ -0,0 +1,12 @@ +// RUN: %clang_cc1 -std=c++11 -emit-llvm-only %s + +struct X { + template<typename T> static typename T::type g(T t); + template<typename T> auto f(T t) -> decltype(g(t)); + void f(...); +}; + +void test() { + X().f(0); + X().f(0); +} diff --git a/clang/test/SemaTemplate/ms-lookup-template-base-classes.cpp b/clang/test/SemaTemplate/ms-lookup-template-base-classes.cpp index 9fa59e626ee..e1a052cef64 100644 --- a/clang/test/SemaTemplate/ms-lookup-template-base-classes.cpp +++ b/clang/test/SemaTemplate/ms-lookup-template-base-classes.cpp @@ -4,8 +4,8 @@ template <class T> class A { public: - void f(T a) { }// expected-note {{must qualify identifier to find this declaration in dependent base class}} - void g();// expected-note {{must qualify identifier to find this declaration in dependent base class}} + void f(T a) { }// expected-note 2{{must qualify identifier to find this declaration in dependent base class}} + void g();// expected-note 2{{must qualify identifier to find this declaration in dependent base class}} }; template <class T> @@ -13,13 +13,13 @@ class B : public A<T> { public: void z(T a) { - f(a); // expected-warning {{use of identifier 'f' found via unqualified lookup into dependent bases of class templates is a Microsoft extension}} - g(); // expected-warning {{use of identifier 'g' found via unqualified lookup into dependent bases of class templates is a Microsoft extension}} + f(a); // expected-warning 2{{use of identifier 'f' found via unqualified lookup into dependent bases of class templates is a Microsoft extension}} + g(); // expected-warning 2{{use of identifier 'g' found via unqualified lookup into dependent bases of class templates is a Microsoft extension}} } }; template class B<int>; // expected-note {{requested here}} -template class B<char>; +template class B<char>; // expected-note {{requested here}} void test() { |