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