Clang Project

clang_source_code/test/Modules/new-delete.cpp
1// RUN: %clang_cc1 -fmodules -verify %s
2// expected-no-diagnostics
3
4#pragma clang module build M
5module M {}
6#pragma clang module contents
7#pragma clang module begin M
8struct A {
9  A();
10  ~A() { delete p; } // expected-warning {{'delete' applied to a pointer that was allocated with 'new[]'}}
11  int *p;
12};
13inline A::A() : p(new int[32]) {} // expected-note {{allocated}}
14struct B {
15  B();
16  ~B() { delete p; }
17  int *p;
18};
19#pragma clang module end
20#pragma clang module endbuild
21
22#pragma clang module import M
23B::B() : p(new int[32]) {}
24