75 lines · cpp
1// RUN: %clang_cc1 %s -triple=x86_64-apple-darwin10 -emit-llvm -o - | FileCheck %s2struct A { 3 void f(); 4 5 int a;6};7 8struct B : A { 9 double b;10};11 12void f() {13 B b;14 15 b.f();16}17 18// CHECK: define{{.*}} ptr @_Z1fP1A(ptr noundef %a) [[NUW:#[0-9]+]]19B *f(A *a) {20 // CHECK-NOT: br label21 // CHECK: ret ptr22 return static_cast<B*>(a);23}24 25// PR596526namespace PR5965 {27 28// CHECK: define{{.*}} ptr @_ZN6PR59651fEP1B(ptr noundef %b) [[NUW]]29A *f(B* b) {30 // CHECK-NOT: br label31 // CHECK: ret ptr32 return b;33}34 35}36 37// Don't crash on a derived-to-base conversion of an r-value38// aggregate.39namespace test3 {40 struct A {};41 struct B : A {};42 43 void foo(A a);44 void test() {45 foo(B());46 }47}48 49// Ensure volatile is preserved during derived-to-base conversion. 50namespace PR127683 {51 52struct Base {53 int Val;54};55 56struct Derived : Base { };57 58volatile Derived Obj;59 60// CHECK-LABEL: define void @_ZN8PR12768319test_volatile_storeEv()61// CHECK: store volatile i32 0, ptr @_ZN8PR1276833ObjE, align 462void test_volatile_store() {63 Obj.Val = 0;64}65 66// CHECK-LABEL: define void @_ZN8PR12768318test_volatile_loadEv()67// CHECK: %0 = load volatile i32, ptr @_ZN8PR1276833ObjE, align 468void test_volatile_load() {69 [[maybe_unused]] int Val = Obj.Val;70}71 72}73 74// CHECK: attributes [[NUW]] = { mustprogress noinline nounwind{{.*}} }75