[PATCH] D6700: Instantiate UnresolvedLookupExpr to MemberExpr when appropriate
Reid Kleckner via cfe-commits
cfe-commits at lists.llvm.org
Tue Oct 13 13:31:51 PDT 2015
rnk updated this revision to Diff 37283.
rnk added a comment.
- Rebase
http://reviews.llvm.org/D6700
Files:
lib/Sema/TreeTransform.h
test/SemaTemplate/instantiate-using-decl.cpp
Index: test/SemaTemplate/instantiate-using-decl.cpp
===================================================================
--- test/SemaTemplate/instantiate-using-decl.cpp
+++ test/SemaTemplate/instantiate-using-decl.cpp
@@ -104,3 +104,26 @@
x.f();
}
}
+
+namespace PR21923 {
+struct A {
+ int member;
+ void method();
+};
+template <typename T>
+struct B : public T {
+ using T::member;
+ using T::method;
+ static void StaticFun() {
+ (void)member; // expected-error {{invalid use of member 'member' in static member function}}
+ (void)B<T>::member; // expected-error {{invalid use of member 'member' in static member function}}
+ method(); // expected-error {{call to non-static member function without an object argument}}
+ }
+ void InstanceFun() {
+ (void)member;
+ (void)B<T>::member;
+ method();
+ }
+};
+template class B<A>; // expected-note 1 {{requested here}}
+}
Index: lib/Sema/TreeTransform.h
===================================================================
--- lib/Sema/TreeTransform.h
+++ lib/Sema/TreeTransform.h
@@ -9128,8 +9128,19 @@
// If we have neither explicit template arguments, nor the template keyword,
// it's a normal declaration name.
- if (!Old->hasExplicitTemplateArgs() && !TemplateKWLoc.isValid())
+ if (!Old->hasExplicitTemplateArgs() && !TemplateKWLoc.isValid()) {
+ // If this resolved to a data member, do member reference semantic analysis
+ // and possibly form a MemberExpr.
+ if (NamedDecl *D = R.getAsSingle<NamedDecl>()) {
+ D = D->getUnderlyingDecl();
+ if (isa<FieldDecl>(D) || isa<IndirectFieldDecl>(D) ||
+ isa<MSPropertyDecl>(D))
+ return getSema().BuildPossibleImplicitMemberExpr(
+ SS, SourceLocation(), R, /*TemplateArgs=*/nullptr,
+ /*Scope=*/nullptr);
+ }
return getDerived().RebuildDeclarationNameExpr(SS, R, Old->requiresADL());
+ }
// If we have template arguments, rebuild them, then rebuild the
// templateid expression.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D6700.37283.patch
Type: text/x-patch
Size: 1999 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20151013/10945a2d/attachment.bin>
More information about the cfe-commits
mailing list