| 1 |
// RUN: %clang_cc1 -triple i686-pc-win32 -fms-compatibility %s -emit-llvm -o - | FileCheck %s |
| 2 |
|
| 3 |
#include <stddef.h> |
| 4 |
|
| 5 |
struct arbitrary_t {} arbitrary; |
| 6 |
void *operator new(size_t size, arbitrary_t); |
| 7 |
|
| 8 |
struct arbitrary2_t {} arbitrary2; |
| 9 |
void *operator new[](size_t size, arbitrary2_t); |
| 10 |
|
| 11 |
namespace PR13164 { |
| 12 |
void f() { |
| 13 |
// MSVC will fall back on the non-array operator new. |
| 14 |
void *a; |
| 15 |
int *p = new(arbitrary) int[4]; |
| 16 |
// CHECK: call noundef ptr @"??2@YAPAXIUarbitrary_t@@@Z"(i32 noundef 16, ptr |
| 17 |
} |
| 18 |
|
| 19 |
struct S { |
| 20 |
void *operator new[](size_t size, arbitrary_t); |
| 21 |
}; |
| 22 |
|
| 23 |
void g() { |
| 24 |
S *s = new(arbitrary) S[2]; |
| 25 |
// CHECK: call noundef ptr @"??_US@PR13164@@SAPAXIUarbitrary_t@@@Z"(i32 noundef 2, ptr |
| 26 |
S *s1 = new(arbitrary) S; |
| 27 |
// CHECK: call noundef ptr @"??2@YAPAXIUarbitrary_t@@@Z"(i32 noundef 1, ptr |
| 28 |
} |
| 29 |
|
| 30 |
struct T { |
| 31 |
void *operator new(size_t size, arbitrary2_t); |
| 32 |
}; |
| 33 |
|
| 34 |
void h() { |
| 35 |
// This should still call the global operator new[]. |
| 36 |
T *t = new(arbitrary2) T[2]; |
| 37 |
// CHECK: call noundef ptr @"??_U@YAPAXIUarbitrary2_t@@@Z"(i32 noundef 2, ptr |
| 38 |
} |
| 39 |
} |