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