Clang Project

clang_source_code/test/CodeGenCXX/constructor-default-arg.cpp
1// RUN: %clang_cc1 -triple x86_64-apple-darwin -std=c++11 -emit-llvm %s -o - | \
2// RUN: FileCheck %s
3// RUN: %clang_cc1 -triple i386-apple-darwin -std=c++11 -emit-llvm %s -o - | \
4// RUN: FileCheck %s
5
6extern "C" int printf(...);
7
8
9struct C {
10  C() : iC(6) {}
11  int iC;
12};
13
14int foo() {
15  return 6;
16};
17
18class X { // ...
19public: 
20  X(int) {}
21  X(const X&, int i = 1, int j = 2, int k = foo()) {
22    printf("X(const X&, %d, %d, %d)\n", i, j, k);
23  }
24};
25
26int main() {
27  X a(1);
28  X b(a, 2);
29  X c = b;
30  X d(a, 5, 6);
31}
32
33// CHECK: call void @_ZN1XC1ERKS_iii
34// CHECK: call void @_ZN1XC1ERKS_iii
35// CHECK: call void @_ZN1XC1ERKS_iii
36