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)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 
14 #pragma nounroll
15   while (i < Length) {
16     List[i] = i;
17   }
18 
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 
29 /* expected-error {{expected ')'}} */ #pragma unroll(4
30 /* expected-error {{missing argument; expected an integer value}} */ #pragma unroll()
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 
36 /* expected-warning {{extra tokens at end of '#pragma nounroll'}} */ #pragma nounroll 1
37   while (i-7 < Length) {
38     List[i] = i;
39   }
40 
41 /* expected-error {{expected ')'}} */ #pragma unroll(()
42 /* expected-error {{expected expression}} */ #pragma unroll -
43 /* expected-error {{invalid value '0'; must be positive}} */ #pragma unroll(0)
44 /* expected-error {{invalid value '0'; must be positive}} */ #pragma unroll 0
45 /* expected-error {{value '3000000000' is too large}} */ #pragma unroll(3000000000)
46 /* expected-error {{value '3000000000' is too large}} */ #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;
55 #pragma nounroll
56 /* expected-error {{expected a for, while, or do-while loop to follow '#pragma nounroll'}} */ int l = Length;
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 
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 
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 
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 
94 /* expected-error {{duplicate directives 'unroll(full)' and '#pragma unroll'}} */ #pragma unroll
95 #pragma clang loop unroll(full)
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}} */ }
108