Home | History | Annotate | Download | only in CodeGenCXX
      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 i8* @"\01??2@YAPAXIUarbitrary_t@@@Z"(i32 16, %struct.arbitrary_t*
     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 i8* @"\01??_US@PR13164@@SAPAXIUarbitrary_t@@@Z"(i32 2, %struct.arbitrary_t*
     26     S *s1 = new(arbitrary) S;
     27     // CHECK: call i8* @"\01??2@YAPAXIUarbitrary_t@@@Z"(i32 1, %struct.arbitrary_t*
     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 i8* @"\01??_U@YAPAXIUarbitrary2_t@@@Z"(i32 2, %struct.arbitrary2_t*
     38   }
     39 }
     40