1 // RUN: %clang_cc1 -verify -fopenmp %s -Wuninitialized
2 // RUN: %clang_cc1 -verify -fopenmp -std=c++98 %s -Wuninitialized
3 // RUN: %clang_cc1 -verify -fopenmp -std=c++11 %s -Wuninitialized
4
5 // RUN: %clang_cc1 -verify -fopenmp-simd %s -Wuninitialized
6 // RUN: %clang_cc1 -verify -fopenmp-simd -std=c++98 %s -Wuninitialized
7 // RUN: %clang_cc1 -verify -fopenmp-simd -std=c++11 %s -Wuninitialized
8
foo()9 void foo() {
10 }
11
12 #if __cplusplus >= 201103L
13 // expected-note@+2 4 {{declared here}}
14 #endif
foobool(int argc)15 bool foobool(int argc) {
16 return argc;
17 }
18
19 struct S1; // expected-note {{declared here}}
20
21 template <class T, typename S, int N, int ST> // expected-note {{declared here}}
22 T tmain(T argc, S **argv) { //expected-note 2 {{declared here}}
23 #pragma omp target
24 #pragma omp teams distribute simd collapse // expected-error {{expected '(' after 'collapse'}}
25 for (int i = ST; i < N; i++)
26 argv[0][i] = argv[0][i] - argv[0][i-ST];
27
28 #pragma omp target
29 #pragma omp teams distribute simd collapse ( // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
30 for (int i = ST; i < N; i++)
31
32 argv[0][i] = argv[0][i] - argv[0][i-ST];
33 #pragma omp target
34 #pragma omp teams distribute simd collapse () // expected-error {{expected expression}}
35 for (int i = ST; i < N; i++)
36 argv[0][i] = argv[0][i] - argv[0][i-ST];
37
38 // expected-error@+4 {{expected ')'}} expected-note@+4 {{to match this '('}}
39 // expected-error@+3 2 {{expression is not an integral constant expression}}
40 // expected-note@+2 2 {{read of non-const variable 'argc' is not allowed in a constant expression}}
41 #pragma omp target
42 #pragma omp teams distribute simd collapse (argc
43 for (int i = ST; i < N; i++)
44 argv[0][i] = argv[0][i] - argv[0][i-ST];
45
46 // expected-error@+2 2 {{argument to 'collapse' clause must be a strictly positive integer value}}
47 #pragma omp target
48 #pragma omp teams distribute simd collapse (ST // expected-error {{expected ')'}} expected-note {{to match this '('}}
49 for (int i = ST; i < N; i++)
50 argv[0][i] = argv[0][i] - argv[0][i-ST];
51
52 #pragma omp target
53 #pragma omp teams distribute simd collapse (1)) // expected-warning {{extra tokens at the end of '#pragma omp teams distribute simd' are ignored}}
54 for (int i = ST; i < N; i++)
55 argv[0][i] = argv[0][i] - argv[0][i-ST];
56
57 #pragma omp target
58 #pragma omp teams distribute simd collapse ((ST > 0) ? 1 + ST : 2) // expected-note 2 {{as specified in 'collapse' clause}}
59 for (int i = ST; i < N; i++)
60 argv[0][i] = argv[0][i] - argv[0][i-ST]; // expected-error 2 {{expected 2 for loops after '#pragma omp teams distribute simd', but found only 1}}
61
62 // expected-error@+7 2 {{directive '#pragma omp teams distribute simd' cannot contain more than one 'collapse' clause}}
63 // expected-error@+6 {{argument to 'collapse' clause must be a strictly positive integer value}}
64 // expected-error@+5 2 {{expression is not an integral constant expression}}
65 #if __cplusplus >= 201103L
66 // expected-note@+3 2 {{non-constexpr function 'foobool' cannot be used in a constant expression}}
67 #endif
68 #pragma omp target
69 #pragma omp teams distribute simd collapse (foobool(argc)), collapse (true), collapse (-5)
70 for (int i = ST; i < N; i++)
71 argv[0][i] = argv[0][i] - argv[0][i-ST];
72
73 #pragma omp distribute collapse (S) // expected-error {{'S' does not refer to a value}}
74 for (int i = ST; i < N; i++)
75 argv[0][i] = argv[0][i] - argv[0][i-ST];
76
77 #if __cplusplus <= 199711L
78 // expected-error@+5 2 {{expression is not an integral constant expression}}
79 #else
80 // expected-error@+3 2 {{integral constant expression must have integral or unscoped enumeration type, not 'char *'}}
81 #endif
82 #pragma omp target
83 #pragma omp teams distribute simd collapse (argv[1]=2) // expected-error {{expected ')'}} expected-note {{to match this '('}}
84 for (int i = ST; i < N; i++)
85 argv[0][i] = argv[0][i] - argv[0][i-ST];
86
87 #pragma omp target
88 #pragma omp teams distribute simd collapse (1)
89 for (int i = ST; i < N; i++)
90 argv[0][i] = argv[0][i] - argv[0][i-ST];
91
92 #pragma omp target
93 #pragma omp teams distribute simd collapse (N) // expected-error {{argument to 'collapse' clause must be a strictly positive integer value}}
94 for (T i = ST; i < N; i++)
95 argv[0][i] = argv[0][i] - argv[0][i-ST];
96
97 #pragma omp target
98 #pragma omp teams distribute simd collapse (2) // expected-note {{as specified in 'collapse' clause}}
99 foo(); // expected-error {{expected 2 for loops after '#pragma omp teams distribute simd'}}
100 return argc;
101 }
102
main(int argc,char ** argv)103 int main(int argc, char **argv) {
104 #pragma omp target
105 #pragma omp teams distribute simd collapse // expected-error {{expected '(' after 'collapse'}}
106 for (int i = 4; i < 12; i++)
107 argv[0][i] = argv[0][i] - argv[0][i-4];
108
109 #pragma omp target
110 #pragma omp teams distribute simd collapse ( // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
111 for (int i = 4; i < 12; i++)
112 argv[0][i] = argv[0][i] - argv[0][i-4];
113
114 #pragma omp target
115 #pragma omp teams distribute simd collapse () // expected-error {{expected expression}}
116 for (int i = 4; i < 12; i++)
117 argv[0][i] = argv[0][i] - argv[0][i-4];
118
119 #pragma omp target
120 #pragma omp teams distribute simd collapse (4 // expected-error {{expected ')'}} expected-note {{to match this '('}} expected-note {{as specified in 'collapse' clause}}
121 for (int i = 4; i < 12; i++)
122 argv[0][i] = argv[0][i] - argv[0][i-4]; // expected-error {{expected 4 for loops after '#pragma omp teams distribute simd', but found only 1}}
123
124 #pragma omp target
125 #pragma omp teams distribute simd collapse (2+2)) // expected-warning {{extra tokens at the end of '#pragma omp teams distribute simd' are ignored}} expected-note {{as specified in 'collapse' clause}}
126 for (int i = 4; i < 12; i++)
127 argv[0][i] = argv[0][i] - argv[0][i-4]; // expected-error {{expected 4 for loops after '#pragma omp teams distribute simd', but found only 1}}
128
129 #if __cplusplus >= 201103L
130 // expected-note@+3 {{non-constexpr function 'foobool' cannot be used in a constant expression}}
131 #endif
132 #pragma omp target
133 #pragma omp teams distribute simd collapse (foobool(1) > 0 ? 1 : 2) // expected-error {{expression is not an integral constant expression}}
134 for (int i = 4; i < 12; i++)
135 argv[0][i] = argv[0][i] - argv[0][i-4];
136
137 // expected-error@+7 {{expression is not an integral constant expression}}
138 // expected-error@+6 2 {{directive '#pragma omp teams distribute simd' cannot contain more than one 'collapse' clause}}
139 // expected-error@+5 {{argument to 'collapse' clause must be a strictly positive integer value}}
140 #if __cplusplus >= 201103L
141 // expected-note@+3 {{non-constexpr function 'foobool' cannot be used in a constant expression}}
142 #endif
143 #pragma omp target
144 #pragma omp teams distribute simd collapse (foobool(argc)), collapse (true), collapse (-5)
145 for (int i = 4; i < 12; i++)
146 argv[0][i] = argv[0][i] - argv[0][i-4];
147
148 #pragma omp target
149 #pragma omp teams distribute simd collapse (S1) // expected-error {{'S1' does not refer to a value}}
150 for (int i = 4; i < 12; i++)
151 argv[0][i] = argv[0][i] - argv[0][i-4];
152
153 #if __cplusplus >= 201103L
154 // expected-error@+5 {{integral constant expression must have integral or unscoped enumeration type, not 'char *'}}
155 #else
156 // expected-error@+3 {{expression is not an integral constant expression}}
157 #endif
158 #pragma omp target
159 #pragma omp teams distribute simd collapse (argv[1]=2) // expected-error {{expected ')'}} expected-note {{to match this '('}}
160 for (int i = 4; i < 12; i++)
161 argv[0][i] = argv[0][i] - argv[0][i-4];
162
163 // expected-error@+4 {{statement after '#pragma omp teams distribute simd' must be a for loop}}
164 // expected-note@+2 {{in instantiation of function template specialization 'tmain<int, char, -1, -2>' requested here}}
165 #pragma omp target
166 #pragma omp teams distribute simd collapse(collapse(tmain<int, char, -1, -2>(argc, argv) // expected-error 2 {{expected ')'}} expected-note 2 {{to match this '('}}
167 foo();
168
169 #pragma omp target
170 #pragma omp teams distribute simd collapse (2) // expected-note {{as specified in 'collapse' clause}}
171 foo(); // expected-error {{expected 2 for loops after '#pragma omp teams distribute simd'}}
172
173 // expected-note@+1 {{in instantiation of function template specialization 'tmain<int, char, 1, 0>' requested here}}
174 return tmain<int, char, 1, 0>(argc, argv);
175 }
176
177