1 | // 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 | |
6 | void test(int *List, int Length, int Value) { |
7 | int i = 0; |
8 | |
9 | #pragma unroll_and_jam |
10 | for (int i = 0; i < Length; i++) { |
11 | for (int j = 0; j < Length; j++) { |
12 | List[i * Length + j] = Value; |
13 | } |
14 | } |
15 | |
16 | #pragma nounroll_and_jam |
17 | for (int i = 0; i < Length; i++) { |
18 | for (int j = 0; j < Length; j++) { |
19 | List[i * Length + j] = Value; |
20 | } |
21 | } |
22 | |
23 | #pragma unroll_and_jam 4 |
24 | for (int i = 0; i < Length; i++) { |
25 | for (int j = 0; j < Length; j++) { |
26 | List[i * Length + j] = Value; |
27 | } |
28 | } |
29 | |
30 | /* expected-error {{expected ')'}} */ #pragma unroll_and_jam(4 |
31 | /* expected-error {{missing argument; expected an integer value}} */ #pragma unroll_and_jam() |
32 | /* expected-warning {{extra tokens at end of '#pragma unroll_and_jam'}} */ #pragma unroll_and_jam 1 2 |
33 | for (int i = 0; i < Length; i++) { |
34 | for (int j = 0; j < Length; j++) { |
35 | List[i * Length + j] = Value; |
36 | } |
37 | } |
38 | |
39 | /* expected-warning {{extra tokens at end of '#pragma nounroll_and_jam'}} */ #pragma nounroll_and_jam 1 |
40 | for (int i = 0; i < Length; i++) { |
41 | for (int j = 0; j < Length; j++) { |
42 | List[i * Length + j] = Value; |
43 | } |
44 | } |
45 | |
46 | #pragma unroll_and_jam |
47 | /* expected-error {{expected a for, while, or do-while loop to follow '#pragma unroll_and_jam'}} */ int j = Length; |
48 | #pragma unroll_and_jam 4 |
49 | /* expected-error {{expected a for, while, or do-while loop to follow '#pragma unroll_and_jam'}} */ int k = Length; |
50 | #pragma nounroll_and_jam |
51 | /* expected-error {{expected a for, while, or do-while loop to follow '#pragma nounroll_and_jam'}} */ int l = Length; |
52 | |
53 | #pragma unroll_and_jam 4 |
54 | /* expected-error {{incompatible directives '#pragma nounroll_and_jam' and '#pragma unroll_and_jam(4)'}} */ #pragma nounroll_and_jam |
55 | for (int i = 0; i < Length; i++) { |
56 | for (int j = 0; j < Length; j++) { |
57 | List[i * Length + j] = Value; |
58 | } |
59 | } |
60 | |
61 | #pragma nounroll_and_jam |
62 | #pragma unroll(4) |
63 | for (int i = 0; i < Length; i++) { |
64 | for (int j = 0; j < Length; j++) { |
65 | List[i * Length + j] = Value; |
66 | } |
67 | } |
68 | |
69 | // pragma clang unroll_and_jam is disabled for the moment |
70 | /* expected-error {{invalid option 'unroll_and_jam'; expected vectorize, vectorize_width, interleave, interleave_count, unroll, unroll_count, pipeline, pipeline_initiation_interval, or distribute}} */ #pragma clang loop unroll_and_jam(4) |
71 | for (int i = 0; i < Length; i++) { |
72 | for (int j = 0; j < Length; j++) { |
73 | List[i * Length + j] = Value; |
74 | } |
75 | } |
76 | |
77 | #pragma unroll_and_jam |
78 | /* expected-error {{expected statement}} */ } |
79 | |