Mark Heffernan | bd26f5e | 2014-07-21 18:08:34 +0000 | [diff] [blame] | 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) { |
| 7 | int i = 0; |
| 8 | |
| 9 | #pragma unroll |
| 10 | while (i + 1 < Length) { |
| 11 | List[i] = i; |
| 12 | } |
| 13 | |
Mark Heffernan | c888e41 | 2014-07-24 18:09:38 +0000 | [diff] [blame] | 14 | #pragma nounroll |
| 15 | while (i < Length) { |
| 16 | List[i] = i; |
| 17 | } |
| 18 | |
Mark Heffernan | bd26f5e | 2014-07-21 18:08:34 +0000 | [diff] [blame] | 19 | #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 Heffernan | bd26f5e | 2014-07-21 18:08:34 +0000 | [diff] [blame] | 29 | /* expected-error {{expected ')'}} */ #pragma unroll(4 |
Mark Heffernan | 450c238 | 2014-07-23 17:31:31 +0000 | [diff] [blame] | 30 | /* expected-error {{missing argument to '#pragma unroll'}} */ #pragma unroll() |
Mark Heffernan | bd26f5e | 2014-07-21 18:08:34 +0000 | [diff] [blame] | 31 | /* 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 Heffernan | c888e41 | 2014-07-24 18:09:38 +0000 | [diff] [blame] | 36 | /* expected-warning {{extra tokens at end of '#pragma nounroll'}} */ #pragma nounroll 1 |
| 37 | while (i-7 < Length) { |
| 38 | List[i] = i; |
| 39 | } |
| 40 | |
Mark Heffernan | bd26f5e | 2014-07-21 18:08:34 +0000 | [diff] [blame] | 41 | /* 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 Heffernan | c888e41 | 2014-07-24 18:09:38 +0000 | [diff] [blame] | 55 | #pragma nounroll |
| 56 | /* expected-error {{expected a for, while, or do-while loop to follow '#pragma nounroll'}} */ int l = Length; |
Mark Heffernan | bd26f5e | 2014-07-21 18:08:34 +0000 | [diff] [blame] | 57 | |
| 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 Heffernan | 450c238 | 2014-07-23 17:31:31 +0000 | [diff] [blame] | 64 | /* 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 Heffernan | c888e41 | 2014-07-24 18:09:38 +0000 | [diff] [blame] | 76 | /* 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 Heffernan | bd26f5e | 2014-07-21 18:08:34 +0000 | [diff] [blame] | 88 | /* 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 Heffernan | 450c238 | 2014-07-23 17:31:31 +0000 | [diff] [blame] | 94 | /* expected-error {{duplicate directives 'unroll(full)' and '#pragma unroll'}} */ #pragma unroll |
| 95 | #pragma clang loop unroll(full) |
Mark Heffernan | bd26f5e | 2014-07-21 18:08:34 +0000 | [diff] [blame] | 96 | 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}} */ } |