aboutsummaryrefslogtreecommitdiffstats
path: root/test/regression/parsing.c
blob: 8687d6aa5f23c9a528d9e2a7e6bb7d20c6d32366 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
#include<stdio.h>

typedef signed int T;

T f(T(T));
T f(T a(T)) {
  T b;
  return 1;
}

T f1(T(x));
T f1(T x) {
  return x;
}

int g(int x) {
 T:;
  T y;
  T T;
  T=1;

  return 1;
}

void h() {
  for(int T; ;)
    if(1)
      ;
  T *x;
  x = 0;
}

void h2() {
  for(int T; ;)
    if(1)
      ;
    else T;
}

struct S {
  const T:3;
  unsigned T:3;
  const T:3;
};

void i() {
  struct S s;
  s.T = -1;
  if(s.T < 0) printf("ERROR i\n");
}

/* These ones are parsed correctly, but rejected by the elaborator. */
/* void j() { */
/*   typedef int I; */
/*   {sizeof(enum{I=2}); return I;} */
/*   {do sizeof(enum{I=2}); while((I)1);} */
/*   {if(1) return sizeof(enum{I=2}); */
/*    else  return (I)1;} */
/*   {if(sizeof(enum{I=2})) return I; */
/*    else return I;} */
/*   {sizeof(enum{I=2})+I;} */
/*   {for(int i = sizeof(enum{I=2}); I; I) I; (I)1;} */
/* } */
/* int f2(enum{I=2} x) { */
/*   return I; */
/* } */
/* void k(A, B) */
/*      int B; */
/*      int A[B]; */
/* { } */
/* int l(A) */
/*      enum {T=1} A; */
/* { return T * A; } */

void m() {
  if(0)
    if(1);
    else printf("ERROR m\n");
  if(0)
    for(int i; ; )
      if(1);
      else printf("ERROR m\n");
  if(0)
    for(1; ; )
      if(1);
      else printf("ERROR m\n");
  if(0)
    while(1)
      if(1);
      else printf("ERROR m\n");
  if(0)
  L: if(1);
     else printf("ERROR m\n");

  if(0)
  LL:for(1;;)
      for(int i;;)
        while(1)
          switch(1)
          case 1:
            if(1);
            else printf("ERROR m\n");
}

int j() {
  T T;
}

int k() {
  { T T; }
  T t;
  for(T T; ; );
  T u;
}

int main () {
  f(g);
  i();
  m();
  return 0;
}