summaryrefslogtreecommitdiffstats
path: root/clang/test/Modules/new-delete.cpp
blob: 585a242b22474e253b0f789b0271fd42caaac7e5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
// RUN: %clang_cc1 -fmodules -verify %s
// expected-no-diagnostics

#pragma clang module build M
module M {}
#pragma clang module contents
#pragma clang module begin M
struct A {
  A();
  ~A() { delete p; } // expected-warning {{'delete' applied to a pointer that was allocated with 'new[]'}}
  int *p;
};
inline A::A() : p(new int[32]) {} // expected-note {{allocated}}
struct B {
  B();
  ~B() { delete p; }
  int *p;
};
#pragma clang module end
#pragma clang module endbuild

#pragma clang module import M
B::B() : p(new int[32]) {}
OpenPOWER on IntegriCloud