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