File: p5.cpp

package info (click to toggle)
llvm-toolchain-3.8 1%3A3.8.1-12~bpo8%2B1
  • links: PTS, VCS
  • area: main
  • in suites: jessie-backports
  • size: 378,896 kB
  • sloc: cpp: 2,309,676; ansic: 477,070; objc: 100,918; asm: 97,974; python: 95,911; sh: 18,634; makefile: 7,265; perl: 5,584; ml: 5,460; pascal: 4,661; lisp: 2,548; xml: 686; cs: 350; php: 212; csh: 117
file content (46 lines) | stat: -rw-r--r-- 1,446 bytes parent folder | download | duplicates (43)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
// RUN: %clang_cc1 -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>
struct 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.
class T3_A;
template<typename T>
struct T3_B { 
  void f0(T *a) { 
    delete a; // expected-error{{calling a private destructor of class 'T3_A'}}
  } 
};

struct T3_C { 
  T3_B<T3_A> x; 
  void f0(T3_A *a) { 
    x.f0(a); // expected-note{{in instantiation of member function 'T3_B<T3_A>::f0' requested here}}
  } 
};

void f0(T3_A *a) { T3_C x; x.f0(a); }
class T3_A { 
private: 
  ~T3_A(); // expected-note{{declared private here}}
};