summaryrefslogtreecommitdiffstats
path: root/clang/test/SemaTemplate/instantiate-expr-4.cpp
diff options
context:
space:
mode:
authorChandler Carruth <chandlerc@gmail.com>2010-03-31 18:34:58 +0000
committerChandler Carruth <chandlerc@gmail.com>2010-03-31 18:34:58 +0000
commitb32b344c8f8194e5b38113c4ed0ab8098c1e4188 (patch)
treed60ee28fd90804b2407168a00211ae5d77251b68 /clang/test/SemaTemplate/instantiate-expr-4.cpp
parentc1fb862fda6091abdce88ad334ebd55021b8b203 (diff)
downloadbcm5719-llvm-b32b344c8f8194e5b38113c4ed0ab8098c1e4188.tar.gz
bcm5719-llvm-b32b344c8f8194e5b38113c4ed0ab8098c1e4188.zip
Re-bind non-dependent CXXTemporaryObjectExpr nodes as temporaries when
instantiating a template, which ensures the destructor is called. This fixes PR6671. llvm-svn: 100029
Diffstat (limited to 'clang/test/SemaTemplate/instantiate-expr-4.cpp')
-rw-r--r--clang/test/SemaTemplate/instantiate-expr-4.cpp13
1 files changed, 13 insertions, 0 deletions
diff --git a/clang/test/SemaTemplate/instantiate-expr-4.cpp b/clang/test/SemaTemplate/instantiate-expr-4.cpp
index 92915c7daf1..8cd7342e98e 100644
--- a/clang/test/SemaTemplate/instantiate-expr-4.cpp
+++ b/clang/test/SemaTemplate/instantiate-expr-4.cpp
@@ -43,6 +43,19 @@ struct Temporaries0 {
template struct Temporaries0<5, 7>;
+// Ensure that both the constructor and the destructor are instantiated by
+// checking for parse errors from each.
+template<int N> struct BadX {
+ BadX() { int a[-N]; } // expected-error {{array size is negative}}
+ ~BadX() { int a[-N]; } // expected-error {{array size is negative}}
+};
+
+template<int N>
+struct PR6671 {
+ void f() { (void)BadX<1>(); } // expected-note 2 {{instantiation}}
+};
+template struct PR6671<1>;
+
// ---------------------------------------------------------------------
// new/delete expressions
// ---------------------------------------------------------------------
OpenPOWER on IntegriCloud