xref: /llvm-project/clang/test/OpenMP/target_update_messages.cpp (revision 2da9572a9b10c8e4d0db2f3267f1a2c0ea31c896)
1 // RUN: %clang_cc1 -verify=expected,omp45 -fopenmp -fopenmp-version=45 -ferror-limit 100 -o - -std=c++11 %s -Wuninitialized
2 // RUN: %clang_cc1 -verify=expected,omp50 -fopenmp -fopenmp-version=50 -ferror-limit 100 -o - -std=c++11 %s -Wuninitialized
3 
4 // RUN: %clang_cc1 -verify=expected,omp45 -fopenmp-simd -fopenmp-version=45 -ferror-limit 100 -o - -std=c++11 %s -Wuninitialized
5 // RUN: %clang_cc1 -verify=expected,omp50 -fopenmp-simd -fopenmp-version=50 -ferror-limit 100 -o - -std=c++11 %s -Wuninitialized
6 
7 void xxx(int argc) {
8   int x; // expected-note {{initialize the variable 'x' to silence this warning}}
9 #pragma omp target update to(x)
10   argc = x; // expected-warning {{variable 'x' is uninitialized when used here}}
11 }
12 
13 void foo() {
14 }
15 
16 bool foobool(int argc) {
17   return argc;
18 }
19 
20 struct S1; // Aexpected-note {{declared here}}
21 
22 template <class T, class S> // Aexpected-note {{declared here}}
23 int tmain(T argc, S **argv) {
24   int n;
25   return 0;
26 }
27 
28 int main(int argc, char **argv) {
29   int m;
30   #pragma omp target update // expected-error {{expected at least one 'to' clause or 'from' clause specified to '#pragma omp target update'}}
31   #pragma omp target update to(m) { // expected-warning {{extra tokens at the end of '#pragma omp target update' are ignored}}
32   #pragma omp target update to(m) ( // expected-warning {{extra tokens at the end of '#pragma omp target update' are ignored}}
33   #pragma omp target update to(m) [ // expected-warning {{extra tokens at the end of '#pragma omp target update' are ignored}}
34   #pragma omp target update to(m) ] // expected-warning {{extra tokens at the end of '#pragma omp target update' are ignored}}
35   #pragma omp target update to(m) ) // expected-warning {{extra tokens at the end of '#pragma omp target update' are ignored}}
36 
37   #pragma omp target update from(m) allocate(m) // expected-error {{unexpected OpenMP clause 'allocate' in directive '#pragma omp target update'}}
38   {
39     foo();
40   }
41 
42   int iarr[5][5];
43 #pragma omp target update to(iarr[0:][1:2:-1]) // omp50-error {{section stride is evaluated to a non-positive value -1}} omp45-error {{expected ']'}} omp45-note {{to match this '['}} expected-error {{expected at least one 'to' clause or 'from' clause specified to '#pragma omp target update'}}
44   {}
45 #pragma omp target update from(iarr[0:][1:2:-1]) // omp50-error {{section stride is evaluated to a non-positive value -1}} omp45-error {{expected ']'}} omp45-note {{to match this '['}} expected-error {{expected at least one 'to' clause or 'from' clause specified to '#pragma omp target update'}}
46 
47   return tmain(argc, argv);
48 }
49