summaryrefslogtreecommitdiffstats
path: root/clang
diff options
context:
space:
mode:
authorDouglas Gregor <dgregor@apple.com>2009-10-01 23:51:25 +0000
committerDouglas Gregor <dgregor@apple.com>2009-10-01 23:51:25 +0000
commitf343fd8929ca94eb36b0765f33b1cda60e717b5b (patch)
tree22240b23e913e1860cc936e052a1651117ab01ac /clang
parentbb69c947983ee49560b4f1165381eb0eff092f96 (diff)
downloadbcm5719-llvm-f343fd8929ca94eb36b0765f33b1cda60e717b5b.tar.gz
bcm5719-llvm-f343fd8929ca94eb36b0765f33b1cda60e717b5b.zip
Make sure to free the explicit template arguments provided for an
explicit instantiation. Also, tighten up reference-count checking to help catch these issues earlier. Fixes PR5069. llvm-svn: 83225
Diffstat (limited to 'clang')
-rw-r--r--clang/include/clang/AST/Stmt.h5
-rw-r--r--clang/lib/Sema/SemaTemplate.cpp1
-rw-r--r--clang/test/SemaTemplate/explicit-instantiation.cpp4
3 files changed, 9 insertions, 1 deletions
diff --git a/clang/include/clang/AST/Stmt.h b/clang/include/clang/AST/Stmt.h
index 125279c1eda..411f215e912 100644
--- a/clang/include/clang/AST/Stmt.h
+++ b/clang/include/clang/AST/Stmt.h
@@ -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
diff --git a/clang/lib/Sema/SemaTemplate.cpp b/clang/lib/Sema/SemaTemplate.cpp
index c7ce0325940..d12ec9318af 100644
--- a/clang/lib/Sema/SemaTemplate.cpp
+++ b/clang/lib/Sema/SemaTemplate.cpp
@@ -3414,6 +3414,7 @@ Sema::DeclResult Sema::ActOnExplicitInstantiation(Scope *S,
TemplateId->getTemplateArgLocations(),
TemplateArgs);
HasExplicitTemplateArgs = true;
+ TemplateArgsPtr.release();
}
// C++ [temp.explicit]p1:
diff --git a/clang/test/SemaTemplate/explicit-instantiation.cpp b/clang/test/SemaTemplate/explicit-instantiation.cpp
index 07994f97d3f..b9a4ad282b9 100644
--- a/clang/test/SemaTemplate/explicit-instantiation.cpp
+++ b/clang/test/SemaTemplate/explicit-instantiation.cpp
@@ -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]);
OpenPOWER on IntegriCloud