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