2014-07-22 02:08:34 +08:00
|
|
|
// 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;
|
|
|
|
}
|
|
|
|
|
2014-07-25 02:09:38 +08:00
|
|
|
#pragma nounroll
|
|
|
|
while (i < Length) {
|
|
|
|
List[i] = i;
|
|
|
|
}
|
|
|
|
|
2014-07-22 02:08:34 +08:00
|
|
|
#pragma unroll 4
|
|
|
|
while (i - 1 < Length) {
|
|
|
|
List[i] = i;
|
|
|
|
}
|
|
|
|
|
|
|
|
#pragma unroll(8)
|
|
|
|
while (i - 2 < Length) {
|
|
|
|
List[i] = i;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* expected-error {{expected ')'}} */ #pragma unroll(4
|
2014-10-13 04:46:07 +08:00
|
|
|
/* expected-error {{missing argument; expected an integer value}} */ #pragma unroll()
|
2014-07-22 02:08:34 +08:00
|
|
|
/* expected-warning {{extra tokens at end of '#pragma unroll'}} */ #pragma unroll 1 2
|
|
|
|
while (i-6 < Length) {
|
|
|
|
List[i] = i;
|
|
|
|
}
|
|
|
|
|
2014-07-25 02:09:38 +08:00
|
|
|
/* expected-warning {{extra tokens at end of '#pragma nounroll'}} */ #pragma nounroll 1
|
|
|
|
while (i-7 < Length) {
|
|
|
|
List[i] = i;
|
|
|
|
}
|
|
|
|
|
2014-10-13 04:46:07 +08:00
|
|
|
/* expected-error {{expected ')'}} */ #pragma unroll(()
|
|
|
|
/* expected-error {{expected expression}} */ #pragma unroll -
|
|
|
|
/* expected-error {{invalid value '0'; must be positive}} */ #pragma unroll(0)
|
|
|
|
/* expected-error {{invalid value '0'; must be positive}} */ #pragma unroll 0
|
|
|
|
/* expected-error {{value '3000000000' is too large}} */ #pragma unroll(3000000000)
|
|
|
|
/* expected-error {{value '3000000000' is too large}} */ #pragma unroll 3000000000
|
2014-07-22 02:08:34 +08:00
|
|
|
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;
|
2014-07-25 02:09:38 +08:00
|
|
|
#pragma nounroll
|
|
|
|
/* expected-error {{expected a for, while, or do-while loop to follow '#pragma nounroll'}} */ int l = Length;
|
2014-07-22 02:08:34 +08:00
|
|
|
|
2018-06-26 04:06:13 +08:00
|
|
|
/* expected-error {{incompatible directives 'unroll(disable)' and '#pragma unroll(4)'}} */ #pragma unroll 4
|
|
|
|
#pragma clang loop unroll(disable)
|
2014-07-22 02:08:34 +08:00
|
|
|
while (i-10 < Length) {
|
|
|
|
List[i] = i;
|
|
|
|
}
|
|
|
|
|
2018-06-26 04:06:13 +08:00
|
|
|
/* expected-error {{incompatible directives 'unroll(full)' and '#pragma unroll(4)'}} */ #pragma unroll(4)
|
|
|
|
#pragma clang loop unroll(full)
|
2014-07-24 01:31:31 +08:00
|
|
|
while (i-11 < Length) {
|
|
|
|
List[i] = i;
|
|
|
|
}
|
|
|
|
|
2018-06-26 04:06:13 +08:00
|
|
|
/* expected-error {{incompatible directives 'unroll(enable)' and '#pragma unroll(4)'}} */ #pragma unroll(4)
|
|
|
|
#pragma clang loop unroll(enable)
|
2015-08-11 01:29:39 +08:00
|
|
|
while (i-11 < Length) {
|
|
|
|
List[i] = i;
|
|
|
|
}
|
|
|
|
|
2018-06-26 04:06:13 +08:00
|
|
|
/* expected-error {{incompatible directives '#pragma unroll' and '#pragma unroll(4)'}} */ #pragma unroll(4)
|
|
|
|
#pragma unroll
|
2014-07-24 01:31:31 +08:00
|
|
|
while (i-11 < Length) {
|
|
|
|
List[i] = i;
|
|
|
|
}
|
|
|
|
|
2018-06-26 04:06:13 +08:00
|
|
|
/* expected-error {{incompatible directives '#pragma nounroll' and 'unroll_count(4)'}} */ #pragma clang loop unroll_count(4)
|
|
|
|
#pragma nounroll
|
2014-07-25 02:09:38 +08:00
|
|
|
while (i-12 < Length) {
|
|
|
|
List[i] = i;
|
|
|
|
}
|
|
|
|
|
2018-06-20 07:46:52 +08:00
|
|
|
/* expected-error {{duplicate directives '#pragma nounroll' and '#pragma nounroll'}} */ #pragma nounroll
|
2018-06-26 04:06:13 +08:00
|
|
|
#pragma nounroll
|
2014-07-25 02:09:38 +08:00
|
|
|
while (i-13 < Length) {
|
|
|
|
List[i] = i;
|
|
|
|
}
|
|
|
|
|
2018-06-20 07:46:52 +08:00
|
|
|
/* expected-error {{duplicate directives '#pragma unroll' and '#pragma unroll'}} */ #pragma unroll
|
2018-06-26 04:06:13 +08:00
|
|
|
#pragma unroll
|
2014-07-22 02:08:34 +08:00
|
|
|
while (i-14 < Length) {
|
|
|
|
List[i] = i;
|
|
|
|
}
|
|
|
|
|
2018-06-26 04:06:13 +08:00
|
|
|
/* expected-error {{duplicate directives 'unroll(full)' and '#pragma unroll'}} */ #pragma unroll
|
|
|
|
#pragma clang loop unroll(full)
|
2014-07-22 02:08:34 +08:00
|
|
|
while (i-15 < Length) {
|
|
|
|
List[i] = i;
|
|
|
|
}
|
|
|
|
|
2018-06-26 04:06:13 +08:00
|
|
|
/* expected-error {{duplicate directives '#pragma unroll(4)' and '#pragma unroll(4)'}} */ #pragma unroll 4
|
|
|
|
#pragma unroll(4)
|
2014-07-22 02:08:34 +08:00
|
|
|
while (i-16 < Length) {
|
|
|
|
List[i] = i;
|
|
|
|
}
|
|
|
|
|
|
|
|
#pragma unroll
|
|
|
|
/* expected-error {{expected statement}} */ }
|