aboutsummaryrefslogtreecommitdiff
path: root/test/CXX/expr/expr.unary/expr.delete/p5.cpp
diff options
context:
space:
mode:
authorDaniel Dunbar <daniel@zuster.org>2009-11-13 19:13:56 +0000
committerDaniel Dunbar <daniel@zuster.org>2009-11-13 19:13:56 +0000
commitbb62dcb37c9c8dce64707715051e7523ed14c8e9 (patch)
tree11c9c958f490940fbee4c9a190082c816b87534d /test/CXX/expr/expr.unary/expr.delete/p5.cpp
parent8fae060d6ef78d4cdd19ebff7dea9c3a566f8b23 (diff)
Add test for expr.delete p5, with a FIXME.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@88678 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test/CXX/expr/expr.unary/expr.delete/p5.cpp')
-rw-r--r--test/CXX/expr/expr.unary/expr.delete/p5.cpp34
1 files changed, 34 insertions, 0 deletions
diff --git a/test/CXX/expr/expr.unary/expr.delete/p5.cpp b/test/CXX/expr/expr.unary/expr.delete/p5.cpp
new file mode 100644
index 0000000000..91e77bcb8b
--- /dev/null
+++ b/test/CXX/expr/expr.unary/expr.delete/p5.cpp
@@ -0,0 +1,34 @@
+// RUN: clang-cc -verify %s
+
+// If the object being deleted has incomplete class type at the point of
+// deletion and the complete class has a non-trivial destructor or a
+// deallocation function, the behavior is undefined.
+
+// The trivial case.
+class T0; // expected-note {{forward declaration}}
+void f0(T0 *a) { delete a; } // expected-warning {{deleting pointer to incomplete type}}
+class T0 { ~T0(); };
+
+// The trivial case, inside a template instantiation.
+template<typename T>
+class T1_A { T *x; ~T1_A() { delete x; } }; // expected-warning {{deleting pointer to incomplete type}}
+class T1_B; // expected-note {{forward declaration}}
+void f0() { T1_A<T1_B> x; } // expected-note {{in instantiation of member function}}
+
+// This case depends on when we check T2_C::f0.
+class T2_A;
+template<typename T>
+struct T2_B { void f0(T *a) { delete a; } };
+struct T2_C { T2_B<T2_A> x; void f0(T2_A *a) { x.f0(a); } };
+void f0(T2_A *a) { T2_C x; x.f0(a); }
+class T2_A { };
+
+// An alternate version of the same.
+//
+// FIXME: Revisit this case when we have access control.
+class T3_A;
+template<typename T>
+struct T3_B { void f0(T *a) { delete a; } };
+struct T3_C { T3_B<T3_A> x; void f0(T3_A *a) { x.f0(a); } };
+void f0(T3_A *a) { T3_C x; x.f0(a); }
+class T3_A { private: ~T3_A(); };