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 test(int * List,int Length)6void test(int *List, int Length) { 7 int i = 0; 8 9 #pragma clang loop vectorize(enable) 10 #pragma clang loop interleave(enable) 11 #pragma clang loop unroll(enable) 12 while (i + 1 < Length) { 13 List[i] = i; 14 } 15 16 #pragma clang loop vectorize_width(4) 17 #pragma clang loop interleave_count(8) 18 #pragma clang loop unroll_count(16) 19 while (i < Length) { 20 List[i] = i; 21 } 22 23 #pragma clang loop vectorize(disable) 24 #pragma clang loop interleave(disable) 25 #pragma clang loop unroll(disable) 26 while (i - 1 < Length) { 27 List[i] = i; 28 } 29 30 #pragma clang loop vectorize_width(4) interleave_count(8) unroll_count(16) 31 while (i - 2 < Length) { 32 List[i] = i; 33 } 34 35 #pragma clang loop interleave_count(16) 36 while (i - 3 < Length) { 37 List[i] = i; 38 } 39 40 int VList[Length]; 41 #pragma clang loop vectorize(disable) interleave(disable) unroll(disable) 42 for (int j : VList) { 43 VList[j] = List[j]; 44 } 45 46 /* expected-error {{expected '('}} */ #pragma clang loop vectorize 47 /* expected-error {{expected '('}} */ #pragma clang loop interleave 48 /* expected-error {{expected '('}} */ #pragma clang loop unroll 49 50 /* expected-error {{expected ')'}} */ #pragma clang loop vectorize(enable 51 /* expected-error {{expected ')'}} */ #pragma clang loop interleave(enable 52 /* expected-error {{expected ')'}} */ #pragma clang loop unroll(enable 53 54 /* expected-error {{expected ')'}} */ #pragma clang loop vectorize_width(4 55 /* expected-error {{expected ')'}} */ #pragma clang loop interleave_count(4 56 /* expected-error {{expected ')'}} */ #pragma clang loop unroll_count(4 57 58 /* expected-error {{missing argument to loop pragma 'vectorize'}} */ #pragma clang loop vectorize() 59 /* expected-error {{missing argument to loop pragma 'interleave_count'}} */ #pragma clang loop interleave_count() 60 /* expected-error {{missing argument to loop pragma 'unroll'}} */ #pragma clang loop unroll() 61 62 /* expected-error {{missing option}} */ #pragma clang loop 63 /* expected-error {{invalid option 'badkeyword'}} */ #pragma clang loop badkeyword 64 /* expected-error {{invalid option 'badkeyword'}} */ #pragma clang loop badkeyword(enable) 65 /* expected-error {{invalid option 'badkeyword'}} */ #pragma clang loop vectorize(enable) badkeyword(4) 66 /* expected-warning {{extra tokens at end of '#pragma clang loop'}} */ #pragma clang loop vectorize(enable) , 67 68 while (i-4 < Length) { 69 List[i] = i; 70 } 71 72 /* expected-error {{invalid argument; expected a positive integer value}} */ #pragma clang loop vectorize_width(0) 73 /* expected-error {{invalid argument; expected a positive integer value}} */ #pragma clang loop interleave_count(0) 74 /* expected-error {{invalid argument; expected a positive integer value}} */ #pragma clang loop unroll_count(0) 75 while (i-5 < Length) { 76 List[i] = i; 77 } 78 79 /* expected-error {{invalid argument; expected a positive integer value}} */ #pragma clang loop vectorize_width(3000000000) 80 /* expected-error {{invalid argument; expected a positive integer value}} */ #pragma clang loop interleave_count(3000000000) 81 /* expected-error {{invalid argument; expected a positive integer value}} */ #pragma clang loop unroll_count(3000000000) 82 while (i-6 < Length) { 83 List[i] = i; 84 } 85 86 /* expected-error {{invalid argument; expected a positive integer value}} */ #pragma clang loop vectorize_width(badvalue) 87 /* expected-error {{invalid argument; expected a positive integer value}} */ #pragma clang loop interleave_count(badvalue) 88 /* expected-error {{invalid argument; expected a positive integer value}} */ #pragma clang loop unroll_count(badvalue) 89 while (i-6 < Length) { 90 List[i] = i; 91 } 92 93 /* expected-error {{invalid argument; expected 'enable' or 'disable'}} */ #pragma clang loop vectorize(badidentifier) 94 /* expected-error {{invalid argument; expected 'enable' or 'disable'}} */ #pragma clang loop interleave(badidentifier) 95 /* expected-error {{invalid argument; expected 'enable' or 'disable'}} */ #pragma clang loop unroll(badidentifier) 96 while (i-7 < Length) { 97 List[i] = i; 98 } 99 100 // PR20069 - Loop pragma arguments that are not identifiers or numeric 101 // constants crash FE. 102 /* expected-error {{invalid argument; expected 'enable' or 'disable'}} */ #pragma clang loop vectorize(() 103 /* expected-error {{invalid argument; expected 'enable' or 'disable'}} */ #pragma clang loop interleave(*) 104 /* expected-error {{invalid argument; expected 'enable' or 'disable'}} */ #pragma clang loop unroll(=) 105 /* expected-error {{invalid argument; expected a positive integer value}} */ #pragma clang loop vectorize_width(^) 106 /* expected-error {{invalid argument; expected a positive integer value}} */ #pragma clang loop interleave_count(/) 107 /* expected-error {{invalid argument; expected a positive integer value}} */ #pragma clang loop unroll_count(==) 108 while (i-8 < Length) { 109 List[i] = i; 110 } 111 112 #pragma clang loop vectorize(enable) 113 /* expected-error {{expected a for, while, or do-while loop to follow the '#pragma clang loop' directive}} */ int j = Length; 114 List[0] = List[1]; 115 116 while (j-1 < Length) { 117 List[j] = j; 118 } 119 120 // FIXME: A bug in ParsedAttributes causes the order of the attributes to be 121 // processed in reverse. Consequently, the errors occur on the first of pragma 122 // of the next three tests rather than the last, and the order of the kinds 123 // is also reversed. 124 125 /* expected-error {{incompatible directives 'vectorize(disable)' and 'vectorize_width(4)'}} */ #pragma clang loop vectorize_width(4) 126 #pragma clang loop vectorize(disable) 127 /* expected-error {{incompatible directives 'interleave(disable)' and 'interleave_count(4)'}} */ #pragma clang loop interleave_count(4) 128 #pragma clang loop interleave(disable) 129 /* expected-error {{incompatible directives 'unroll(disable)' and 'unroll_count(4)'}} */ #pragma clang loop unroll_count(4) 130 #pragma clang loop unroll(disable) 131 while (i-8 < Length) { 132 List[i] = i; 133 } 134 135 /* expected-error {{duplicate directives 'vectorize(disable)' and 'vectorize(enable)'}} */ #pragma clang loop vectorize(enable) 136 #pragma clang loop vectorize(disable) 137 /* expected-error {{duplicate directives 'interleave(disable)' and 'interleave(enable)'}} */ #pragma clang loop interleave(enable) 138 #pragma clang loop interleave(disable) 139 /* expected-error {{duplicate directives 'unroll(disable)' and 'unroll(enable)'}} */ #pragma clang loop unroll(enable) 140 #pragma clang loop unroll(disable) 141 while (i-9 < Length) { 142 List[i] = i; 143 } 144 145 /* expected-error {{incompatible directives 'vectorize(disable)' and 'vectorize_width(4)'}} */ #pragma clang loop vectorize(disable) 146 #pragma clang loop vectorize_width(4) 147 /* expected-error {{incompatible directives 'interleave(disable)' and 'interleave_count(4)'}} */ #pragma clang loop interleave(disable) 148 #pragma clang loop interleave_count(4) 149 /* expected-error {{incompatible directives 'unroll(disable)' and 'unroll_count(4)'}} */ #pragma clang loop unroll(disable) 150 #pragma clang loop unroll_count(4) 151 while (i-10 < Length) { 152 List[i] = i; 153 } 154 155 /* expected-error {{duplicate directives 'vectorize_width(4)' and 'vectorize_width(8)'}} */ #pragma clang loop vectorize_width(8) 156 #pragma clang loop vectorize_width(4) 157 /* expected-error {{duplicate directives 'interleave_count(4)' and 'interleave_count(8)'}} */ #pragma clang loop interleave_count(8) 158 #pragma clang loop interleave_count(4) 159 /* expected-error {{duplicate directives 'unroll_count(4)' and 'unroll_count(8)'}} */ #pragma clang loop unroll_count(8) 160 #pragma clang loop unroll_count(4) 161 while (i-11 < Length) { 162 List[i] = i; 163 } 164 165 #pragma clang loop interleave(enable) 166 /* expected-error {{expected statement}} */ } 167