blob: 5d28dae2d84dda4325b49757823a0e0c90d3dccb [file] [log] [blame]
Mark Heffernanbd26f5e2014-07-21 18:08:34 +00001// RUN: %clang_cc1 -std=c++11 -verify %s
2
3// Note that this puts the expected lines before the directives to work around
4// limitations in the -verify mode.
5
6void test(int *List, int Length) {
7 int i = 0;
8
9#pragma unroll
10 while (i + 1 < Length) {
11 List[i] = i;
12 }
13
Mark Heffernanc888e412014-07-24 18:09:38 +000014#pragma nounroll
15 while (i < Length) {
16 List[i] = i;
17 }
18
Mark Heffernanbd26f5e2014-07-21 18:08:34 +000019#pragma unroll 4
20 while (i - 1 < Length) {
21 List[i] = i;
22 }
23
24#pragma unroll(8)
25 while (i - 2 < Length) {
26 List[i] = i;
27 }
28
Mark Heffernanbd26f5e2014-07-21 18:08:34 +000029/* expected-error {{expected ')'}} */ #pragma unroll(4
Mark Heffernan450c2382014-07-23 17:31:31 +000030/* expected-error {{missing argument to '#pragma unroll'}} */ #pragma unroll()
Mark Heffernanbd26f5e2014-07-21 18:08:34 +000031/* expected-warning {{extra tokens at end of '#pragma unroll'}} */ #pragma unroll 1 2
32 while (i-6 < Length) {
33 List[i] = i;
34 }
35
Mark Heffernanc888e412014-07-24 18:09:38 +000036/* expected-warning {{extra tokens at end of '#pragma nounroll'}} */ #pragma nounroll 1
37 while (i-7 < Length) {
38 List[i] = i;
39 }
40
Mark Heffernanbd26f5e2014-07-21 18:08:34 +000041/* expected-error {{invalid argument; expected a positive integer value}} */ #pragma unroll(()
42/* expected-error {{invalid argument; expected a positive integer value}} */ #pragma unroll -
43/* expected-error {{invalid argument; expected a positive integer value}} */ #pragma unroll(0)
44/* expected-error {{invalid argument; expected a positive integer value}} */ #pragma unroll 0
45/* expected-error {{invalid argument; expected a positive integer value}} */ #pragma unroll(3000000000)
46/* expected-error {{invalid argument; expected a positive integer value}} */ #pragma unroll 3000000000
47 while (i-8 < Length) {
48 List[i] = i;
49 }
50
51#pragma unroll
52/* expected-error {{expected a for, while, or do-while loop to follow '#pragma unroll'}} */ int j = Length;
53#pragma unroll 4
54/* expected-error {{expected a for, while, or do-while loop to follow '#pragma unroll'}} */ int k = Length;
Mark Heffernanc888e412014-07-24 18:09:38 +000055#pragma nounroll
56/* expected-error {{expected a for, while, or do-while loop to follow '#pragma nounroll'}} */ int l = Length;
Mark Heffernanbd26f5e2014-07-21 18:08:34 +000057
58/* expected-error {{incompatible directives 'unroll(disable)' and '#pragma unroll(4)'}} */ #pragma unroll 4
59#pragma clang loop unroll(disable)
60 while (i-10 < Length) {
61 List[i] = i;
62 }
63
Mark Heffernan450c2382014-07-23 17:31:31 +000064/* expected-error {{incompatible directives 'unroll(full)' and '#pragma unroll(4)'}} */ #pragma unroll(4)
65#pragma clang loop unroll(full)
66 while (i-11 < Length) {
67 List[i] = i;
68 }
69
70/* expected-error {{incompatible directives '#pragma unroll' and '#pragma unroll(4)'}} */ #pragma unroll(4)
71#pragma unroll
72 while (i-11 < Length) {
73 List[i] = i;
74 }
75
Mark Heffernanc888e412014-07-24 18:09:38 +000076/* expected-error {{incompatible directives '#pragma nounroll' and 'unroll_count(4)'}} */ #pragma clang loop unroll_count(4)
77#pragma nounroll
78 while (i-12 < Length) {
79 List[i] = i;
80 }
81
82/* expected-error {{duplicate directives '#pragma nounroll' and '#pragma nounroll'}} */ #pragma nounroll
83#pragma nounroll
84 while (i-13 < Length) {
85 List[i] = i;
86 }
87
Mark Heffernanbd26f5e2014-07-21 18:08:34 +000088/* expected-error {{duplicate directives '#pragma unroll' and '#pragma unroll'}} */ #pragma unroll
89#pragma unroll
90 while (i-14 < Length) {
91 List[i] = i;
92 }
93
Mark Heffernan450c2382014-07-23 17:31:31 +000094/* expected-error {{duplicate directives 'unroll(full)' and '#pragma unroll'}} */ #pragma unroll
95#pragma clang loop unroll(full)
Mark Heffernanbd26f5e2014-07-21 18:08:34 +000096 while (i-15 < Length) {
97 List[i] = i;
98 }
99
100/* expected-error {{duplicate directives '#pragma unroll(4)' and '#pragma unroll(4)'}} */ #pragma unroll 4
101#pragma unroll(4)
102 while (i-16 < Length) {
103 List[i] = i;
104 }
105
106#pragma unroll
107/* expected-error {{expected statement}} */ }