aboutsummaryrefslogtreecommitdiff
path: root/test/SemaTemplate/example-dynarray.cpp
diff options
context:
space:
mode:
authorDouglas Gregor <dgregor@apple.com>2009-09-04 19:04:08 +0000
committerDouglas Gregor <dgregor@apple.com>2009-09-04 19:04:08 +0000
commit4fe95f99a2693f1145785ea5835ba6937e49c730 (patch)
tree0ee110356234d08d51bd2a76ded824e7043da003 /test/SemaTemplate/example-dynarray.cpp
parentf79079565e15e6a328372076ac5583af16c8dbce (diff)
Don't generate any code for an explicit call to a trivial destructor.
Now that parsing, semantic analysis, and (I think) code generation of pseudo-destructor expressions and explicit destructor calls works, update the example-dynarray.cpp test to destroy the objects it allocates and update the test to actually compile + link. The code seems correct, but the Clang-compiled version dies with a malloc error. Time to debug! git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@81025 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test/SemaTemplate/example-dynarray.cpp')
-rw-r--r--test/SemaTemplate/example-dynarray.cpp14
1 files changed, 10 insertions, 4 deletions
diff --git a/test/SemaTemplate/example-dynarray.cpp b/test/SemaTemplate/example-dynarray.cpp
index 7dcc508d2c..0b8d605b62 100644
--- a/test/SemaTemplate/example-dynarray.cpp
+++ b/test/SemaTemplate/example-dynarray.cpp
@@ -1,4 +1,4 @@
-// RUN: clang-cc -fsyntax-only -verify %s
+// RUN: clang %s -o %t
#include <stddef.h>
#include <stdlib.h>
#include <assert.h>
@@ -24,6 +24,9 @@ public:
}
~dynarray() {
+ for (unsigned I = 0, N = size(); I != N; ++I)
+ Start[I].~T();
+
free(Start);
}
@@ -33,7 +36,9 @@ public:
for (unsigned I = 0, N = other.size(); I != N; ++I)
new (NewStart + I) T(other[I]);
- // FIXME: destroy everything in Start
+ for (unsigned I = 0, N = size(); I != N; ++I)
+ Start[I].~T();
+
free(Start);
Start = NewStart;
Last = End = NewStart + other.size();
@@ -46,8 +51,8 @@ public:
void push_back(const T& value);
void pop_back() {
- // FIXME: destruct old value
--Last;
+ Last->~T();
}
T& operator[](unsigned Idx) {
@@ -99,7 +104,8 @@ void dynarray<T>::push_back(const T& value) {
for (unsigned I = 0; I != Size; ++I)
new (NewStart + I) T(Start[I]);
- // FIXME: destruct old values
+ for (unsigned I = 0, N = size(); I != N; ++I)
+ Start[I].~T();
free(Start);
Start = NewStart;