1// RUN: %clang_cc1 %s -triple=x86_64-apple-darwin10 -emit-llvm -o - | FileCheck %s
2struct 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 %struct.B* @_Z1fP1A(%struct.A* %a) nounwind
19B *f(A *a) {
20  // CHECK-NOT: br label
21  // CHECK: ret %struct.B*
22  return static_cast<B*>(a);
23}
24
25// PR5965
26namespace PR5965 {
27
28// CHECK: define %struct.A* @_ZN6PR59651fEP1B(%struct.B* %b) nounwind
29A *f(B* b) {
30  // CHECK-NOT: br label
31  // CHECK: ret %struct.A*
32  return b;
33}
34
35}
36
37// Don't crash on a derived-to-base conversion of an r-value
38// 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