blob: 06182802d7a986418d742b4d7c82facc2883d59b [file] [log] [blame]
Alexey Bataeva9148882019-07-08 15:45:24 +00001// RUN: %clang_cc1 -verify -fopenmp -ferror-limit 100 -std=c++11 -o - %s -Wuninitialized
Alexey Bataev84d0b3e2014-07-08 08:12:03 +00002
Alexey Bataeva9148882019-07-08 15:45:24 +00003// RUN: %clang_cc1 -verify -fopenmp-simd -ferror-limit 100 -std=c++11 -o - %s -Wuninitialized
Alexey Bataeva8a9153a2017-12-29 18:07:07 +00004
Alexey Bataevc2c21ef2019-07-11 14:54:17 +00005void xxx(int argc) {
6 int x; // expected-note {{initialize the variable 'x' to silence this warning}}
7#pragma omp parallel sections
8{
9 argc = x; // expected-warning {{variable 'x' is uninitialized when used here}}
10}
11}
12
Alexey Bataev84d0b3e2014-07-08 08:12:03 +000013void foo() {
14}
15
16#pragma omp parallel sections // expected-error {{unexpected OpenMP directive '#pragma omp parallel sections'}}
17
18int main(int argc, char **argv) {
19#pragma omp parallel sections {// expected-warning {{extra tokens at the end of '#pragma omp parallel sections' are ignored}}
20 {
21 foo();
22 }
23#pragma omp parallel sections( // expected-warning {{extra tokens at the end of '#pragma omp parallel sections' are ignored}}
24 {
25 foo();
26 }
27#pragma omp parallel sections[ // expected-warning {{extra tokens at the end of '#pragma omp parallel sections' are ignored}}
28 {
29 foo();
30 }
31#pragma omp parallel sections] // expected-warning {{extra tokens at the end of '#pragma omp parallel sections' are ignored}}
32 {
33 foo();
34 }
35#pragma omp parallel sections) // expected-warning {{extra tokens at the end of '#pragma omp parallel sections' are ignored}}
36 {
37 foo();
38 }
39#pragma omp parallel sections } // expected-warning {{extra tokens at the end of '#pragma omp parallel sections' are ignored}}
40 {
41 foo();
42 }
43// expected-warning@+1 {{extra tokens at the end of '#pragma omp parallel sections' are ignored}}
44#pragma omp parallel sections unknown()
45 {
46 foo();
47#pragma omp section
48 L1:
49 foo();
50 }
51#pragma omp parallel sections
52 {
53 ;
54 }
55#pragma omp parallel sections
56 {
57 goto L1; // expected-error {{use of undeclared label 'L1'}}
58 }
59
60 for (int i = 0; i < 10; ++i) {
61 switch (argc) {
62 case (0):
63#pragma omp parallel sections
64 {
65 foo();
66 break; // expected-error {{'break' statement not in loop or switch statement}}
67 continue; // expected-error {{'continue' statement not in loop statement}}
68 }
69 default:
70 break;
71 }
72 }
Alexey Bataev41ebe0c2019-05-09 18:14:57 +000073#pragma omp parallel sections default(none) // expected-note {{explicit data sharing attribute requested here}}
Alexey Bataev84d0b3e2014-07-08 08:12:03 +000074 {
75 ++argc; // expected-error {{variable 'argc' must have explicitly specified data sharing attributes}}
76 }
77
78 goto L2; // expected-error {{use of undeclared label 'L2'}}
79#pragma omp parallel sections
80 {
81 L2:
82 foo();
83 }
84#pragma omp parallel sections
85 {
86 return 1; // expected-error {{cannot return from OpenMP region}}
87 }
88
89 [[]] // expected-error {{an attribute list cannot appear here}}
90#pragma omp parallel sections
91 {
92 }
93
94 return 0;
95}