1 // RUN: %clang_cc1 -verify=expected,omp45 -fopenmp -std=c++11 -o - %s -Wuninitialized
2 // RUN: %clang_cc1 -verify -fopenmp -fopenmp-version=50 -std=c++11 -o - %s -Wuninitialized
3 
4 // RUN: %clang_cc1 -verify=expected,omp45 -fopenmp-simd -std=c++11 -o - %s -Wuninitialized
5 
6 void xxx(int argc) {
7   int x; // expected-note {{initialize the variable 'x' to silence this warning}}
8 #pragma omp target
9 #pragma omp teams
10   argc = x; // expected-warning {{variable 'x' is uninitialized when used here}}
11 }
12 
13 void foo() {
14 }
15 
16 #pragma omp teams // expected-error {{unexpected OpenMP directive '#pragma omp teams'}}
17 
18 int main(int argc, char **argv) {
19   #pragma omp teams // omp45-error {{orphaned 'omp teams' directives are prohibited; perhaps you forget to enclose the directive into a target region?}}
20   ;
21   #pragma omp target
22   #pragma omp teams
23   f; // expected-error {{use of undeclared identifier 'f'}}
24   #pragma omp target
25   #pragma omp teams { // expected-warning {{extra tokens at the end of '#pragma omp teams' are ignored}}
26   foo();
27   #pragma omp target
28   #pragma omp teams ( // expected-warning {{extra tokens at the end of '#pragma omp teams' are ignored}}
29   foo();
30   #pragma omp target
31   #pragma omp teams [ // expected-warning {{extra tokens at the end of '#pragma omp teams' are ignored}}
32   foo();
33   #pragma omp target
34   #pragma omp teams ] // expected-warning {{extra tokens at the end of '#pragma omp teams' are ignored}}
35   foo();
36   #pragma omp target
37   #pragma omp teams ) // expected-warning {{extra tokens at the end of '#pragma omp teams' are ignored}}
38   foo();
39   #pragma omp target
40   #pragma omp teams } // expected-warning {{extra tokens at the end of '#pragma omp teams' are ignored}}
41   foo();
42   #pragma omp target
43   #pragma omp teams
44   foo();
45   // expected-warning@+2 {{extra tokens at the end of '#pragma omp teams' are ignored}}
46   #pragma omp target
47   #pragma omp teams unknown()
48   foo();
49   L1:
50     foo();
51   #pragma omp target
52   #pragma omp teams
53   ;
54   #pragma omp target
55   #pragma omp teams
56   {
57     goto L1; // expected-error {{use of undeclared label 'L1'}}
58     argc++;
59   }
60 
61   for (int i = 0; i < 10; ++i) {
62     switch(argc) {
63      case (0):
64       #pragma omp target
65       #pragma omp teams
66       {
67         foo();
68         break; // expected-error {{'break' statement not in loop or switch statement}}
69         continue; // expected-error {{'continue' statement not in loop statement}}
70       }
71       default:
72        break;
73     }
74   }
75   #pragma omp target
76   #pragma omp teams default(none) // expected-note {{explicit data sharing attribute requested here}}
77   ++argc; // expected-error {{variable 'argc' must have explicitly specified data sharing attributes}}
78 
79   goto L2; // expected-error {{use of undeclared label 'L2'}}
80   #pragma omp target
81   #pragma omp teams
82   L2:
83   foo();
84   #pragma omp target
85   #pragma omp teams
86   {
87     return 1; // expected-error {{cannot return from OpenMP region}}
88   }
89 
90   [[]] // expected-error {{an attribute list cannot appear here}}
91   #pragma omp target
92   #pragma omp teams
93   for (int n = 0; n < 100; ++n) {}
94 
95   return 0;
96 }
97 
98