[cfe-commits] r97152 - in /cfe/trunk: lib/Sema/SemaDeclCXX.cpp test/SemaCXX/destructor.cpp

Douglas Gregor dgregor at apple.com
Thu Feb 25 10:11:54 PST 2010


Author: dgregor
Date: Thu Feb 25 12:11:54 2010
New Revision: 97152

URL: http://llvm.org/viewvc/llvm-project?rev=97152&view=rev
Log:
Don't try to finalize an ill-formed variable or one whose class type is ill-formed. Fixes PR6421

Modified:
    cfe/trunk/lib/Sema/SemaDeclCXX.cpp
    cfe/trunk/test/SemaCXX/destructor.cpp

Modified: cfe/trunk/lib/Sema/SemaDeclCXX.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDeclCXX.cpp?rev=97152&r1=97151&r2=97152&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaDeclCXX.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDeclCXX.cpp Thu Feb 25 12:11:54 2010
@@ -4023,7 +4023,8 @@
 
 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);

Modified: cfe/trunk/test/SemaCXX/destructor.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/destructor.cpp?rev=97152&r1=97151&r2=97152&view=diff
==============================================================================
--- cfe/trunk/test/SemaCXX/destructor.cpp (original)
+++ cfe/trunk/test/SemaCXX/destructor.cpp Thu Feb 25 12:11:54 2010
@@ -61,3 +61,20 @@
 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'}}
+    }
+  };
+}





More information about the cfe-commits mailing list