1*67e74705SXin Li // RUN: %clang_cc1 -std=c++11 -verify %s 2*67e74705SXin Li 3*67e74705SXin Li // Note that this puts the expected lines before the directives to work around 4*67e74705SXin Li // limitations in the -verify mode. 5*67e74705SXin Li test(int * List,int Length)6*67e74705SXin Livoid test(int *List, int Length) { 7*67e74705SXin Li int i = 0; 8*67e74705SXin Li 9*67e74705SXin Li #pragma unroll 10*67e74705SXin Li while (i + 1 < Length) { 11*67e74705SXin Li List[i] = i; 12*67e74705SXin Li } 13*67e74705SXin Li 14*67e74705SXin Li #pragma nounroll 15*67e74705SXin Li while (i < Length) { 16*67e74705SXin Li List[i] = i; 17*67e74705SXin Li } 18*67e74705SXin Li 19*67e74705SXin Li #pragma unroll 4 20*67e74705SXin Li while (i - 1 < Length) { 21*67e74705SXin Li List[i] = i; 22*67e74705SXin Li } 23*67e74705SXin Li 24*67e74705SXin Li #pragma unroll(8) 25*67e74705SXin Li while (i - 2 < Length) { 26*67e74705SXin Li List[i] = i; 27*67e74705SXin Li } 28*67e74705SXin Li 29*67e74705SXin Li /* expected-error {{expected ')'}} */ #pragma unroll(4 30*67e74705SXin Li /* expected-error {{missing argument; expected an integer value}} */ #pragma unroll() 31*67e74705SXin Li /* expected-warning {{extra tokens at end of '#pragma unroll'}} */ #pragma unroll 1 2 32*67e74705SXin Li while (i-6 < Length) { 33*67e74705SXin Li List[i] = i; 34*67e74705SXin Li } 35*67e74705SXin Li 36*67e74705SXin Li /* expected-warning {{extra tokens at end of '#pragma nounroll'}} */ #pragma nounroll 1 37*67e74705SXin Li while (i-7 < Length) { 38*67e74705SXin Li List[i] = i; 39*67e74705SXin Li } 40*67e74705SXin Li 41*67e74705SXin Li /* expected-error {{expected ')'}} */ #pragma unroll(() 42*67e74705SXin Li /* expected-error {{expected expression}} */ #pragma unroll - 43*67e74705SXin Li /* expected-error {{invalid value '0'; must be positive}} */ #pragma unroll(0) 44*67e74705SXin Li /* expected-error {{invalid value '0'; must be positive}} */ #pragma unroll 0 45*67e74705SXin Li /* expected-error {{value '3000000000' is too large}} */ #pragma unroll(3000000000) 46*67e74705SXin Li /* expected-error {{value '3000000000' is too large}} */ #pragma unroll 3000000000 47*67e74705SXin Li while (i-8 < Length) { 48*67e74705SXin Li List[i] = i; 49*67e74705SXin Li } 50*67e74705SXin Li 51*67e74705SXin Li #pragma unroll 52*67e74705SXin Li /* expected-error {{expected a for, while, or do-while loop to follow '#pragma unroll'}} */ int j = Length; 53*67e74705SXin Li #pragma unroll 4 54*67e74705SXin Li /* expected-error {{expected a for, while, or do-while loop to follow '#pragma unroll'}} */ int k = Length; 55*67e74705SXin Li #pragma nounroll 56*67e74705SXin Li /* expected-error {{expected a for, while, or do-while loop to follow '#pragma nounroll'}} */ int l = Length; 57*67e74705SXin Li 58*67e74705SXin Li /* expected-error {{incompatible directives 'unroll(disable)' and '#pragma unroll(4)'}} */ #pragma unroll 4 59*67e74705SXin Li #pragma clang loop unroll(disable) 60*67e74705SXin Li while (i-10 < Length) { 61*67e74705SXin Li List[i] = i; 62*67e74705SXin Li } 63*67e74705SXin Li 64*67e74705SXin Li /* expected-error {{incompatible directives 'unroll(full)' and '#pragma unroll(4)'}} */ #pragma unroll(4) 65*67e74705SXin Li #pragma clang loop unroll(full) 66*67e74705SXin Li while (i-11 < Length) { 67*67e74705SXin Li List[i] = i; 68*67e74705SXin Li } 69*67e74705SXin Li 70*67e74705SXin Li /* expected-error {{incompatible directives 'unroll(enable)' and '#pragma unroll(4)'}} */ #pragma unroll(4) 71*67e74705SXin Li #pragma clang loop unroll(enable) 72*67e74705SXin Li while (i-11 < Length) { 73*67e74705SXin Li List[i] = i; 74*67e74705SXin Li } 75*67e74705SXin Li 76*67e74705SXin Li /* expected-error {{incompatible directives '#pragma unroll' and '#pragma unroll(4)'}} */ #pragma unroll(4) 77*67e74705SXin Li #pragma unroll 78*67e74705SXin Li while (i-11 < Length) { 79*67e74705SXin Li List[i] = i; 80*67e74705SXin Li } 81*67e74705SXin Li 82*67e74705SXin Li /* expected-error {{incompatible directives '#pragma nounroll' and 'unroll_count(4)'}} */ #pragma clang loop unroll_count(4) 83*67e74705SXin Li #pragma nounroll 84*67e74705SXin Li while (i-12 < Length) { 85*67e74705SXin Li List[i] = i; 86*67e74705SXin Li } 87*67e74705SXin Li 88*67e74705SXin Li /* expected-error {{duplicate directives '#pragma nounroll' and '#pragma nounroll'}} */ #pragma nounroll 89*67e74705SXin Li #pragma nounroll 90*67e74705SXin Li while (i-13 < Length) { 91*67e74705SXin Li List[i] = i; 92*67e74705SXin Li } 93*67e74705SXin Li 94*67e74705SXin Li /* expected-error {{duplicate directives '#pragma unroll' and '#pragma unroll'}} */ #pragma unroll 95*67e74705SXin Li #pragma unroll 96*67e74705SXin Li while (i-14 < Length) { 97*67e74705SXin Li List[i] = i; 98*67e74705SXin Li } 99*67e74705SXin Li 100*67e74705SXin Li /* expected-error {{duplicate directives 'unroll(full)' and '#pragma unroll'}} */ #pragma unroll 101*67e74705SXin Li #pragma clang loop unroll(full) 102*67e74705SXin Li while (i-15 < Length) { 103*67e74705SXin Li List[i] = i; 104*67e74705SXin Li } 105*67e74705SXin Li 106*67e74705SXin Li /* expected-error {{duplicate directives '#pragma unroll(4)' and '#pragma unroll(4)'}} */ #pragma unroll 4 107*67e74705SXin Li #pragma unroll(4) 108*67e74705SXin Li while (i-16 < Length) { 109*67e74705SXin Li List[i] = i; 110*67e74705SXin Li } 111*67e74705SXin Li 112*67e74705SXin Li #pragma unroll 113*67e74705SXin Li /* expected-error {{expected statement}} */ } 114