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