summaryrefslogtreecommitdiffstats
path: root/clang/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
commitd94105a1c2e133ede54baeea911975abed93f457 (patch)
treec1f7cf2f91fcad5ff5ba3c44de0f43c2b78e1f77 /clang/test/SemaTemplate/example-dynarray.cpp
parent35337557af5ebe1905a3013b1843e48ce00c48d3 (diff)
downloadbcm5719-llvm-d94105a1c2e133ede54baeea911975abed93f457.tar.gz
bcm5719-llvm-d94105a1c2e133ede54baeea911975abed93f457.zip
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! llvm-svn: 81025
Diffstat (limited to 'clang/test/SemaTemplate/example-dynarray.cpp')
-rw-r--r--clang/test/SemaTemplate/example-dynarray.cpp14
1 files changed, 10 insertions, 4 deletions
diff --git a/clang/test/SemaTemplate/example-dynarray.cpp b/clang/test/SemaTemplate/example-dynarray.cpp
index 7dcc508d2c8..0b8d605b623 100644
--- a/clang/test/SemaTemplate/example-dynarray.cpp
+++ b/clang/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;
OpenPOWER on IntegriCloud