Anders Carlsson | a78fa2c | 2010-02-02 19:58:43 +0000 | [diff] [blame] | 1 | // RUN: %clang_cc1 -emit-llvm %s -o - -triple=x86_64-apple-darwin10 -O3 | FileCheck %s |
| 2 | |
| 3 | struct A { |
| 4 | virtual int f() { return 1; } |
| 5 | }; |
| 6 | |
| 7 | struct B : A { |
| 8 | B() : i(f()) { } |
| 9 | |
| 10 | virtual int f() { return 2; } |
| 11 | |
| 12 | int i; |
| 13 | }; |
| 14 | |
| 15 | // CHECK: define i32 @_Z1fv() nounwind |
| 16 | int f() { |
| 17 | B b; |
| 18 | |
| 19 | // CHECK: call i32 @_ZN1B1fEv |
| 20 | return b.i; |
| 21 | } |
| 22 | |
Anders Carlsson | f6b6025 | 2010-02-03 21:58:41 +0000 | [diff] [blame] | 23 | // Test that we don't try to fold the default value of j when initializing i. |
| 24 | // CHECK: define i32 @_Z9test_foldv() nounwind |
| 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 | |