xref: /minix3/external/bsd/llvm/dist/clang/test/Parser/recovery.c (revision f4a2713ac843a11c696ec80c0a5e3e5d80b4d338)
1*f4a2713aSLionel Sambuc // RUN: %clang_cc1 -fsyntax-only -verify -pedantic -fblocks %s
2*f4a2713aSLionel Sambuc 
3*f4a2713aSLionel Sambuc // PR2241
4*f4a2713aSLionel Sambuc float test2241[2] = {
5*f4a2713aSLionel Sambuc   1e,            // expected-error {{exponent}}
6*f4a2713aSLionel Sambuc   1ee0           // expected-error {{exponent}}
7*f4a2713aSLionel Sambuc };
8*f4a2713aSLionel Sambuc 
9*f4a2713aSLionel Sambuc 
10*f4a2713aSLionel Sambuc // Testcase derived from PR2692
f(char * (* g)(char **,int),char ** p,...)11*f4a2713aSLionel Sambuc static void f (char * (*g) (char **, int), char **p, ...) {
12*f4a2713aSLionel Sambuc   char *s;
13*f4a2713aSLionel Sambuc   va_list v;                              // expected-error {{identifier}}
14*f4a2713aSLionel Sambuc   s = g (p, __builtin_va_arg(v, int));    // expected-error {{identifier}}
15*f4a2713aSLionel Sambuc }
16*f4a2713aSLionel Sambuc 
17*f4a2713aSLionel Sambuc 
18*f4a2713aSLionel Sambuc // PR3172
19*f4a2713aSLionel Sambuc } // expected-error {{extraneous closing brace ('}')}}
20*f4a2713aSLionel Sambuc 
21*f4a2713aSLionel Sambuc 
22*f4a2713aSLionel Sambuc // rdar://6094870
23*f4a2713aSLionel Sambuc void test(int a) {
24*f4a2713aSLionel Sambuc   struct { int i; } x;
25*f4a2713aSLionel Sambuc 
26*f4a2713aSLionel Sambuc   if (x.hello)   // expected-error {{no member named 'hello'}}
27*f4a2713aSLionel Sambuc     test(0);
28*f4a2713aSLionel Sambuc   else
29*f4a2713aSLionel Sambuc     ;
30*f4a2713aSLionel Sambuc 
31*f4a2713aSLionel Sambuc   if (x.hello == 0)   // expected-error {{no member named 'hello'}}
32*f4a2713aSLionel Sambuc     test(0);
33*f4a2713aSLionel Sambuc   else
34*f4a2713aSLionel Sambuc     ;
35*f4a2713aSLionel Sambuc 
36*f4a2713aSLionel Sambuc   if ((x.hello == 0))   // expected-error {{no member named 'hello'}}
37*f4a2713aSLionel Sambuc     test(0);
38*f4a2713aSLionel Sambuc   else
39*f4a2713aSLionel Sambuc     ;
40*f4a2713aSLionel Sambuc 
41*f4a2713aSLionel Sambuc   // PR12595
42*f4a2713aSLionel Sambuc   if (x.i == 0))   // expected-error {{extraneous ')' after condition, expected a statement}}
43*f4a2713aSLionel Sambuc     test(0);
44*f4a2713aSLionel Sambuc   else
45*f4a2713aSLionel Sambuc     ;
46*f4a2713aSLionel Sambuc }
47*f4a2713aSLionel Sambuc 
48*f4a2713aSLionel Sambuc 
49*f4a2713aSLionel Sambuc 
50*f4a2713aSLionel Sambuc char ((((                       /* expected-note {{to match this '('}} */
51*f4a2713aSLionel Sambuc          *X x ] ))));                    /* expected-error {{expected ')'}} */
52*f4a2713aSLionel Sambuc 
53*f4a2713aSLionel Sambuc ;   // expected-warning {{extra ';' outside of a function}}
54*f4a2713aSLionel Sambuc 
55*f4a2713aSLionel Sambuc 
56*f4a2713aSLionel Sambuc 
57*f4a2713aSLionel Sambuc 
58*f4a2713aSLionel Sambuc struct S { void *X, *Y; };
59*f4a2713aSLionel Sambuc 
60*f4a2713aSLionel Sambuc struct S A = {
61*f4a2713aSLionel Sambuc &BADIDENT, 0     /* expected-error {{use of undeclared identifier}} */
62*f4a2713aSLionel Sambuc };
63*f4a2713aSLionel Sambuc 
64*f4a2713aSLionel Sambuc // rdar://6248081
65*f4a2713aSLionel Sambuc void test6248081() {
66*f4a2713aSLionel Sambuc   [10]  // expected-error {{expected expression}}
67*f4a2713aSLionel Sambuc }
68*f4a2713aSLionel Sambuc 
69*f4a2713aSLionel Sambuc struct forward; // expected-note{{forward declaration of 'struct forward'}}
70*f4a2713aSLionel Sambuc void x(struct forward* x) {switch(x->a) {}} // expected-error {{incomplete definition of type}}
71*f4a2713aSLionel Sambuc 
72*f4a2713aSLionel Sambuc // PR3410
73*f4a2713aSLionel Sambuc void foo() {
74*f4a2713aSLionel Sambuc   int X;
75*f4a2713aSLionel Sambuc   X = 4 // expected-error{{expected ';' after expression}}
76*f4a2713aSLionel Sambuc }
77*f4a2713aSLionel Sambuc 
78*f4a2713aSLionel Sambuc // rdar://9045701
79*f4a2713aSLionel Sambuc void test9045701(int x) {
80*f4a2713aSLionel Sambuc #define VALUE 0
81*f4a2713aSLionel Sambuc   x = VALUE // expected-error{{expected ';' after expression}}
82*f4a2713aSLionel Sambuc }
83*f4a2713aSLionel Sambuc 
84*f4a2713aSLionel Sambuc // rdar://7980651
85*f4a2713aSLionel Sambuc typedef int intptr_t;  // expected-note {{'intptr_t' declared here}}
86*f4a2713aSLionel Sambuc void bar(intptr y);     // expected-error {{unknown type name 'intptr'; did you mean 'intptr_t'?}}
87*f4a2713aSLionel Sambuc 
88*f4a2713aSLionel Sambuc void test1(void) {
89*f4a2713aSLionel Sambuc   int x = 2: // expected-error {{expected ';' at end of declaration}}
90*f4a2713aSLionel Sambuc   int y = x;
91*f4a2713aSLionel Sambuc   int z = y;
92*f4a2713aSLionel Sambuc }
93*f4a2713aSLionel Sambuc 
94*f4a2713aSLionel Sambuc void test2(int x) {
95*f4a2713aSLionel Sambuc #define VALUE2 VALUE+VALUE
96*f4a2713aSLionel Sambuc #define VALUE3 VALUE+0
97*f4a2713aSLionel Sambuc #define VALUE4(x) x+0
98*f4a2713aSLionel Sambuc   x = VALUE2 // expected-error{{expected ';' after expression}}
99*f4a2713aSLionel Sambuc   x = VALUE3 // expected-error{{expected ';' after expression}}
100*f4a2713aSLionel Sambuc   x = VALUE4(0) // expected-error{{expected ';' after expression}}
101*f4a2713aSLionel Sambuc }
102