xref: /minix3/external/bsd/llvm/dist/clang/test/CodeGenCXX/default-arguments.cpp (revision 0a6a1f1d05b60e214de2f05a7310ddd1f0e590e7)
1f4a2713aSLionel Sambuc // RUN: %clang_cc1 %s -triple=x86_64-apple-darwin10 -emit-llvm -o - | FileCheck %s
2f4a2713aSLionel Sambuc 
3f4a2713aSLionel Sambuc // PR5484
4f4a2713aSLionel Sambuc namespace PR5484 {
5f4a2713aSLionel Sambuc struct A { };
6f4a2713aSLionel Sambuc extern A a;
7f4a2713aSLionel Sambuc 
8f4a2713aSLionel Sambuc void f(const A & = a);
9f4a2713aSLionel Sambuc 
g()10f4a2713aSLionel Sambuc void g() {
11f4a2713aSLionel Sambuc   f();
12f4a2713aSLionel Sambuc }
13f4a2713aSLionel Sambuc }
14f4a2713aSLionel Sambuc 
15f4a2713aSLionel Sambuc struct A1 {
16f4a2713aSLionel Sambuc  A1();
17f4a2713aSLionel Sambuc  ~A1();
18f4a2713aSLionel Sambuc };
19f4a2713aSLionel Sambuc 
20f4a2713aSLionel Sambuc struct A2 {
21f4a2713aSLionel Sambuc  A2();
22f4a2713aSLionel Sambuc  ~A2();
23f4a2713aSLionel Sambuc };
24f4a2713aSLionel Sambuc 
25f4a2713aSLionel Sambuc struct B {
26f4a2713aSLionel Sambuc  B(const A1& = A1(), const A2& = A2());
27f4a2713aSLionel Sambuc };
28f4a2713aSLionel Sambuc 
29f4a2713aSLionel Sambuc // CHECK-LABEL: define void @_Z2f1v()
f1()30f4a2713aSLionel Sambuc void f1() {
31f4a2713aSLionel Sambuc 
32f4a2713aSLionel Sambuc  // CHECK: call void @_ZN2A1C1Ev(
33f4a2713aSLionel Sambuc  // CHECK: call void @_ZN2A2C1Ev(
34f4a2713aSLionel Sambuc  // CHECK: call void @_ZN1BC1ERK2A1RK2A2(
35f4a2713aSLionel Sambuc  // CHECK: call void @_ZN2A2D1Ev
36f4a2713aSLionel Sambuc  // CHECK: call void @_ZN2A1D1Ev
37f4a2713aSLionel Sambuc  B bs[2];
38f4a2713aSLionel Sambuc }
39f4a2713aSLionel Sambuc 
40f4a2713aSLionel Sambuc struct C {
41f4a2713aSLionel Sambuc  B bs[2];
42f4a2713aSLionel Sambuc  C();
43f4a2713aSLionel Sambuc };
44f4a2713aSLionel Sambuc 
45f4a2713aSLionel Sambuc // CHECK-LABEL: define void @_ZN1CC2Ev(%struct.C* %this) unnamed_addr
46f4a2713aSLionel Sambuc // CHECK: call void @_ZN2A1C1Ev(
47f4a2713aSLionel Sambuc // CHECK: call void @_ZN2A2C1Ev(
48f4a2713aSLionel Sambuc // CHECK: call void @_ZN1BC1ERK2A1RK2A2(
49f4a2713aSLionel Sambuc // CHECK: call void @_ZN2A2D1Ev
50f4a2713aSLionel Sambuc // CHECK: call void @_ZN2A1D1Ev
51*0a6a1f1dSLionel Sambuc 
52*0a6a1f1dSLionel Sambuc // CHECK-LABEL: define void @_ZN1CC1Ev(%struct.C* %this) unnamed_addr
53*0a6a1f1dSLionel Sambuc // CHECK: call void @_ZN1CC2Ev(
C()54f4a2713aSLionel Sambuc C::C() { }
55f4a2713aSLionel Sambuc 
56f4a2713aSLionel Sambuc // CHECK-LABEL: define void @_Z2f3v()
f3()57f4a2713aSLionel Sambuc void f3() {
58f4a2713aSLionel Sambuc  // CHECK: call void @_ZN2A1C1Ev(
59f4a2713aSLionel Sambuc  // CHECK: call void @_ZN2A2C1Ev(
60f4a2713aSLionel Sambuc  // CHECK: call void @_ZN1BC1ERK2A1RK2A2(
61f4a2713aSLionel Sambuc  // CHECK: call void @_ZN2A2D1Ev
62f4a2713aSLionel Sambuc  // CHECK: call void @_ZN2A1D1Ev
63f4a2713aSLionel Sambuc  B *bs = new B[2];
64f4a2713aSLionel Sambuc  delete bs;
65f4a2713aSLionel Sambuc }
66f4a2713aSLionel Sambuc 
f4()67f4a2713aSLionel Sambuc void f4() {
68f4a2713aSLionel Sambuc   void g4(int a, int b = 7);
69f4a2713aSLionel Sambuc   {
70f4a2713aSLionel Sambuc     void g4(int a, int b = 5);
71f4a2713aSLionel Sambuc   }
72f4a2713aSLionel Sambuc   void g4(int a = 5, int b);
73f4a2713aSLionel Sambuc 
74f4a2713aSLionel Sambuc   // CHECK: call void @_Z2g4ii(i32 5, i32 7)
75f4a2713aSLionel Sambuc   g4();
76f4a2713aSLionel Sambuc }
77