From e614d6c6b12f20f0072c20eb312db2e80d1cb051 Mon Sep 17 00:00:00 2001 From: Francois Pichet Date: Tue, 15 Nov 2011 23:33:34 +0000 Subject: [PATCH] In Microsoft mode, make "Unqualified lookup into dependent bases of class templates" works inside static functions. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@144729 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Sema/SemaExpr.cpp | 4 +++- .../ms-lookup-template-base-classes.cpp | 23 +++++++++++++++++++ 2 files changed, 26 insertions(+), 1 deletion(-) diff --git a/lib/Sema/SemaExpr.cpp b/lib/Sema/SemaExpr.cpp index cfa5feabb3..362aea9a74 100644 --- a/lib/Sema/SemaExpr.cpp +++ b/lib/Sema/SemaExpr.cpp @@ -1534,7 +1534,7 @@ bool Sema::DiagnoseEmptyLookup(Scope *S, CXXScopeSpec &SS, LookupResult &R, CXXMethodDecl *DepMethod = cast_or_null( CurMethod->getInstantiatedFromMemberFunction()); if (DepMethod) { - if (getLangOptions().MicrosoftExt) + if (getLangOptions().MicrosoftMode) diagnostic = diag::warn_found_via_dependent_bases_lookup; Diag(R.getNameLoc(), diagnostic) << Name << FixItHint::CreateInsertion(R.getNameLoc(), "this->"); @@ -1560,6 +1560,8 @@ bool Sema::DiagnoseEmptyLookup(Scope *S, CXXScopeSpec &SS, LookupResult &R, Diag(R.getNameLoc(), diagnostic) << Name; } } else { + if (getLangOptions().MicrosoftMode) + diagnostic = diag::warn_found_via_dependent_bases_lookup; Diag(R.getNameLoc(), diagnostic) << Name; } diff --git a/test/SemaTemplate/ms-lookup-template-base-classes.cpp b/test/SemaTemplate/ms-lookup-template-base-classes.cpp index 0e3757297f..149ec4f8e9 100644 --- a/test/SemaTemplate/ms-lookup-template-base-classes.cpp +++ b/test/SemaTemplate/ms-lookup-template-base-classes.cpp @@ -48,3 +48,26 @@ template class B; } + + +namespace lookup_dependent_base_class_static_function { + +template +class A { +public: + static void static_func();// expected-note {{must qualify identifier to find this declaration in dependent base class}} + void func();// expected-note {{must qualify identifier to find this declaration in dependent base class}} +}; + + +template +class B : public A { +public: + static void z2(){ + static_func(); // expected-warning {{use of identifier 'static_func' found via unqualified lookup into dependent bases of class templates is a Microsoft extension}} + func(); // expected-warning {{use of identifier 'func' found via unqualified lookup into dependent bases of class templates is a Microsoft extension}} expected-error {{call to non-static member function without an object argument}} + } +}; +template class B; // expected-note {{requested here}} + +} -- 2.40.0