Implement AST, semantics, and CodeGen for C++ pseudo-destructor
expressions, e.g.,

  p->~T()

when p is a pointer to a scalar type. 

We don't currently diagnose errors when pseudo-destructor expressions
are used in any way other than by forming a call.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@81009 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Sema/SemaExprCXX.cpp b/lib/Sema/SemaExprCXX.cpp
index c62159d..4d49f87 100644
--- a/lib/Sema/SemaExprCXX.cpp
+++ b/lib/Sema/SemaExprCXX.cpp
@@ -1821,26 +1821,19 @@
   if (SS && SS->isInvalid())
     return ExprError();
 
-  Expr *BaseExpr = (Expr *)Base.get();
+  QualType BaseType;
+  if (SS && isUnknownSpecialization(*SS))
+    BaseType = Context.getTypenameType((NestedNameSpecifier *)SS->getScopeRep(),
+                                       ClassName);
+  else {
+    TypeTy *BaseTy = getTypeName(*ClassName, ClassNameLoc, S, SS);
+    if (!BaseTy) {
+      Diag(ClassNameLoc, diag::err_ident_in_pseudo_dtor_not_a_type) 
+        << ClassName;
+      return ExprError();
+    }
   
-  if (BaseExpr->isTypeDependent() || 
-      (SS && isDependentScopeSpecifier(*SS))) {
-    // FIXME: Return an unresolved ref expr.
-    return ExprError();
-  }
-
-  TypeTy *BaseTy = getTypeName(*ClassName, ClassNameLoc, S, SS);
-  if (!BaseTy) {
-    Diag(ClassNameLoc, diag::err_ident_in_pseudo_dtor_not_a_type) 
-      << ClassName;
-    return ExprError();
-  }
-  
-  QualType BaseType = GetTypeFromParser(BaseTy);
-  if (!BaseType->isRecordType()) {
-    Diag(ClassNameLoc, diag::err_type_in_pseudo_dtor_not_a_class_type)
-      << BaseType;
-    return ExprError();
+    BaseType = GetTypeFromParser(BaseTy);
   }
   
   CanQualType CanBaseType = Context.getCanonicalType(BaseType);