1 // RUN: %clang_cc1 -verify -fopenmp -std=c++11 -o - %s -Wuninitialized
2 
3 // RUN: %clang_cc1 -verify -fopenmp-simd -std=c++11 -o - %s -Wuninitialized
4 
5 void xxx(int argc) {
6   int x; // expected-note {{initialize the variable 'x' to silence this warning}}
7 #pragma omp target
8 #pragma omp teams
9   argc = x; // expected-warning {{variable 'x' is uninitialized when used here}}
10 }
11 
12 void foo() {
13 }
14 
15 #pragma omp teams // expected-error {{unexpected OpenMP directive '#pragma omp teams'}}
16 
17 int main(int argc, char **argv) {
18   #pragma omp target
19   #pragma omp teams
20   f; // expected-error {{use of undeclared identifier 'f'}}
21   #pragma omp target
22   #pragma omp teams { // expected-warning {{extra tokens at the end of '#pragma omp teams' are ignored}}
23   foo();
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
41   foo();
42   // expected-warning@+2 {{extra tokens at the end of '#pragma omp teams' are ignored}}
43   #pragma omp target
44   #pragma omp teams unknown()
45   foo();
46   L1:
47     foo();
48   #pragma omp target
49   #pragma omp teams
50   ;
51   #pragma omp target
52   #pragma omp teams
53   {
54     goto L1; // expected-error {{use of undeclared label 'L1'}}
55     argc++;
56   }
57 
58   for (int i = 0; i < 10; ++i) {
59     switch(argc) {
60      case (0):
61       #pragma omp target
62       #pragma omp teams
63       {
64         foo();
65         break; // expected-error {{'break' statement not in loop or switch statement}}
66         continue; // expected-error {{'continue' statement not in loop statement}}
67       }
68       default:
69        break;
70     }
71   }
72   #pragma omp target
73   #pragma omp teams default(none) // expected-note {{explicit data sharing attribute requested here}}
74   ++argc; // expected-error {{variable 'argc' must have explicitly specified data sharing attributes}}
75 
76   goto L2; // expected-error {{use of undeclared label 'L2'}}
77   #pragma omp target
78   #pragma omp teams
79   L2:
80   foo();
81   #pragma omp target
82   #pragma omp teams
83   {
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
89   #pragma omp teams
90   for (int n = 0; n < 100; ++n) {}
91 
92   return 0;
93 }
94 
95