[clang] Handle __declspec() attributes in using
[llvm-project.git] / clang / test / CodeGenCXX / microsoft-new.cpp
blob0a514ffcc89229737b04d00a982c9ca036617988
1 // RUN: %clang_cc1 -triple i686-pc-win32 -fms-compatibility %s -emit-llvm -o - | FileCheck %s
3 #include <stddef.h>
5 struct arbitrary_t {} arbitrary;
6 void *operator new(size_t size, arbitrary_t);
8 struct arbitrary2_t {} arbitrary2;
9 void *operator new[](size_t size, arbitrary2_t);
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
19 struct S {
20 void *operator new[](size_t size, arbitrary_t);
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
30 struct T {
31 void *operator new(size_t size, arbitrary2_t);
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