Basic support for member exprs where the base expr type is dependent.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@71907 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Sema/SemaExpr.cpp b/lib/Sema/SemaExpr.cpp
index 0d72a75..41c868e 100644
--- a/lib/Sema/SemaExpr.cpp
+++ b/lib/Sema/SemaExpr.cpp
@@ -2024,7 +2024,10 @@
   // Get the type being accessed in BaseType.  If this is an arrow, the BaseExpr
   // must have pointer type, and the accessed type is the pointee.
   if (OpKind == tok::arrow) {
-    if (const PointerType *PT = BaseType->getAsPointerType())
+    if (BaseType->isDependentType())
+      return Owned(new (Context) MemberExpr(BaseExpr, true, 0,
+                                            MemberLoc, Context.DependentTy));
+    else if (const PointerType *PT = BaseType->getAsPointerType())
       BaseType = PT->getPointeeType();
     else if (getLangOptions().CPlusPlus && BaseType->isRecordType())
       return Owned(BuildOverloadedArrowExpr(S, BaseExpr, OpLoc,
@@ -2033,6 +2036,17 @@
       return ExprError(Diag(MemberLoc,
                             diag::err_typecheck_member_reference_arrow)
         << BaseType << BaseExpr->getSourceRange());
+  } else {
+    // We use isTemplateTypeParmType directly here, instead of simply checking
+    // whether BaseType is dependent, because we want to report an error for
+    //
+    // T *t;
+    // t.foo;
+    //
+    //
+    if (BaseType->isTemplateTypeParmType()) 
+      return Owned(new (Context) MemberExpr(BaseExpr, false, 0,
+                                            MemberLoc, Context.DependentTy));
   }
 
   // Handle field access to simple records.  This also handles access to fields