allocator is given the pointer to allocate into.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@149760
91177308-0d34-0410-b5e6-
96231b3b80d8
// Warn if the type is over-aligned and is being allocated by global operator
// new.
- if (OperatorNew &&
+ if (NumPlaceArgs == 0 && OperatorNew &&
(OperatorNew->isImplicit() ||
getSourceManager().isInSystemHeader(OperatorNew->getLocStart()))) {
if (unsigned Align = Context.getPreferredTypeAlign(AllocType.getTypePtr())){
return 0;
}
+void* operator new(unsigned long, void *) {
+ return 0;
+}
+
+void* operator new[](unsigned long, void *) {
+ return 0;
+}
// where the header here simulates <new>.
#include <warn-new-overaligned-3.h>
+namespace test1 {
struct Test {
template <typename T>
struct SeparateCacheLines {
void helper() {
Test t;
- new Test; // expected-warning {{type 'Test' requires 256 bytes of alignment and the default allocator only guarantees}}
- new Test[10]; // expected-warning {{type 'Test' requires 256 bytes of alignment and the default allocator only guarantees}}
+ new Test; // expected-warning {{type 'test1::Test' requires 256 bytes of alignment and the default allocator only guarantees}}
+ new Test[10]; // expected-warning {{type 'test1::Test' requires 256 bytes of alignment and the default allocator only guarantees}}
+}
+}
+
+namespace test2 {
+struct helper { int i __attribute__((aligned(256))); };
+
+struct Placement {
+ Placement() {
+ new (d) helper();
+ }
+ helper *d;
+};
}