aboutsummaryrefslogtreecommitdiffstats
path: root/gcc-4.9/gcc/testsuite/c-c++-common/cilk-plus/AN/misc.c
blob: 814786b9961b2ad9d969e0e5053babc5a88b7260 (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
/* { dg-do compile } */
/* { dg-options "-fcilkplus" } */

int main (void)
{
  int array[10], array2[10][10];
  int x, ii, jj ;

  switch (array[:]) {  /* { dg-error "cannot be used as a condition for switch statement" } */
  case 1:
    x = 5;
    break;
  case 2:
    x = 2;
    break;
  default:
    x = 9;
  }

  switch (array2[:][:]) { /* { dg-error "cannot be used as a condition for switch statement" } */
  case 1:
    x = 5;
    break;
  case 2:
    x = 2;
    break;
  default:
    x = 9;
  }

  switch (array[:] + x) { /* { dg-error "cannot be used as a condition for switch statement" } */
  case 1:
    x = 5;
    break;
  case 2:
    x = 2;
    break;
  default:
    x = 9;
  }
  
  switch (array2[:][1:x:4] + x) { /* { dg-error "cannot be used as a condition for switch statement" } */
  case 1:
    x = 5;
    break;
  case 2:
    x = 2;
    break;
  default:
    x = 9;
  }

  for (ii = 0; ii < array[:]; ii++) /* { dg-error "cannot be used in a condition for a for-loop" } */
    {
      x = 2;
    }

  for (ii = 0; ii < array2[:][:]; ii++) /* { dg-error "cannot be used in a condition for a for-loop" } */
    {
      x = 3;
    }

  for (; array2[:][:] < 2;) /* { dg-error "cannot be used in a condition for a for-loop" } */
    x = 4;


  while (array2[:][:]) /* { dg-error "cannot be used as a condition for while statement" } */
    x = 3;

  while (array[1:1:1]) /* { dg-error "cannot be used as a condition for while statement" } */
    x = 1;

  while (ii != array2[1:x:3][1:2:1]) /* { dg-error "cannot be used as a condition for while statement"  } */
    x = 2;

  do { /* { dg-error "cannot be used as a condition for a do-while statement" "" { target c } } */
    x = 3;
  } while (ii != array2[:][:]); /* { dg-error "cannot be used as a condition for a do-while statement" "" { target c++ } } */

  do {  /* { dg-error "cannot be used as a condition for a do-while statement" "" { target c } } */
    x = 2;
  } while (ii != (x + array2[:][1:x:2]) + 2); /* { dg-error "cannot be used as a condition for a do-while statement" "" { target c++ } } */
  
  do { 
    x += 3;
    if (x == 5)
      return array2[:][:]; /* { dg-error "array notation expression cannot be used as a return value" } */
  } while (ii != 0);

  for (ii = 0;  ii < 10; ii++)
    if (ii % 2)
      return array[1:x:ii]; /* { dg-error "array notation expression cannot be used as a return value" } */

  for (ii = 0; ii < x; ii++)
    if (ii)
      return array2[:][:]; /* { dg-error "array notation expression cannot be used as a return value" } */

  for (array[:] = 0; ii < x; ii++) /* This should be OK.  */
    x= 2;

  for (ii = 0; ii < 10; array[:]++) /* This is OK.  */
    x = 5;

  for (jj = 0; jj < 10; array2[:][:]++) /* This is OK.  */
    x = 3;

  for (jj = 0; jj < 10; array2[:][1:x:4]++, jj++) /* This is OK.  */
    x = 3;
  
  return x;
}