[cfe-commits] r91798 - in /cfe/trunk: lib/Sema/SemaDecl.cpp test/SemaTemplate/instantiate-decl-dtor.cpp

Eli Friedman eli.friedman at gmail.com
Sun Dec 20 14:29:12 PST 2009


Author: efriedma
Date: Sun Dec 20 16:29:11 2009
New Revision: 91798

URL: http://llvm.org/viewvc/llvm-project?rev=91798&view=rev
Log:
Make sure we instantiate the destructor for variables initialized by
assignment.


Added:
    cfe/trunk/test/SemaTemplate/instantiate-decl-dtor.cpp
Modified:
    cfe/trunk/lib/Sema/SemaDecl.cpp

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

==============================================================================
--- cfe/trunk/lib/Sema/SemaDecl.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDecl.cpp Sun Dec 20 16:29:11 2009
@@ -3658,6 +3658,15 @@
     assert(Deleted && "Unrecorded tentative definition?"); Deleted=Deleted;
   }
 
+  if (getLangOptions().CPlusPlus) {
+    // Make sure we mark the destructor as used if necessary.
+    QualType InitType = VDecl->getType();
+    if (const ArrayType *Array = Context.getAsArrayType(InitType))
+      InitType = Context.getBaseElementType(Array);
+    if (InitType->isRecordType())
+      FinalizeVarWithDestructor(VDecl, InitType);
+  }
+
   return;
 }
 

Added: cfe/trunk/test/SemaTemplate/instantiate-decl-dtor.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaTemplate/instantiate-decl-dtor.cpp?rev=91798&view=auto

==============================================================================
--- cfe/trunk/test/SemaTemplate/instantiate-decl-dtor.cpp (added)
+++ cfe/trunk/test/SemaTemplate/instantiate-decl-dtor.cpp Sun Dec 20 16:29:11 2009
@@ -0,0 +1,11 @@
+// RUN: %clang_cc1 %s -fsyntax-only -verify
+
+template <typename T> struct A {
+  T x;
+  A(int y) { x = y; }
+  ~A() { *x = 10; } // expected-error {{indirection requires pointer operand}}
+};
+
+void a() {
+  A<int> b = 10; // expected-note {{requested here}}
+}





More information about the cfe-commits mailing list