Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / clang / test / OpenMP / teams_distribute_collapse_messages.cpp
blob50d8ab2686d392d70d03584df8284f13dac25d81
1 // RUN: %clang_cc1 -verify -fopenmp %s -Wuninitialized
2 // RUN: %clang_cc1 -verify -fopenmp %s -std=c++98 -Wuninitialized
3 // RUN: %clang_cc1 -verify -fopenmp %s -std=c++11 -Wuninitialized
5 // RUN: %clang_cc1 -verify -fopenmp-simd %s -Wuninitialized
6 // RUN: %clang_cc1 -verify -fopenmp-simd %s -std=c++98 -Wuninitialized
7 // RUN: %clang_cc1 -verify -fopenmp-simd %s -std=c++11 -Wuninitialized
9 // expected-note@* 0+{{declared here}}
11 void foo() {
14 bool foobool(int argc) {
15 return argc;
18 struct S1;
20 template <class T, typename S, int N, int ST>
21 T tmain(T argc, S **argv) {
22 #pragma omp target
23 #pragma omp teams distribute collapse // expected-error {{expected '(' after 'collapse'}}
24 for (int i = ST; i < N; i++)
25 argv[0][i] = argv[0][i] - argv[0][i-ST];
27 #pragma omp target
28 #pragma omp teams distribute collapse ( // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
29 for (int i = ST; i < N; i++)
31 argv[0][i] = argv[0][i] - argv[0][i-ST];
32 #pragma omp target
33 #pragma omp teams distribute collapse () // expected-error {{expected expression}}
34 for (int i = ST; i < N; i++)
35 argv[0][i] = argv[0][i] - argv[0][i-ST];
37 // expected-error@+3 {{expected ')'}} expected-note@+3 {{to match this '('}}
38 // expected-error@+2 2 {{integral constant expression}} expected-note@+2 0+{{constant expression}}
39 #pragma omp target
40 #pragma omp teams distribute collapse (argc
41 for (int i = ST; i < N; i++)
42 argv[0][i] = argv[0][i] - argv[0][i-ST];
44 // expected-error@+2 2 {{argument to 'collapse' clause must be a strictly positive integer value}}
45 #pragma omp target
46 #pragma omp teams distribute collapse (ST // expected-error {{expected ')'}} expected-note {{to match this '('}}
47 for (int i = ST; i < N; i++)
48 argv[0][i] = argv[0][i] - argv[0][i-ST];
50 #pragma omp target
51 #pragma omp teams distribute collapse (1)) // expected-warning {{extra tokens at the end of '#pragma omp teams distribute' are ignored}}
52 for (int i = ST; i < N; i++)
53 argv[0][i] = argv[0][i] - argv[0][i-ST];
55 #pragma omp target
56 #pragma omp teams distribute collapse ((ST > 0) ? 1 + ST : 2) // expected-note 2 {{as specified in 'collapse' clause}}
57 for (int i = ST; i < N; i++)
58 argv[0][i] = argv[0][i] - argv[0][i-ST]; // expected-error 2 {{expected 2 for loops after '#pragma omp teams distribute', but found only 1}}
60 // expected-error@+4 2 {{directive '#pragma omp teams distribute' cannot contain more than one 'collapse' clause}}
61 // expected-error@+3 {{argument to 'collapse' clause must be a strictly positive integer value}}
62 // expected-error@+2 2 {{integral constant expression}} expected-note@+2 0+{{constant expression}}
63 #pragma omp target
64 #pragma omp teams distribute collapse (foobool(argc)), collapse (true), collapse (-5)
65 for (int i = ST; i < N; i++)
66 argv[0][i] = argv[0][i] - argv[0][i-ST];
68 #pragma omp target
69 #pragma omp teams distribute collapse (S) // expected-error {{'S' does not refer to a value}}
70 for (int i = ST; i < N; i++)
71 argv[0][i] = argv[0][i] - argv[0][i-ST];
73 #if __cplusplus >= 201103L
74 // expected-error@+5 2 {{integral constant expression must have integral or unscoped enumeration type}}
75 #else
76 // expected-error@+3 2 {{integral constant expression}} expected-note@+3 0+{{constant expression}}
77 #endif
78 #pragma omp target
79 #pragma omp teams distribute collapse (argv[1]=2) // expected-error {{expected ')'}} expected-note {{to match this '('}}
80 for (int i = ST; i < N; i++)
81 argv[0][i] = argv[0][i] - argv[0][i-ST];
83 #pragma omp target
84 #pragma omp teams distribute collapse (1)
85 for (int i = ST; i < N; i++)
86 argv[0][i] = argv[0][i] - argv[0][i-ST];
88 #pragma omp target
89 #pragma omp teams distribute collapse (N) // expected-error {{argument to 'collapse' clause must be a strictly positive integer value}}
90 for (T i = ST; i < N; i++)
91 argv[0][i] = argv[0][i] - argv[0][i-ST];
93 #pragma omp target
94 #pragma omp teams distribute collapse (2) // expected-note {{as specified in 'collapse' clause}}
95 foo(); // expected-error {{expected 2 for loops after '#pragma omp teams distribute'}}
96 return argc;
99 int main(int argc, char **argv) {
100 #pragma omp target
101 #pragma omp teams distribute collapse // expected-error {{expected '(' after 'collapse'}}
102 for (int i = 4; i < 12; i++)
103 argv[0][i] = argv[0][i] - argv[0][i-4];
105 #pragma omp target
106 #pragma omp teams distribute collapse ( // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
107 for (int i = 4; i < 12; i++)
108 argv[0][i] = argv[0][i] - argv[0][i-4];
110 #pragma omp target
111 #pragma omp teams distribute collapse () // expected-error {{expected expression}}
112 for (int i = 4; i < 12; i++)
113 argv[0][i] = argv[0][i] - argv[0][i-4];
115 #pragma omp target
116 #pragma omp teams distribute collapse (4 // expected-error {{expected ')'}} expected-note {{to match this '('}} expected-note {{as specified in 'collapse' clause}}
117 for (int i = 4; i < 12; i++)
118 argv[0][i] = argv[0][i] - argv[0][i-4]; // expected-error {{expected 4 for loops after '#pragma omp teams distribute', but found only 1}}
120 #pragma omp target
121 #pragma omp teams distribute collapse (2+2)) // expected-warning {{extra tokens at the end of '#pragma omp teams distribute' are ignored}} expected-note {{as specified in 'collapse' clause}}
122 for (int i = 4; i < 12; i++)
123 argv[0][i] = argv[0][i] - argv[0][i-4]; // expected-error {{expected 4 for loops after '#pragma omp teams distribute', but found only 1}}
125 #pragma omp target
126 #pragma omp teams distribute collapse (foobool(1) > 0 ? 1 : 2) // expected-error {{integral constant expression}} expected-note 0+{{constant expression}}
127 for (int i = 4; i < 12; i++)
128 argv[0][i] = argv[0][i] - argv[0][i-4];
130 // expected-error@+4 {{integral constant expression}} expected-note@+4 0+{{constant expression}}
131 // expected-error@+3 2 {{directive '#pragma omp teams distribute' cannot contain more than one 'collapse' clause}}
132 // expected-error@+2 {{argument to 'collapse' clause must be a strictly positive integer value}}
133 #pragma omp target
134 #pragma omp teams distribute collapse (foobool(argc)), collapse (true), collapse (-5)
135 for (int i = 4; i < 12; i++)
136 argv[0][i] = argv[0][i] - argv[0][i-4];
138 #pragma omp target
139 #pragma omp teams distribute collapse (S1) // expected-error {{'S1' does not refer to a value}}
140 for (int i = 4; i < 12; i++)
141 argv[0][i] = argv[0][i] - argv[0][i-4];
143 #if __cplusplus >= 201103L
144 // expected-error@+5 {{integral constant expression must have integral or unscoped enumeration type}}
145 #else
146 // expected-error@+3 {{integral constant expression}} expected-note@+3 0+{{constant expression}}
147 #endif
148 #pragma omp target
149 #pragma omp teams distribute collapse (argv[1]=2) // expected-error {{expected ')'}} expected-note {{to match this '('}}
150 for (int i = 4; i < 12; i++)
151 argv[0][i] = argv[0][i] - argv[0][i-4];
153 // expected-error@+4 {{statement after '#pragma omp teams distribute' must be a for loop}}
154 // expected-note@+2 {{in instantiation of function template specialization 'tmain<int, char, -1, -2>' requested here}}
155 #pragma omp target
156 #pragma omp teams distribute collapse(collapse(tmain<int, char, -1, -2>(argc, argv) // expected-error 2 {{expected ')'}} expected-note 2 {{to match this '('}}
157 foo();
159 #pragma omp target
160 #pragma omp teams distribute collapse (2) // expected-note {{as specified in 'collapse' clause}}
161 foo(); // expected-error {{expected 2 for loops after '#pragma omp teams distribute'}}
163 // expected-note@+1 {{in instantiation of function template specialization 'tmain<int, char, 1, 0>' requested here}}
164 return tmain<int, char, 1, 0>(argc, argv);