1 // RUN: %clang_cc1 %s -triple=x86_64-apple-darwin10 -emit-llvm -o - | FileCheck %s
2 struct A {
3   void f();
4 
5   int a;
6 };
7 
8 struct B : A {
9   double b;
10 };
11 
f()12 void f() {
13   B b;
14 
15   b.f();
16 }
17 
18 // CHECK: define %struct.B* @_Z1fP1A(%struct.A* %a) [[NUW:#[0-9]+]]
f(A * a)19 B *f(A *a) {
20   // CHECK-NOT: br label
21   // CHECK: ret %struct.B*
22   return static_cast<B*>(a);
23 }
24 
25 // PR5965
26 namespace PR5965 {
27 
28 // CHECK: define %struct.A* @_ZN6PR59651fEP1B(%struct.B* %b) [[NUW]]
f(B * b)29 A *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.
39 namespace test3 {
40   struct A {};
41   struct B : A {};
42 
43   void foo(A a);
test()44   void test() {
45     foo(B());
46   }
47 }
48 
49 // CHECK: attributes [[NUW]] = { noinline nounwind{{.*}} }
50