[cfe-commits] r158842 - in /cfe/trunk: lib/Sema/SemaExpr.cpp test/SemaTemplate/ms-lookup-template-base-classes.cpp
Nico Weber
nicolasweber at gmx.de
Wed Jun 20 13:21:42 PDT 2012
Author: nico
Date: Wed Jun 20 15:21:42 2012
New Revision: 158842
URL: http://llvm.org/viewvc/llvm-project?rev=158842&view=rev
Log:
Allow unqualified lookup of non-dependent member functions
in microsoft mode. Fixes PR12701.
The code for this was already in 2 of the 3 branches of a
conditional and missing in the 3rd branch, so lift it above
the conditional.
Modified:
cfe/trunk/lib/Sema/SemaExpr.cpp
cfe/trunk/test/SemaTemplate/ms-lookup-template-base-classes.cpp
Modified: cfe/trunk/lib/Sema/SemaExpr.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExpr.cpp?rev=158842&r1=158841&r2=158842&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaExpr.cpp (original)
+++ cfe/trunk/lib/Sema/SemaExpr.cpp Wed Jun 20 15:21:42 2012
@@ -1466,14 +1466,14 @@
// Give a code modification hint to insert 'this->'.
// TODO: fixit for inserting 'Base<T>::' in the other cases.
// Actually quite difficult!
+ if (getLangOpts().MicrosoftMode)
+ diagnostic = diag::warn_found_via_dependent_bases_lookup;
if (isInstance) {
UnresolvedLookupExpr *ULE = cast<UnresolvedLookupExpr>(
CallsUndergoingInstantiation.back()->getCallee());
CXXMethodDecl *DepMethod = cast_or_null<CXXMethodDecl>(
CurMethod->getInstantiatedFromMemberFunction());
if (DepMethod) {
- if (getLangOpts().MicrosoftMode)
- diagnostic = diag::warn_found_via_dependent_bases_lookup;
Diag(R.getNameLoc(), diagnostic) << Name
<< FixItHint::CreateInsertion(R.getNameLoc(), "this->");
QualType DepThisType = DepMethod->getThisType(Context);
@@ -1500,8 +1500,6 @@
Diag(R.getNameLoc(), diagnostic) << Name;
}
} else {
- if (getLangOpts().MicrosoftMode)
- diagnostic = diag::warn_found_via_dependent_bases_lookup;
Diag(R.getNameLoc(), diagnostic) << Name;
}
Modified: cfe/trunk/test/SemaTemplate/ms-lookup-template-base-classes.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaTemplate/ms-lookup-template-base-classes.cpp?rev=158842&r1=158841&r2=158842&view=diff
==============================================================================
--- cfe/trunk/test/SemaTemplate/ms-lookup-template-base-classes.cpp (original)
+++ cfe/trunk/test/SemaTemplate/ms-lookup-template-base-classes.cpp Wed Jun 20 15:21:42 2012
@@ -143,3 +143,32 @@
template class A<C>;
}
+
+namespace PR12701 {
+
+class A {};
+class B {};
+
+template <class T>
+class Base {
+ public:
+ bool base_fun(void* p) { return false; } // expected-note {{must qualify identifier to find this declaration in dependent base clas}}
+ operator T*() const { return 0; }
+};
+
+template <class T>
+class Container : public Base<T> {
+ public:
+ template <typename S>
+ bool operator=(const Container<S>& rhs) {
+ return base_fun(rhs); // expected-warning {{use of identifier 'base_fun' found via unqualified lookup into dependent bases of class templates is a Microsoft extension}}
+ }
+};
+
+void f() {
+ Container<A> text_provider;
+ Container<B> text_provider2;
+ text_provider2 = text_provider; // expected-note {{in instantiation of function template specialization}}
+}
+
+} // namespace PR12701
More information about the cfe-commits
mailing list