Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / clang / test / OpenMP / target_simd_collapse_messages.cpp
blob00fa3c85279f22f4a45a4e86b34a744827bd9319
1 // RUN: %clang_cc1 -verify -fopenmp %s -Wuninitialized
2 // RUN: %clang_cc1 -verify -fopenmp -std=c++11 %s -Wuninitialized
4 // RUN: %clang_cc1 -verify -fopenmp-simd %s -Wuninitialized
5 // RUN: %clang_cc1 -verify -fopenmp-simd -std=c++11 %s -Wuninitialized
7 // expected-note@* 0+{{declared here}}
9 void foo() {
12 bool foobool(int argc) {
13 return argc;
16 struct S1;
18 template <class T, typename S, int N, int ST>
19 T tmain(T argc, S **argv) {
20 int j;
21 #pragma omp target simd collapse // expected-error {{expected '(' after 'collapse'}}
22 for (int i = ST; i < N; i++) argv[0][i] = argv[0][i] - argv[0][i-ST];
23 #pragma omp target simd collapse ( // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
24 for (int i = ST; i < N; i++) argv[0][i] = argv[0][i] - argv[0][i-ST];
25 #pragma omp target simd collapse () // expected-error {{expected expression}}
26 for (int i = ST; i < N; i++) argv[0][i] = argv[0][i] - argv[0][i-ST];
27 // expected-error@+2 {{expected ')'}} expected-note@+2 {{to match this '('}}
28 // expected-error@+1 2 {{integral constant expression}} expected-note@+1 0+{{constant expression}}
29 #pragma omp target simd collapse (argc
30 for (int i = ST; i < N; i++) argv[0][i] = argv[0][i] - argv[0][i-ST];
31 // expected-error@+1 2 {{argument to 'collapse' clause must be a strictly positive integer value}}
32 #pragma omp target simd collapse (ST // expected-error {{expected ')'}} expected-note {{to match this '('}}
33 for (int i = ST; i < N; i++) argv[0][i] = argv[0][i] - argv[0][i-ST];
34 #pragma omp target simd collapse (1)) // expected-warning {{extra tokens at the end of '#pragma omp target simd' are ignored}}
35 for (int i = ST; i < N; i++) argv[0][i] = argv[0][i] - argv[0][i-ST];
36 #pragma omp target simd collapse ((ST > 0) ? 1 + ST : 2) // expected-note 2 {{as specified in 'collapse' clause}}
37 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 target simd', but found only 1}}
39 // expected-error@+3 2 {{directive '#pragma omp target simd' cannot contain more than one 'collapse' clause}}
40 // expected-error@+2 {{argument to 'collapse' clause must be a strictly positive integer value}}
41 // expected-error@+1 2 {{integral constant expression}} expected-note@+1 0+{{constant expression}}
42 #pragma omp target simd collapse (foobool(argc)), collapse (true), collapse (-5)
43 for (int i = ST; i < N; i++) argv[0][i] = argv[0][i] - argv[0][i-ST];
44 #pragma omp target simd collapse (S) // expected-error {{'S' does not refer to a value}}
45 for (int i = ST; i < N; i++) argv[0][i] = argv[0][i] - argv[0][i-ST];
47 // expected-error@+1 {{integral constant expression}} expected-note@+1 0+{{constant expression}}
48 #pragma omp target simd collapse (j=2) // expected-error {{expected ')'}} expected-note {{to match this '('}}
49 for (int i = ST; i < N; i++) argv[0][i] = argv[0][i] - argv[0][i-ST];
50 #pragma omp target simd collapse (1)
51 for (int i = ST; i < N; i++) argv[0][i] = argv[0][i] - argv[0][i-ST];
52 #pragma omp target simd collapse (N) // expected-error {{argument to 'collapse' clause must be a strictly positive integer value}}
53 for (T i = ST; i < N; i++) argv[0][i] = argv[0][i] - argv[0][i-ST];
54 #pragma omp target simd collapse (2) // expected-note {{as specified in 'collapse' clause}}
55 foo(); // expected-error {{expected 2 for loops after '#pragma omp target simd'}}
56 return argc;
59 int main(int argc, char **argv) {
60 int j;
61 #pragma omp target simd collapse // expected-error {{expected '(' after 'collapse'}}
62 for (int i = 4; i < 12; i++) argv[0][i] = argv[0][i] - argv[0][i-4];
63 #pragma omp target simd collapse ( // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
64 for (int i = 4; i < 12; i++) argv[0][i] = argv[0][i] - argv[0][i-4];
65 #pragma omp target simd collapse () // expected-error {{expected expression}}
66 for (int i = 4; i < 12; i++) argv[0][i] = argv[0][i] - argv[0][i-4];
67 #pragma omp target simd collapse (4 // expected-error {{expected ')'}} expected-note {{to match this '('}} expected-note {{as specified in 'collapse' clause}}
68 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 target simd', but found only 1}}
69 #pragma omp target simd collapse (2+2)) // expected-warning {{extra tokens at the end of '#pragma omp target simd' are ignored}} expected-note {{as specified in 'collapse' clause}}
70 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 target simd', but found only 1}}
72 #pragma omp target simd collapse (foobool(1) > 0 ? 1 : 2) // expected-error {{integral constant expression}} expected-note 0+{{constant expression}}
73 for (int i = 4; i < 12; i++) argv[0][i] = argv[0][i] - argv[0][i-4];
75 // expected-error@+3 {{integral constant expression}} expected-note@+3 0+{{constant expression}}
76 // expected-error@+2 2 {{directive '#pragma omp target simd' cannot contain more than one 'collapse' clause}}
77 // expected-error@+1 {{argument to 'collapse' clause must be a strictly positive integer value}}
78 #pragma omp target simd collapse (foobool(argc)), collapse (true), collapse (-5)
79 for (int i = 4; i < 12; i++) argv[0][i] = argv[0][i] - argv[0][i-4];
80 #pragma omp target simd collapse (S1) // expected-error {{'S1' does not refer to a value}}
81 for (int i = 4; i < 12; i++) argv[0][i] = argv[0][i] - argv[0][i-4];
83 // expected-error@+1 {{integral constant expression}} expected-note@+1 0+{{constant expression}}
84 #pragma omp target simd collapse (j=2) // expected-error {{expected ')'}} expected-note {{to match this '('}}
85 for (int i = 4; i < 12; i++) argv[0][i] = argv[0][i] - argv[0][i-4];
86 // expected-error@+3 {{statement after '#pragma omp target simd' must be a for loop}}
87 // expected-note@+1 {{in instantiation of function template specialization 'tmain<int, char, -1, -2>' requested here}}
88 #pragma omp target simd collapse(collapse(tmain<int, char, -1, -2>(argc, argv) // expected-error 2 {{expected ')'}} expected-note 2 {{to match this '('}}
89 foo();
90 #pragma omp target simd collapse (2) // expected-note {{as specified in 'collapse' clause}}
91 foo(); // expected-error {{expected 2 for loops after '#pragma omp target simd'}}
92 // expected-note@+1 {{in instantiation of function template specialization 'tmain<int, char, 1, 0>' requested here}}
93 return tmain<int, char, 1, 0>(argc, argv);