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.


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.
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to