xref: /llvm-project/clang/test/OpenMP/taskgroup_messages.cpp (revision 410f09af09b9261f51663773bee01ec7b37e8fd4)
1 // RUN: %clang_cc1 -verify -fopenmp %s -Wuninitialized
2 
3 // RUN: %clang_cc1 -verify -fopenmp-simd %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 taskgroup
8   argc = x; // expected-warning {{variable 'x' is uninitialized when used here}}
9 }
10 
11 int foo();
12 
main()13 int main() {
14   #pragma omp taskgroup
15   ;
16   #pragma omp taskgroup unknown // expected-warning {{extra tokens at the end of '#pragma omp taskgroup' are ignored}}
17   foo();
18   {
19     #pragma omp taskgroup
20   } // expected-error {{expected statement}}
21   #pragma omp taskgroup
22   #pragma omp taskgroup
23   for (int i = 0; i < 10; ++i) {
24     foo();
25     #pragma omp parallel
26     #pragma omp for
27     for (int j = 0; j < 10; j++) {
28       foo();
29       #pragma omp taskgroup
30       foo();
31     }
32   }
33   #pragma omp taskgroup
34   #pragma omp taskgroup
35   for (int i = 0; i < 10; ++i) {
36     foo();
37     #pragma omp parallel
38     #pragma omp for
39     for (int j = 0; j < 10; j++) {
40       #pragma omp taskgroup
41       foo();
42     }
43   }
44   #pragma omp taskgroup
45   #pragma omp taskgroup
46   for (int i = 0; i < 10; ++i) {
47     foo();
48     #pragma omp parallel
49     #pragma omp for
50     for (int j = 0; j < 10; j++) {
51       #pragma omp taskgroup
52       foo();
53     }
54   }
55 
56   return 0;
57 }
58 
foo()59 int foo() {
60   L1:
61     foo();
62   #pragma omp taskgroup
63   {
64     foo();
65     goto L1; // expected-error {{use of undeclared label 'L1'}}
66   }
67   goto L2; // expected-error {{use of undeclared label 'L2'}}
68   #pragma omp taskgroup
69   {
70     L2:
71     foo();
72   }
73 
74 #pragma omp taskgroup initi // expected-warning {{extra tokens at the end of '#pragma omp taskgroup' are ignored}}
75   ;
76   return 0;
77 }
78