blob: 1fa23ef4673b7a59d50cc237ee1f273814dc3710 [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
14#pragma unroll 4
15 while (i - 1 < Length) {
16 List[i] = i;
17 }
18
19#pragma unroll(8)
20 while (i - 2 < Length) {
21 List[i] = i;
22 }
23
Mark Heffernanbd26f5e2014-07-21 18:08:34 +000024/* expected-error {{expected ')'}} */ #pragma unroll(4
Mark Heffernan450c2382014-07-23 17:31:31 +000025/* expected-error {{missing argument to '#pragma unroll'}} */ #pragma unroll()
Mark Heffernanbd26f5e2014-07-21 18:08:34 +000026/* expected-warning {{extra tokens at end of '#pragma unroll'}} */ #pragma unroll 1 2
27 while (i-6 < Length) {
28 List[i] = i;
29 }
30
31/* expected-error {{invalid argument; expected a positive integer value}} */ #pragma unroll(()
32/* expected-error {{invalid argument; expected a positive integer value}} */ #pragma unroll -
33/* expected-error {{invalid argument; expected a positive integer value}} */ #pragma unroll(0)
34/* expected-error {{invalid argument; expected a positive integer value}} */ #pragma unroll 0
35/* expected-error {{invalid argument; expected a positive integer value}} */ #pragma unroll(3000000000)
36/* expected-error {{invalid argument; expected a positive integer value}} */ #pragma unroll 3000000000
37 while (i-8 < Length) {
38 List[i] = i;
39 }
40
41#pragma unroll
42/* expected-error {{expected a for, while, or do-while loop to follow '#pragma unroll'}} */ int j = Length;
43#pragma unroll 4
44/* expected-error {{expected a for, while, or do-while loop to follow '#pragma unroll'}} */ int k = Length;
45
46/* expected-error {{incompatible directives 'unroll(disable)' and '#pragma unroll(4)'}} */ #pragma unroll 4
47#pragma clang loop unroll(disable)
48 while (i-10 < Length) {
49 List[i] = i;
50 }
51
Mark Heffernan450c2382014-07-23 17:31:31 +000052/* expected-error {{incompatible directives 'unroll(full)' and '#pragma unroll(4)'}} */ #pragma unroll(4)
53#pragma clang loop unroll(full)
54 while (i-11 < Length) {
55 List[i] = i;
56 }
57
58/* expected-error {{incompatible directives '#pragma unroll' and '#pragma unroll(4)'}} */ #pragma unroll(4)
59#pragma unroll
60 while (i-11 < Length) {
61 List[i] = i;
62 }
63
Mark Heffernanbd26f5e2014-07-21 18:08:34 +000064/* expected-error {{duplicate directives '#pragma unroll' and '#pragma unroll'}} */ #pragma unroll
65#pragma unroll
66 while (i-14 < Length) {
67 List[i] = i;
68 }
69
Mark Heffernan450c2382014-07-23 17:31:31 +000070/* expected-error {{duplicate directives 'unroll(full)' and '#pragma unroll'}} */ #pragma unroll
71#pragma clang loop unroll(full)
Mark Heffernanbd26f5e2014-07-21 18:08:34 +000072 while (i-15 < Length) {
73 List[i] = i;
74 }
75
76/* expected-error {{duplicate directives '#pragma unroll(4)' and '#pragma unroll(4)'}} */ #pragma unroll 4
77#pragma unroll(4)
78 while (i-16 < Length) {
79 List[i] = i;
80 }
81
82#pragma unroll
83/* expected-error {{expected statement}} */ }