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