annotate clang/test/Parser/pragma-unroll.cpp @ 221:79ff65ed7e25

LLVM12 Original
author Shinji KONO <kono@ie.u-ryukyu.ac.jp>
date Tue, 15 Jun 2021 19:15:29 +0900
parents 1d019706d866
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
150
anatofuz
parents:
diff changeset
1 // RUN: %clang_cc1 -std=c++11 -verify %s
anatofuz
parents:
diff changeset
2
anatofuz
parents:
diff changeset
3 // Note that this puts the expected lines before the directives to work around
anatofuz
parents:
diff changeset
4 // limitations in the -verify mode.
anatofuz
parents:
diff changeset
5
anatofuz
parents:
diff changeset
6 void test(int *List, int Length) {
anatofuz
parents:
diff changeset
7 int i = 0;
anatofuz
parents:
diff changeset
8
anatofuz
parents:
diff changeset
9 #pragma unroll
anatofuz
parents:
diff changeset
10 while (i + 1 < Length) {
anatofuz
parents:
diff changeset
11 List[i] = i;
anatofuz
parents:
diff changeset
12 }
anatofuz
parents:
diff changeset
13
anatofuz
parents:
diff changeset
14 #pragma nounroll
anatofuz
parents:
diff changeset
15 while (i < Length) {
anatofuz
parents:
diff changeset
16 List[i] = i;
anatofuz
parents:
diff changeset
17 }
anatofuz
parents:
diff changeset
18
anatofuz
parents:
diff changeset
19 #pragma unroll 4
anatofuz
parents:
diff changeset
20 while (i - 1 < Length) {
anatofuz
parents:
diff changeset
21 List[i] = i;
anatofuz
parents:
diff changeset
22 }
anatofuz
parents:
diff changeset
23
anatofuz
parents:
diff changeset
24 #pragma unroll(8)
anatofuz
parents:
diff changeset
25 while (i - 2 < Length) {
anatofuz
parents:
diff changeset
26 List[i] = i;
anatofuz
parents:
diff changeset
27 }
anatofuz
parents:
diff changeset
28
anatofuz
parents:
diff changeset
29 /* expected-error {{expected ')'}} */ #pragma unroll(4
anatofuz
parents:
diff changeset
30 /* expected-error {{missing argument; expected an integer value}} */ #pragma unroll()
anatofuz
parents:
diff changeset
31 /* expected-warning {{extra tokens at end of '#pragma unroll'}} */ #pragma unroll 1 2
anatofuz
parents:
diff changeset
32 while (i-6 < Length) {
anatofuz
parents:
diff changeset
33 List[i] = i;
anatofuz
parents:
diff changeset
34 }
anatofuz
parents:
diff changeset
35
anatofuz
parents:
diff changeset
36 /* expected-warning {{extra tokens at end of '#pragma nounroll'}} */ #pragma nounroll 1
anatofuz
parents:
diff changeset
37 while (i-7 < Length) {
anatofuz
parents:
diff changeset
38 List[i] = i;
anatofuz
parents:
diff changeset
39 }
anatofuz
parents:
diff changeset
40
anatofuz
parents:
diff changeset
41 /* expected-error {{expected ')'}} */ #pragma unroll(()
anatofuz
parents:
diff changeset
42 /* expected-error {{expected expression}} */ #pragma unroll -
anatofuz
parents:
diff changeset
43 /* expected-error {{invalid value '0'; must be positive}} */ #pragma unroll(0)
anatofuz
parents:
diff changeset
44 /* expected-error {{invalid value '0'; must be positive}} */ #pragma unroll 0
anatofuz
parents:
diff changeset
45 /* expected-error {{value '3000000000' is too large}} */ #pragma unroll(3000000000)
anatofuz
parents:
diff changeset
46 /* expected-error {{value '3000000000' is too large}} */ #pragma unroll 3000000000
anatofuz
parents:
diff changeset
47 while (i-8 < Length) {
anatofuz
parents:
diff changeset
48 List[i] = i;
anatofuz
parents:
diff changeset
49 }
anatofuz
parents:
diff changeset
50
anatofuz
parents:
diff changeset
51 #pragma unroll
anatofuz
parents:
diff changeset
52 /* expected-error {{expected a for, while, or do-while loop to follow '#pragma unroll'}} */ int j = Length;
anatofuz
parents:
diff changeset
53 #pragma unroll 4
anatofuz
parents:
diff changeset
54 /* expected-error {{expected a for, while, or do-while loop to follow '#pragma unroll'}} */ int k = Length;
anatofuz
parents:
diff changeset
55 #pragma nounroll
anatofuz
parents:
diff changeset
56 /* expected-error {{expected a for, while, or do-while loop to follow '#pragma nounroll'}} */ int l = Length;
anatofuz
parents:
diff changeset
57
221
79ff65ed7e25 LLVM12 Original
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 150
diff changeset
58 switch (i) {
79ff65ed7e25 LLVM12 Original
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 150
diff changeset
59 case 1:
79ff65ed7e25 LLVM12 Original
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 150
diff changeset
60 #pragma unroll
79ff65ed7e25 LLVM12 Original
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 150
diff changeset
61 /* expected-error {{expected a for, while, or do-while loop to follow '#pragma unroll'}} */ [[fallthrough]];
79ff65ed7e25 LLVM12 Original
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 150
diff changeset
62 case 2:
79ff65ed7e25 LLVM12 Original
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 150
diff changeset
63 for (int i = 0; i < 10; ++i);
79ff65ed7e25 LLVM12 Original
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 150
diff changeset
64 break;
79ff65ed7e25 LLVM12 Original
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 150
diff changeset
65 }
79ff65ed7e25 LLVM12 Original
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 150
diff changeset
66
150
anatofuz
parents:
diff changeset
67 #pragma unroll 4
anatofuz
parents:
diff changeset
68 /* expected-error {{incompatible directives 'unroll(disable)' and '#pragma unroll(4)'}} */ #pragma clang loop unroll(disable)
anatofuz
parents:
diff changeset
69 while (i-10 < Length) {
anatofuz
parents:
diff changeset
70 List[i] = i;
anatofuz
parents:
diff changeset
71 }
anatofuz
parents:
diff changeset
72
anatofuz
parents:
diff changeset
73 #pragma unroll(4)
anatofuz
parents:
diff changeset
74 /* expected-error {{incompatible directives 'unroll(full)' and '#pragma unroll(4)'}} */ #pragma clang loop unroll(full)
anatofuz
parents:
diff changeset
75 while (i-11 < Length) {
anatofuz
parents:
diff changeset
76 List[i] = i;
anatofuz
parents:
diff changeset
77 }
anatofuz
parents:
diff changeset
78
anatofuz
parents:
diff changeset
79 #pragma unroll(4)
anatofuz
parents:
diff changeset
80 /* expected-error {{incompatible directives 'unroll(enable)' and '#pragma unroll(4)'}} */ #pragma clang loop unroll(enable)
anatofuz
parents:
diff changeset
81 while (i-11 < Length) {
anatofuz
parents:
diff changeset
82 List[i] = i;
anatofuz
parents:
diff changeset
83 }
anatofuz
parents:
diff changeset
84
anatofuz
parents:
diff changeset
85 #pragma unroll(4)
anatofuz
parents:
diff changeset
86 /* expected-error {{incompatible directives '#pragma unroll' and '#pragma unroll(4)'}} */ #pragma unroll
anatofuz
parents:
diff changeset
87 while (i-11 < Length) {
anatofuz
parents:
diff changeset
88 List[i] = i;
anatofuz
parents:
diff changeset
89 }
anatofuz
parents:
diff changeset
90
anatofuz
parents:
diff changeset
91 #pragma clang loop unroll_count(4)
anatofuz
parents:
diff changeset
92 /* expected-error {{incompatible directives '#pragma nounroll' and 'unroll_count(4)'}} */ #pragma nounroll
anatofuz
parents:
diff changeset
93 while (i-12 < Length) {
anatofuz
parents:
diff changeset
94 List[i] = i;
anatofuz
parents:
diff changeset
95 }
anatofuz
parents:
diff changeset
96
anatofuz
parents:
diff changeset
97 #pragma nounroll
anatofuz
parents:
diff changeset
98 /* expected-error {{duplicate directives '#pragma nounroll' and '#pragma nounroll'}} */ #pragma nounroll
anatofuz
parents:
diff changeset
99 while (i-13 < Length) {
anatofuz
parents:
diff changeset
100 List[i] = i;
anatofuz
parents:
diff changeset
101 }
anatofuz
parents:
diff changeset
102
anatofuz
parents:
diff changeset
103 #pragma unroll
anatofuz
parents:
diff changeset
104 /* expected-error {{duplicate directives '#pragma unroll' and '#pragma unroll'}} */ #pragma unroll
anatofuz
parents:
diff changeset
105 while (i-14 < Length) {
anatofuz
parents:
diff changeset
106 List[i] = i;
anatofuz
parents:
diff changeset
107 }
anatofuz
parents:
diff changeset
108
anatofuz
parents:
diff changeset
109 #pragma unroll
anatofuz
parents:
diff changeset
110 /* expected-error {{duplicate directives '#pragma unroll' and 'unroll(full)'}} */ #pragma clang loop unroll(full)
anatofuz
parents:
diff changeset
111 while (i-15 < Length) {
anatofuz
parents:
diff changeset
112 List[i] = i;
anatofuz
parents:
diff changeset
113 }
anatofuz
parents:
diff changeset
114
anatofuz
parents:
diff changeset
115 #pragma unroll 4
anatofuz
parents:
diff changeset
116 /* expected-error {{duplicate directives '#pragma unroll(4)' and '#pragma unroll(4)'}} */ #pragma unroll(4)
anatofuz
parents:
diff changeset
117 while (i-16 < Length) {
anatofuz
parents:
diff changeset
118 List[i] = i;
anatofuz
parents:
diff changeset
119 }
anatofuz
parents:
diff changeset
120
anatofuz
parents:
diff changeset
121 #pragma unroll
anatofuz
parents:
diff changeset
122 /* expected-error {{expected statement}} */ }