3 // RUN: split-file %s %t
5 // RUN: %clang_cc1 -std=c++20 %t/A.cppm -emit-module-interface -o %t/A.pcm
6 // RUN: %clang_cc1 -std=c++20 %t/Use.cpp -fprebuilt-module-path=%t -fsyntax-only -verify
8 // RUN: %clang_cc1 -std=c++20 %t/A.cppm -emit-reduced-module-interface -o %t/A.pcm
9 // RUN: %clang_cc1 -std=c++20 %t/Use.cpp -fprebuilt-module-path=%t -fsyntax-only -verify
13 using size_t = decltype(sizeof(0));
15 void *operator new(std::size_t, void *p
) { return p
; }
19 #include "placement.h"
21 export
template<class T
>
23 A(void *p
) : ptr(new (p
) T(43)) {}
29 B(void *p
) : ptr(new (p
) int(43)) {}
34 // The use of operator new in the current module unit is only in the non-inline
35 // function definitions. So it may be optimized out.
39 // expected-no-diagnostics
43 A
<int> a(nullptr); // Good. It should be OK to construct A.
45 void *p
= ::operator new(sizeof(int), ptr
); // Bad. The placement allocation in module A is not visible.
46 void *q
= new (ptr
) int(43); // Good. We don't call the placement allocation function directly.