]> granicus.if.org Git - clang/commitdiff
Make sure to free the explicit template arguments provided for an
authorDouglas Gregor <dgregor@apple.com>
Thu, 1 Oct 2009 23:51:25 +0000 (23:51 +0000)
committerDouglas Gregor <dgregor@apple.com>
Thu, 1 Oct 2009 23:51:25 +0000 (23:51 +0000)
explicit instantiation. Also, tighten up reference-count checking to
help catch these issues earlier. Fixes PR5069.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@83225 91177308-0d34-0410-b5e6-96231b3b80d8

include/clang/AST/Stmt.h
lib/Sema/SemaTemplate.cpp
test/SemaTemplate/explicit-instantiation.cpp

index 125279c1eda17d993cbeeae4488988382adb3f8c..411f215e912e19d8c868a4409c6778305e7834b3 100644 (file)
@@ -188,7 +188,10 @@ public:
     return this;
   }
 
-  StmtClass getStmtClass() const { return (StmtClass)sClass; }
+  StmtClass getStmtClass() const { 
+    assert(RefCount >= 1 && "Referencing already-destroyed statement!");
+    return (StmtClass)sClass; 
+  }
   const char *getStmtClassName() const;
 
   /// SourceLocation tokens are not useful in isolation - they are low level
index c7ce03259408fa2f66ed6c3f9938f80fc2c64cac..d12ec9318af903fb53b5af168d2272d38e37c773 100644 (file)
@@ -3414,6 +3414,7 @@ Sema::DeclResult Sema::ActOnExplicitInstantiation(Scope *S,
                                TemplateId->getTemplateArgLocations(),
                                TemplateArgs);
     HasExplicitTemplateArgs = true;
+    TemplateArgsPtr.release();
   }
     
   // C++ [temp.explicit]p1:
index 07994f97d3f618a047ab74336dfc8d8aedfbca4a..b9a4ad282b9f4118eb366378d79a31aa868c6de9 100644 (file)
@@ -69,3 +69,7 @@ template void print_type<int>(float*); // expected-error{{does not refer}}
 
 void print_type(double*);
 template void print_type<double>(double*);
+
+// PR5069
+template<int I> void foo0 (int (&)[I + 1]) { }
+template void foo0<2> (int (&)[3]);