1// RUN: %clang_cc1 -emit-llvm %s -o - -triple=x86_64-apple-darwin10 -O3 | FileCheck %s
2
3struct A {
4  virtual int f() { return 1; }
5};
6
7struct B : A {
8  B() : i(f()) { }
9
10  virtual int f() { return 2; }
11
12  int i;
13};
14
15// CHECK-LABEL: define i32 @_Z1fv() #0
16int 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() [[NUW_RN:#[0-9]+]]
25int 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// CHECK: attributes [[NUW_RN]] = { nounwind readnone{{.*}} }
36