[VPlan] Perform DT expensive input DT verification earlier (NFC).
[llvm-project.git] / clang / test / OpenMP / distribute_simd_collapse_messages.cpp
blob98b02ed814fd492a04024b4b4b507ec85c078bb0
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
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
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
24 #pragma omp distribute simd collapse // expected-error {{expected '(' after 'collapse'}}
25 for (int i = ST; i < N; i++) argv[0][i] = argv[0][i] - argv[0][i-ST];
26 #pragma omp target
27 #pragma omp teams
28 #pragma omp distribute simd collapse ( // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
29 for (int i = ST; i < N; i++) argv[0][i] = argv[0][i] - argv[0][i-ST];
30 #pragma omp target
31 #pragma omp teams
32 #pragma omp distribute simd collapse () // expected-error {{expected expression}}
33 for (int i = ST; i < N; i++) argv[0][i] = argv[0][i] - argv[0][i-ST];
34 #pragma omp target
35 #pragma omp teams
36 // expected-error@+2 {{expected ')'}} expected-note@+2 {{to match this '('}}
37 // expected-error@+1 2 {{integral constant expression}} expected-note@+1 0+{{constant expression}}
38 #pragma omp distribute simd collapse (argc
39 for (int i = ST; i < N; i++) argv[0][i] = argv[0][i] - argv[0][i-ST];
40 #pragma omp target
41 #pragma omp teams
42 // expected-error@+1 2 {{argument to 'collapse' clause must be a strictly positive integer value}}
43 #pragma omp distribute simd collapse (ST // expected-error {{expected ')'}} expected-note {{to match this '('}}
44 for (int i = ST; i < N; i++) argv[0][i] = argv[0][i] - argv[0][i-ST];
45 #pragma omp target
46 #pragma omp teams
47 #pragma omp distribute simd collapse (1)) // expected-warning {{extra tokens at the end of '#pragma omp distribute simd' are ignored}}
48 for (int i = ST; i < N; i++) argv[0][i] = argv[0][i] - argv[0][i-ST];
49 #pragma omp target
50 #pragma omp teams
51 #pragma omp distribute simd collapse ((ST > 0) ? 1 + ST : 2) // expected-note 2 {{as specified in 'collapse' clause}}
52 for (int i = ST; i < N; i++) argv[0][i] = argv[0][i] - argv[0][i-ST]; // expected-error 2 {{expected 2 for loops after '#pragma omp distribute simd', but found only 1}}
53 // expected-error@+5 2 {{directive '#pragma omp distribute simd' cannot contain more than one 'collapse' clause}}
54 // expected-error@+4 {{argument to 'collapse' clause must be a strictly positive integer value}}
55 // expected-error@+3 2 {{integral constant expression}} expected-note@+3 0+{{constant expression}}
56 #pragma omp target
57 #pragma omp teams
58 #pragma omp distribute simd collapse (foobool(argc)), collapse (true), collapse (-5)
59 for (int i = ST; i < N; i++) argv[0][i] = argv[0][i] - argv[0][i-ST];
60 #pragma omp target
61 #pragma omp teams
62 #pragma omp distribute simd collapse (S) // expected-error {{'S' does not refer to a value}}
63 for (int i = ST; i < N; i++) argv[0][i] = argv[0][i] - argv[0][i-ST];
64 #if __cplusplus <= 199711L
65 // expected-error@+6 2 {{integral constant expression}} expected-note@+6 0+{{constant expression}}
66 #else
67 // expected-error@+4 2 {{integral constant expression must have integral or unscoped enumeration type, not 'char *'}}
68 #endif
69 #pragma omp target
70 #pragma omp teams
71 #pragma omp distribute simd collapse (argv[1]=2) // expected-error {{expected ')'}} expected-note {{to match this '('}}
72 for (int i = ST; i < N; i++) argv[0][i] = argv[0][i] - argv[0][i-ST];
73 #pragma omp target
74 #pragma omp teams
75 #pragma omp distribute simd collapse (1)
76 for (int i = ST; i < N; i++) argv[0][i] = argv[0][i] - argv[0][i-ST];
77 #pragma omp target
78 #pragma omp teams
79 #pragma omp distribute simd collapse (N) // expected-error {{argument to 'collapse' clause must be a strictly positive integer value}}
80 for (T i = ST; i < N; i++) argv[0][i] = argv[0][i] - argv[0][i-ST];
81 #pragma omp target
82 #pragma omp teams
83 #pragma omp distribute simd collapse (2) // expected-note {{as specified in 'collapse' clause}}
84 foo(); // expected-error {{expected 2 for loops after '#pragma omp distribute simd'}}
85 return argc;
88 int main(int argc, char **argv) {
89 #pragma omp target
90 #pragma omp teams
91 #pragma omp distribute simd collapse // expected-error {{expected '(' after 'collapse'}}
92 for (int i = 4; i < 12; i++) argv[0][i] = argv[0][i] - argv[0][i-4];
93 #pragma omp target
94 #pragma omp teams
95 #pragma omp distribute simd collapse ( // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
96 for (int i = 4; i < 12; i++) argv[0][i] = argv[0][i] - argv[0][i-4];
97 #pragma omp target
98 #pragma omp teams
99 #pragma omp distribute simd collapse () // expected-error {{expected expression}}
100 for (int i = 4; i < 12; i++) argv[0][i] = argv[0][i] - argv[0][i-4];
101 #pragma omp target
102 #pragma omp teams
103 #pragma omp distribute simd collapse (4 // expected-error {{expected ')'}} expected-note {{to match this '('}} expected-note {{as specified in 'collapse' clause}}
104 for (int i = 4; i < 12; i++) argv[0][i] = argv[0][i] - argv[0][i-4]; // expected-error {{expected 4 for loops after '#pragma omp distribute simd', but found only 1}}
105 #pragma omp target
106 #pragma omp teams
107 #pragma omp distribute simd collapse (2+2)) // expected-warning {{extra tokens at the end of '#pragma omp distribute simd' are ignored}} expected-note {{as specified in 'collapse' clause}}
108 for (int i = 4; i < 12; i++) argv[0][i] = argv[0][i] - argv[0][i-4]; // expected-error {{expected 4 for loops after '#pragma omp distribute simd', but found only 1}}
109 // expected-error@+3 {{integral constant expression}} expected-note@+3 0+{{constant expression}}
110 #pragma omp target
111 #pragma omp teams
112 #pragma omp distribute simd collapse (foobool(1) > 0 ? 1 : 2)
113 for (int i = 4; i < 12; i++) argv[0][i] = argv[0][i] - argv[0][i-4];
114 // expected-error@+5 {{integral constant expression}} expected-note@+5 0+{{constant expression}}
115 // expected-error@+4 2 {{directive '#pragma omp distribute simd' cannot contain more than one 'collapse' clause}}
116 // expected-error@+3 {{argument to 'collapse' clause must be a strictly positive integer value}}
117 #pragma omp target
118 #pragma omp teams
119 #pragma omp distribute simd collapse (foobool(argc)), collapse (true), collapse (-5)
120 for (int i = 4; i < 12; i++) argv[0][i] = argv[0][i] - argv[0][i-4];
121 #pragma omp target
122 #pragma omp teams
123 #pragma omp distribute simd collapse (S1) // expected-error {{'S1' does not refer to a value}}
124 for (int i = 4; i < 12; i++) argv[0][i] = argv[0][i] - argv[0][i-4];
125 #if __cplusplus <= 199711L
126 // expected-error@+6 {{integral constant expression}} expected-note@+6 0+{{constant expression}}
127 #else
128 // expected-error@+4 {{integral constant expression must have integral or unscoped enumeration type, not 'char *'}}
129 #endif
130 #pragma omp target
131 #pragma omp teams
132 #pragma omp distribute simd collapse (argv[1]=2) // expected-error {{expected ')'}} expected-note {{to match this '('}}
133 for (int i = 4; i < 12; i++) argv[0][i] = argv[0][i] - argv[0][i-4];
134 // expected-error@+5 {{statement after '#pragma omp distribute simd' must be a for loop}}
135 // expected-note@+3 {{in instantiation of function template specialization 'tmain<int, char, -1, -2>' requested here}}
136 #pragma omp target
137 #pragma omp teams
138 #pragma omp distribute simd collapse(collapse(tmain<int, char, -1, -2>(argc, argv) // expected-error 2 {{expected ')'}} expected-note 2 {{to match this '('}}
139 foo();
140 #pragma omp target
141 #pragma omp teams
142 #pragma omp distribute simd collapse (2) // expected-note {{as specified in 'collapse' clause}}
143 foo(); // expected-error {{expected 2 for loops after '#pragma omp distribute simd'}}
144 // expected-note@+1 {{in instantiation of function template specialization 'tmain<int, char, 1, 0>' requested here}}
145 return tmain<int, char, 1, 0>(argc, argv);