]> granicus.if.org Git - clang/commitdiff
Don't try to finalize an ill-formed variable or one whose class type is ill-formed...
authorDouglas Gregor <dgregor@apple.com>
Thu, 25 Feb 2010 18:11:54 +0000 (18:11 +0000)
committerDouglas Gregor <dgregor@apple.com>
Thu, 25 Feb 2010 18:11:54 +0000 (18:11 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@97152 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Sema/SemaDeclCXX.cpp
test/SemaCXX/destructor.cpp

index 3710c4fc6db4c4f2d25b6aa3d5cd64b279bb5fc7..e12a104d77bcf6729ab822296df2e68996ecda84 100644 (file)
@@ -4023,7 +4023,8 @@ bool Sema::InitializeVarWithConstructor(VarDecl *VD,
 
 void Sema::FinalizeVarWithDestructor(VarDecl *VD, const RecordType *Record) {
   CXXRecordDecl *ClassDecl = cast<CXXRecordDecl>(Record->getDecl());
-  if (!ClassDecl->hasTrivialDestructor()) {
+  if (!ClassDecl->isInvalidDecl() && !VD->isInvalidDecl() &&
+      !ClassDecl->hasTrivialDestructor()) {
     CXXDestructorDecl *Destructor = ClassDecl->getDestructor(Context);
     MarkDeclarationReferenced(VD->getLocation(), Destructor);
     CheckDestructorAccess(VD->getLocation(), Record);
index a0c2c1e037ed428fadc4f368ec0c1420da3e89ee..ab3c809e00a82dcd3f0b903db480738fd46c65f8 100644 (file)
@@ -61,3 +61,20 @@ struct X {};
 struct Y {
   ~X(); // expected-error {{expected the class name after '~' to name the enclosing class}}
 };
+
+namespace PR6421 {
+  class T; // expected-note{{forward declaration}}
+
+  class QGenericArgument
+  {
+    template<typename U>
+    void foo(T t) // expected-error{{variable has incomplete type}}
+    { }
+    
+    void disconnect()
+    {
+      T* t;
+      bob<QGenericArgument>(t); // expected-error{{undeclared identifier 'bob'}}
+    }
+  };
+}