xref: /minix3/external/bsd/llvm/dist/clang/test/Parser/cxx-default-args.cpp (revision f4a2713ac843a11c696ec80c0a5e3e5d80b4d338)
1*f4a2713aSLionel Sambuc // RUN: %clang_cc1 -fsyntax-only -verify %s
2*f4a2713aSLionel Sambuc 
3*f4a2713aSLionel Sambuc // PR6647
4*f4a2713aSLionel Sambuc class C {
5*f4a2713aSLionel Sambuc   // After the error, the rest of the tokens inside the default arg should be
6*f4a2713aSLionel Sambuc   // skipped, avoiding a "expected ';' after class" after 'undecl'.
7*f4a2713aSLionel Sambuc   void m(int x = undecl + 0); // expected-error {{use of undeclared identifier 'undecl'}}
8*f4a2713aSLionel Sambuc };
9*f4a2713aSLionel Sambuc 
10*f4a2713aSLionel Sambuc typedef struct Inst {
11*f4a2713aSLionel Sambuc   void m(int x=0);
12*f4a2713aSLionel Sambuc } *InstPtr;
13*f4a2713aSLionel Sambuc 
14*f4a2713aSLionel Sambuc struct X {
15*f4a2713aSLionel Sambuc   void f(int x = 1:); // expected-error {{unexpected end of default argument expression}}
16*f4a2713aSLionel Sambuc };
17*f4a2713aSLionel Sambuc 
18*f4a2713aSLionel Sambuc // PR13657
19*f4a2713aSLionel Sambuc struct T {
20*f4a2713aSLionel Sambuc   template <typename A, typename B> struct T1 { enum {V};};
21*f4a2713aSLionel Sambuc   template <int A, int B> struct T2 { enum {V}; };
22*f4a2713aSLionel Sambuc   template <int, int> static int func(int);
23*f4a2713aSLionel Sambuc 
24*f4a2713aSLionel Sambuc 
25*f4a2713aSLionel Sambuc   void f1(T1<int, int> = T1<int, int>());
26*f4a2713aSLionel Sambuc   void f2(T1<int, double> = T1<int, double>(), T2<0, 5> = T2<0, 5>());
27*f4a2713aSLionel Sambuc   void f3(int a = T2<0, (T1<int, int>::V > 10) ? 5 : 6>::V, bool b = 4<5 );
28*f4a2713aSLionel Sambuc   void f4(bool a = 1 < 0, bool b = 2 > 0 );
29*f4a2713aSLionel Sambuc   void f5(bool a = 1 > T2<0, 0>::V, bool b = T1<int,int>::V < 3, int c = 0);
30*f4a2713aSLionel Sambuc   void f6(bool a = T2<0,3>::V < 4, bool b = 4 > T2<0,3>::V);
31*f4a2713aSLionel Sambuc   void f7(bool a = T1<int, bool>::V < 3);
32*f4a2713aSLionel Sambuc   void f8(int = func<0,1<2>(0), int = 1<0, T1<int,int>(int) = 0);
33*f4a2713aSLionel Sambuc };
34