brintos

brintos / llvm-project-archived public Read only

0
0
Text · 1.3 KiB · f01cad1 Raw
48 lines · cpp
1// RUN: %clang_cc1 -triple x86_64-windows-gnu -emit-llvm -o - %s | FileCheck %s2// RUN: %clang_cc1 -triple powerpc64le-windows-gnu -emit-llvm -o - %s | FileCheck %s3 4// An empty struct is handled as a struct with a dummy i8, on all targets.5// Most targets treat an empty struct return value as essentially void - but6// some don't. (Currently, at least x86_64-windows-* and powerpc64le-* don't7// treat it as void.)8//9// When intializing a struct with such a no_unique_address member, make sure we10// don't write the dummy i8 into the struct where there's no space allocated for11// it.12//13// This can only be tested with targets that don't treat empty struct returns as14// void.15 16struct S {};17S f();18struct Z {19  int x;20  [[no_unique_address]] S y;21  Z();22};23Z::Z() : x(111), y(f()) {}24 25// CHECK: define {{.*}} @_ZN1ZC2Ev26// CHECK: %call = call i8 @_Z1fv()27// CHECK-NEXT: ret void28 29 30// Check that the constructor for an empty member gets called with the right31// 'this' pointer.32 33struct S2 {34  S2();35};36struct Z2 {37  int x;38  [[no_unique_address]] S2 y;39  Z2();40};41Z2::Z2() : x(111) {}42 43// CHECK: define {{.*}} @_ZN2Z2C2Ev(ptr {{.*}} %this)44// CHECK: %this.addr = alloca ptr45// CHECK: store ptr %this, ptr %this.addr46// CHECK: %this1 = load ptr, ptr %this.addr47// CHECK: call void @_ZN2S2C1Ev(ptr {{.*}} %this1)48