Clang Project

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