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
xxx(int argc)5 void xxx(int argc) {
6 int x; // expected-note {{initialize the variable 'x' to silence this warning}}
7 #pragma omp target teams
8 argc = x; // expected-warning {{variable 'x' is uninitialized when used here}}
9 }
10
foo()11 void foo() {
12 }
13
14 #pragma omp target teams // expected-error {{unexpected OpenMP directive '#pragma omp target teams'}}
15
main(int argc,char ** argv)16 int main(int argc, char **argv) {
17 #pragma omp target teams { // expected-warning {{extra tokens at the end of '#pragma omp target teams' are ignored}}
18 foo();
19 #pragma omp target teams ( // expected-warning {{extra tokens at the end of '#pragma omp target teams' are ignored}}
20 foo();
21 #pragma omp target teams [ // expected-warning {{extra tokens at the end of '#pragma omp target teams' are ignored}}
22 foo();
23 #pragma omp target teams ] // expected-warning {{extra tokens at the end of '#pragma omp target teams' are ignored}}
24 foo();
25 #pragma omp target teams ) // expected-warning {{extra tokens at the end of '#pragma omp target teams' are ignored}}
26 foo();
27 #pragma omp target teams } // expected-warning {{extra tokens at the end of '#pragma omp target teams' are ignored}}
28 foo();
29 #pragma omp target teams
30 foo();
31 #pragma omp target teams unknown() // expected-warning {{extra tokens at the end of '#pragma omp target teams' are ignored}}
32 foo();
33 L1:
34 foo();
35 #pragma omp target teams
36 ;
37 #pragma omp target teams
38 {
39 goto L1; // expected-error {{use of undeclared label 'L1'}}
40 argc++;
41 }
42
43 for (int i = 0; i < 10; ++i) {
44 switch(argc) {
45 case (0):
46 #pragma omp target teams
47 {
48 foo();
49 break; // expected-error {{'break' statement not in loop or switch statement}}
50 continue; // expected-error {{'continue' statement not in loop statement}}
51 }
52 default:
53 break;
54 }
55 }
56 #pragma omp target teams default(none) // expected-note {{explicit data sharing attribute requested here}}
57 ++argc; // expected-error {{variable 'argc' must have explicitly specified data sharing attributes}}
58
59 #pragma omp target teams default(none) // expected-note {{explicit data sharing attribute requested here}}
60 #pragma omp parallel num_threads(argc) // expected-error {{variable 'argc' must have explicitly specified data sharing attributes}}
61 ;
62
63 #pragma omp target teams default(none) // expected-note {{explicit data sharing attribute requested here}}
64 {
65 #pragma omp parallel num_threads(argc) // expected-error {{variable 'argc' must have explicitly specified data sharing attributes}}
66 ;
67 }
68
69 goto L2; // expected-error {{use of undeclared label 'L2'}}
70 #pragma omp target teams
71 L2:
72 foo();
73 #pragma omp target teams
74 {
75 return 1; // expected-error {{cannot return from OpenMP region}}
76 }
77
78 [[]] // expected-error {{an attribute list cannot appear here}}
79 #pragma omp target teams
80 for (int n = 0; n < 100; ++n) {}
81
82 return 0;
83 }
84