1 // RUN: %clang_cc1 -verify -fopenmp -ferror-limit 100 -std=c++11 -o - %s
2
foo()3 void foo() {
4 }
5
6 #pragma omp parallel for // expected-error {{unexpected OpenMP directive '#pragma omp parallel for'}}
7
main(int argc,char ** argv)8 int main(int argc, char **argv) {
9 #pragma omp parallel for { // expected-warning {{extra tokens at the end of '#pragma omp parallel for' are ignored}}
10 for (int i = 0; i < argc; ++i)
11 foo();
12 #pragma omp parallel for ( // expected-warning {{extra tokens at the end of '#pragma omp parallel for' are ignored}}
13 for (int i = 0; i < argc; ++i)
14 foo();
15 #pragma omp parallel for[ // expected-warning {{extra tokens at the end of '#pragma omp parallel for' are ignored}}
16 for (int i = 0; i < argc; ++i)
17 foo();
18 #pragma omp parallel for] // expected-warning {{extra tokens at the end of '#pragma omp parallel for' are ignored}}
19 for (int i = 0; i < argc; ++i)
20 foo();
21 #pragma omp parallel for) // expected-warning {{extra tokens at the end of '#pragma omp parallel for' are ignored}}
22 for (int i = 0; i < argc; ++i)
23 foo();
24 #pragma omp parallel for } // expected-warning {{extra tokens at the end of '#pragma omp parallel for' are ignored}}
25 for (int i = 0; i < argc; ++i)
26 foo();
27 #pragma omp parallel for
28 for (int i = 0; i < argc; ++i)
29 foo();
30 // expected-warning@+1 {{extra tokens at the end of '#pragma omp parallel for' are ignored}}
31 #pragma omp parallel for unknown()
32 for (int i = 0; i < argc; ++i)
33 foo();
34 L1:
35 for (int i = 0; i < argc; ++i)
36 foo();
37 #pragma omp parallel for
38 for (int i = 0; i < argc; ++i)
39 foo();
40 #pragma omp parallel for
41 for (int i = 0; i < argc; ++i) {
42 goto L1; // expected-error {{use of undeclared label 'L1'}}
43 argc++;
44 }
45
46 for (int i = 0; i < 10; ++i) {
47 switch (argc) {
48 case (0):
49 #pragma omp parallel for
50 for (int i = 0; i < argc; ++i) {
51 foo();
52 break; // expected-error {{'break' statement cannot be used in OpenMP for loop}}
53 continue;
54 }
55 default:
56 break;
57 }
58 }
59 #pragma omp parallel for default(none)
60 for (int i = 0; i < 10; ++i)
61 ++argc; // expected-error {{variable 'argc' must have explicitly specified data sharing attributes}}
62
63 goto L2; // expected-error {{use of undeclared label 'L2'}}
64 #pragma omp parallel for
65 for (int i = 0; i < argc; ++i)
66 L2:
67 foo();
68 #pragma omp parallel for
69 for (int i = 0; i < argc; ++i) {
70 return 1; // expected-error {{cannot return from OpenMP region}}
71 }
72
73 [[]] // expected-error {{an attribute list cannot appear here}}
74 #pragma omp parallel for
75 for (int n = 0; n < 100; ++n) {
76 }
77
78 return 0;
79 }
80
test_ordered()81 void test_ordered() {
82 #pragma omp parallel for ordered ordered // expected-error {{directive '#pragma omp parallel for' cannot contain more than one 'ordered' clause}}
83 for (int i = 0; i < 16; ++i)
84 ;
85 }
86
87