summaryrefslogtreecommitdiffstats
path: root/test/Parser/pragma-unroll.cpp
blob: 1d89e63028c48abe0a08f5d97f7e339d85e05176 (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
// RUN: %clang_cc1 -std=c++11 -verify %s

// Note that this puts the expected lines before the directives to work around
// limitations in the -verify mode.

void test(int *List, int Length) {
  int i = 0;

#pragma unroll
  while (i + 1 < Length) {
    List[i] = i;
  }

#pragma unroll 4
  while (i - 1 < Length) {
    List[i] = i;
  }

#pragma unroll(8)
  while (i - 2 < Length) {
    List[i] = i;
  }

#pragma unroll
#pragma unroll(8)
  while (i - 3 < Length) {
    List[i] = i;
  }

#pragma clang loop unroll(enable)
#pragma unroll(8)
  while (i - 4 < Length) {
    List[i] = i;
  }

#pragma unroll
#pragma clang loop unroll_count(4)
  while (i - 5 < Length) {
    List[i] = i;
  }

/* expected-error {{expected ')'}} */ #pragma unroll(4
/* expected-error {{missing argument to '#pragma unroll'; expected a positive integer value}} */ #pragma unroll()
/* expected-warning {{extra tokens at end of '#pragma unroll'}} */ #pragma unroll 1 2
  while (i-6 < Length) {
    List[i] = i;
  }

/* expected-error {{invalid argument; expected a positive integer value}} */ #pragma unroll(()
/* expected-error {{invalid argument; expected a positive integer value}} */ #pragma unroll -
/* expected-error {{invalid argument; expected a positive integer value}} */ #pragma unroll(0)
/* expected-error {{invalid argument; expected a positive integer value}} */ #pragma unroll 0
/* expected-error {{invalid argument; expected a positive integer value}} */ #pragma unroll(3000000000)
/* expected-error {{invalid argument; expected a positive integer value}} */ #pragma unroll 3000000000
  while (i-8 < Length) {
    List[i] = i;
  }

#pragma unroll
/* expected-error {{expected a for, while, or do-while loop to follow '#pragma unroll'}} */ int j = Length;
#pragma unroll 4
/* expected-error {{expected a for, while, or do-while loop to follow '#pragma unroll'}} */ int k = Length;

/* expected-error {{incompatible directives 'unroll(disable)' and '#pragma unroll(4)'}} */ #pragma unroll 4
#pragma clang loop unroll(disable)
  while (i-10 < Length) {
    List[i] = i;
  }

/* expected-error {{duplicate directives '#pragma unroll' and '#pragma unroll'}} */ #pragma unroll
#pragma unroll
  while (i-14 < Length) {
    List[i] = i;
  }

/* expected-error {{duplicate directives 'unroll(enable)' and '#pragma unroll'}} */ #pragma unroll
#pragma clang loop unroll(enable)
  while (i-15 < Length) {
    List[i] = i;
  }

/* expected-error {{duplicate directives '#pragma unroll(4)' and '#pragma unroll(4)'}} */ #pragma unroll 4
#pragma unroll(4)
  while (i-16 < Length) {
    List[i] = i;
  }

#pragma unroll
/* expected-error {{expected statement}} */ }