1 // RUN: %clang_cc1 -emit-llvm %s -o - -triple=x86_64-apple-darwin10 -O3 | FileCheck %s
2
3 struct A {
fA4 virtual int f() { return 1; }
5 };
6
7 struct B : A {
BB8 B() : i(f()) { }
9
fB10 virtual int f() { return 2; }
11
12 int i;
13 };
14
15 // CHECK: define i32 @_Z1fv() nounwind
f()16 int f() {
17 B b;
18
19 // CHECK: ret i32 2
20 return b.i;
21 }
22
23 // Test that we don't try to fold the default value of j when initializing i.
24 // CHECK: define i32 @_Z9test_foldv() nounwind
test_fold()25 int test_fold() {
26 struct A {
27 A(const int j = 1) : i(j) { }
28 int i;
29 };
30
31 // CHECK: ret i32 2
32 return A(2).i;
33 }
34
35