blob: 9ab4bccfc984900d55b3b3494942783c03ea0833 [file] [log] [blame]
Alexey Bataevdb390212015-05-20 04:24:19 +00001// RUN: %clang_cc1 -verify -fopenmp -ferror-limit 100 -std=c++11 -o - %s
Alexey Bataev4acb8592014-07-07 13:01:15 +00002
Alexey Bataeva8a9153a2017-12-29 18:07:07 +00003// RUN: %clang_cc1 -verify -fopenmp-simd -ferror-limit 100 -std=c++11 -o - %s
4
Alexey Bataev4acb8592014-07-07 13:01:15 +00005void foo() {
6}
7
8#pragma omp parallel for // expected-error {{unexpected OpenMP directive '#pragma omp parallel for'}}
9
10int main(int argc, char **argv) {
Alexey Bataev4c904ad2014-07-21 02:45:36 +000011#pragma omp parallel for { // expected-warning {{extra tokens at the end of '#pragma omp parallel for' are ignored}}
12 for (int i = 0; i < argc; ++i)
13 foo();
14#pragma omp parallel for ( // expected-warning {{extra tokens at the end of '#pragma omp parallel for' are ignored}}
15 for (int i = 0; i < argc; ++i)
16 foo();
17#pragma omp parallel for[ // expected-warning {{extra tokens at the end of '#pragma omp parallel for' are ignored}}
18 for (int i = 0; i < argc; ++i)
19 foo();
20#pragma omp parallel for] // expected-warning {{extra tokens at the end of '#pragma omp parallel for' are ignored}}
21 for (int i = 0; i < argc; ++i)
22 foo();
23#pragma omp parallel for) // expected-warning {{extra tokens at the end of '#pragma omp parallel for' are ignored}}
24 for (int i = 0; i < argc; ++i)
25 foo();
26#pragma omp parallel for } // expected-warning {{extra tokens at the end of '#pragma omp parallel for' are ignored}}
27 for (int i = 0; i < argc; ++i)
28 foo();
29#pragma omp parallel for
30 for (int i = 0; i < argc; ++i)
31 foo();
32// expected-warning@+1 {{extra tokens at the end of '#pragma omp parallel for' are ignored}}
33#pragma omp parallel for unknown()
34 for (int i = 0; i < argc; ++i)
35 foo();
36L1:
37 for (int i = 0; i < argc; ++i)
38 foo();
39#pragma omp parallel for
40 for (int i = 0; i < argc; ++i)
41 foo();
42#pragma omp parallel for
43 for (int i = 0; i < argc; ++i) {
Alexey Bataev4acb8592014-07-07 13:01:15 +000044 goto L1; // expected-error {{use of undeclared label 'L1'}}
45 argc++;
46 }
47
48 for (int i = 0; i < 10; ++i) {
Alexey Bataev4c904ad2014-07-21 02:45:36 +000049 switch (argc) {
50 case (0):
51#pragma omp parallel for
52 for (int i = 0; i < argc; ++i) {
Alexey Bataev4acb8592014-07-07 13:01:15 +000053 foo();
54 break; // expected-error {{'break' statement cannot be used in OpenMP for loop}}
55 continue;
56 }
Alexey Bataev4c904ad2014-07-21 02:45:36 +000057 default:
58 break;
Alexey Bataev4acb8592014-07-07 13:01:15 +000059 }
60 }
Alexey Bataev4c904ad2014-07-21 02:45:36 +000061#pragma omp parallel for default(none)
Alexey Bataev4acb8592014-07-07 13:01:15 +000062 for (int i = 0; i < 10; ++i)
Alexey Bataev4c904ad2014-07-21 02:45:36 +000063 ++argc; // expected-error {{variable 'argc' must have explicitly specified data sharing attributes}}
Alexey Bataev4acb8592014-07-07 13:01:15 +000064
65 goto L2; // expected-error {{use of undeclared label 'L2'}}
Alexey Bataev4c904ad2014-07-21 02:45:36 +000066#pragma omp parallel for
67 for (int i = 0; i < argc; ++i)
68 L2:
69 foo();
70#pragma omp parallel for
71 for (int i = 0; i < argc; ++i) {
Alexey Bataev4acb8592014-07-07 13:01:15 +000072 return 1; // expected-error {{cannot return from OpenMP region}}
73 }
74
75 [[]] // expected-error {{an attribute list cannot appear here}}
Alexey Bataev4c904ad2014-07-21 02:45:36 +000076#pragma omp parallel for
77 for (int n = 0; n < 100; ++n) {
78 }
Alexey Bataev4acb8592014-07-07 13:01:15 +000079
80 return 0;
81}
82
Alexey Bataev4c904ad2014-07-21 02:45:36 +000083void test_ordered() {
84#pragma omp parallel for ordered ordered // expected-error {{directive '#pragma omp parallel for' cannot contain more than one 'ordered' clause}}
85 for (int i = 0; i < 16; ++i)
86 ;
87}
88