• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // RUN: %clang_cc1 -verify=expected,omp45 -fopenmp -fopenmp-version=45 -ferror-limit 100 -std=c++11 -o - %s -Wuninitialized
2 // RUN: %clang_cc1 -verify=expected,omp50 -fopenmp -fopenmp-version=50 -ferror-limit 100 -std=c++11 -o - %s -Wuninitialized
3 
4 // RUN: %clang_cc1 -verify=expected,omp45 -fopenmp-simd -fopenmp-version=45 -ferror-limit 100 -std=c++11 -o - %s -Wuninitialized
5 // RUN: %clang_cc1 -verify=expected,omp50 -fopenmp-simd -fopenmp-version=50 -ferror-limit 100 -std=c++11 -o - %s -Wuninitialized
6 
xxx(int argc)7 void xxx(int argc) {
8   int x; // expected-note {{initialize the variable 'x' to silence this warning}}
9 #pragma omp target parallel for
10   for (int i = 0; i < 10; ++i)
11     argc = x; // expected-warning {{variable 'x' is uninitialized when used here}}
12 }
13 
foo()14 void foo() {
15 }
16 
17 static int pvt;
18 #pragma omp threadprivate(pvt)
19 
20 #pragma omp target parallel for // expected-error {{unexpected OpenMP directive '#pragma omp target parallel for'}}
21 
main(int argc,char ** argv)22 int main(int argc, char **argv) {
23 #pragma omp target parallel for { // expected-warning {{extra tokens at the end of '#pragma omp target parallel for' are ignored}}
24   for (int i = 0; i < argc; ++i)
25     foo();
26 #pragma omp target parallel for ( // expected-warning {{extra tokens at the end of '#pragma omp target parallel for' are ignored}}
27   for (int i = 0; i < argc; ++i)
28     foo();
29 #pragma omp target parallel for[ // expected-warning {{extra tokens at the end of '#pragma omp target parallel for' are ignored}}
30   for (int i = 0; i < argc; ++i)
31     foo();
32 #pragma omp target parallel for] // expected-warning {{extra tokens at the end of '#pragma omp target parallel for' are ignored}}
33   for (int i = 0; i < argc; ++i)
34     foo();
35 #pragma omp target parallel for) // expected-warning {{extra tokens at the end of '#pragma omp target parallel for' are ignored}}
36   for (int i = 0; i < argc; ++i)
37     foo();
38 #pragma omp target parallel for } // expected-warning {{extra tokens at the end of '#pragma omp target parallel for' are ignored}}
39   for (int i = 0; i < argc; ++i)
40     foo();
41 #pragma omp target parallel for
42   for (int i = 0; i < argc; ++i)
43     foo();
44 // expected-warning@+1 {{extra tokens at the end of '#pragma omp target parallel for' are ignored}}
45 #pragma omp target parallel for unknown()
46   for (int i = 0; i < argc; ++i)
47     foo();
48 L1:
49   for (int i = 0; i < argc; ++i)
50     foo();
51 #pragma omp target parallel for
52   for (int i = 0; i < argc; ++i)
53     foo();
54 #pragma omp target parallel for
55   for (int i = 0; i < argc; ++i) {
56     goto L1; // expected-error {{use of undeclared label 'L1'}}
57     argc++;
58   }
59 
60   for (int i = 0; i < 10; ++i) {
61     switch (argc) {
62     case (0):
63 #pragma omp target parallel for
64       for (int i = 0; i < argc; ++i) {
65         foo();
66         break; // expected-error {{'break' statement cannot be used in OpenMP for loop}}
67         continue;
68       }
69     default:
70       break;
71     }
72   }
73 #pragma omp target parallel for default(none) // expected-note {{explicit data sharing attribute requested here}}
74   for (int i = 0; i < 10; ++i)
75     ++argc; // expected-error {{variable 'argc' must have explicitly specified data sharing attributes}}
76 
77   goto L2; // expected-error {{use of undeclared label 'L2'}}
78 #pragma omp target parallel for
79   for (int i = 0; i < argc; ++i)
80   L2:
81   foo();
82 #pragma omp target parallel for
83   for (int i = 0; i < argc; ++i) {
84     return 1; // expected-error {{cannot return from OpenMP region}}
85   }
86 
87   [[]] // expected-error {{an attribute list cannot appear here}}
88 #pragma omp target parallel for
89       for (int n = 0; n < 100; ++n) {
90   }
91 
92 #pragma omp target parallel for copyin(pvt) // expected-error {{unexpected OpenMP clause 'copyin' in directive '#pragma omp target parallel for'}}
93   for (int n = 0; n < 100; ++n) {}
94 
95   return 0;
96 }
97 
test_ordered()98 void test_ordered() {
99 #pragma omp target parallel for ordered ordered // expected-error {{directive '#pragma omp target parallel for' cannot contain more than one 'ordered' clause}}
100   for (int i = 0; i < 16; ++i)
101     ;
102 #pragma omp target parallel for order // omp45-error {{unexpected OpenMP clause 'order' in directive '#pragma omp target parallel for'}} expected-error {{expected '(' after 'order'}}
103   for (int i = 0; i < 10; ++i)
104     ;
105 #pragma omp target parallel for order( // omp45-error {{unexpected OpenMP clause 'order' in directive '#pragma omp target parallel for'}} expected-error {{expected ')'}} expected-note {{to match this '('}} omp50-error {{expected 'concurrent' in OpenMP clause 'order'}}
106   for (int i = 0; i < 10; ++i)
107     ;
108 #pragma omp target parallel for order(none // omp45-error {{unexpected OpenMP clause 'order' in directive '#pragma omp target parallel for'}} expected-error {{expected ')'}} expected-note {{to match this '('}} omp50-error {{expected 'concurrent' in OpenMP clause 'order'}}
109   for (int i = 0; i < 10; ++i)
110     ;
111 #pragma omp target parallel for order(concurrent // omp45-error {{unexpected OpenMP clause 'order' in directive '#pragma omp target parallel for'}} expected-error {{expected ')'}} expected-note {{to match this '('}}
112   for (int i = 0; i < 10; ++i)
113     ;
114 #pragma omp target parallel for order(concurrent) // omp45-error {{unexpected OpenMP clause 'order' in directive '#pragma omp target parallel for'}}
115   for (int i = 0; i < 10; ++i)
116     ;
117 }
118 
119