Debian Codegraph @

clang/test/Modules/new-delete.cpp

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