1 // The first run checks that the correct errors are generated,
2 // implicitly checking the order of default argument parsing:
3 // RUN: %clang_cc1 -fsyntax-only -verify %s
4 // The second run checks the order of inline method definitions:
5 // RUN: not %clang_cc1 -fsyntax-only %s 2> %t
6 // RUN: FileCheck %s < %t
7 
8 class A {
9 public:
a1()10   void a1() {
11     B b = B();
12   }
13 
14   class B;
15   void a2(B b = B()); // expected-error{{use of default argument to function 'B' that is declared later in class 'B'}}
16 
17   void a3(int a = 42);
18 
19   // CHECK: error: use of undeclared identifier 'first'
20   void a4(int a = first); // expected-error{{use of undeclared identifier 'first'}}
21 
22   class B {
23   public:
B(int b=42)24     B(int b = 42) { // expected-note{{default argument declared here}}
25       A a;
26       a.a3();
27       a.a6();
28     }
29 
30     void b1(A a = A()); // expected-error{{use of default argument to function 'A' that is declared later in class 'A'}}
31 
32     // CHECK: error: use of undeclared identifier 'second'
33     void b2(int a = second); // expected-error{{use of undeclared identifier 'second'}}
34   };
35 
a5()36   void a5() {
37     B b = B();
38   }
39 
40   void a6(B b = B());
41 
42   A(int a = 42); // expected-note{{default argument declared here}}
43 
44   // CHECK: error: use of undeclared identifier 'third'
45   void a7(int a = third); // expected-error{{use of undeclared identifier 'third'}}
46 };
47