[cfe-commits] r72282 - in /cfe/trunk: lib/Sema/SemaTemplateInstantiateExpr.cpp test/SemaTemplate/instantiate-expr-4.cpp

Douglas Gregor dgregor at apple.com
Fri May 22 14:26:58 PDT 2009


Author: dgregor
Date: Fri May 22 16:26:58 2009
New Revision: 72282

URL: http://llvm.org/viewvc/llvm-project?rev=72282&view=rev
Log:
Add a few tests to ensure that member functions of class templates can
call other member functions of class templates, including after
template instantiation. No functionality change.


Modified:
    cfe/trunk/lib/Sema/SemaTemplateInstantiateExpr.cpp
    cfe/trunk/test/SemaTemplate/instantiate-expr-4.cpp

Modified: cfe/trunk/lib/Sema/SemaTemplateInstantiateExpr.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaTemplateInstantiateExpr.cpp?rev=72282&r1=72281&r2=72282&view=diff

==============================================================================
--- cfe/trunk/lib/Sema/SemaTemplateInstantiateExpr.cpp (original)
+++ cfe/trunk/lib/Sema/SemaTemplateInstantiateExpr.cpp Fri May 22 16:26:58 2009
@@ -74,7 +74,7 @@
     OwningExprResult VisitImplicitCastExpr(ImplicitCastExpr *E);
     OwningExprResult VisitExplicitCastExpr(ExplicitCastExpr *E);
     OwningExprResult VisitCStyleCastExpr(CStyleCastExpr *E);
-    // FIXME: CXXMemberCallExpr
+    OwningExprResult VisitCXXMemberCallExpr(CXXMemberCallExpr *E);
     OwningExprResult VisitCXXNamedCastExpr(CXXNamedCastExpr *E);
     OwningExprResult VisitCXXStaticCastExpr(CXXStaticCastExpr *E);
     OwningExprResult VisitCXXDynamicCastExpr(CXXDynamicCastExpr *E);
@@ -852,6 +852,11 @@
 }
 
 Sema::OwningExprResult 
+TemplateExprInstantiator::VisitCXXMemberCallExpr(CXXMemberCallExpr *E) {
+  return VisitCallExpr(E);
+}
+
+Sema::OwningExprResult 
 TemplateExprInstantiator::VisitCXXNamedCastExpr(CXXNamedCastExpr *E) {
   // Figure out which cast operator we're dealing with.
   tok::TokenKind Kind;

Modified: cfe/trunk/test/SemaTemplate/instantiate-expr-4.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaTemplate/instantiate-expr-4.cpp?rev=72282&r1=72281&r2=72282&view=diff

==============================================================================
--- cfe/trunk/test/SemaTemplate/instantiate-expr-4.cpp (original)
+++ cfe/trunk/test/SemaTemplate/instantiate-expr-4.cpp Fri May 22 16:26:58 2009
@@ -238,3 +238,41 @@
 };
 
 template struct NonDepMemberExpr0<0>; 
+
+template<typename T, typename Result>
+struct MemberFuncCall0 {
+  void f(T t) {
+    Result result = t.f();
+  }
+};
+
+template<typename T>
+struct HasMemFunc0 {
+  T f();
+};
+
+
+template struct MemberFuncCall0<HasMemFunc0<int&>, const int&>;
+
+template<typename Result>
+struct ThisMemberFuncCall0 {
+  Result g();
+
+  void f() {
+    Result r1 = g();
+    Result r2 = this->g();
+  }
+};
+
+template struct ThisMemberFuncCall0<int&>;
+
+template<typename T>
+struct NonDepMemberCall0 {
+  void foo(HasMemFunc0<int&> x) {
+    T result = x.f(); // expected-error{{initialized}}
+  }
+};
+
+template struct NonDepMemberCall0<int&>;
+template struct NonDepMemberCall0<const int&>;
+template struct NonDepMemberCall0<float&>; // expected-note{{instantiation}}





More information about the cfe-commits mailing list