Alexey Bataev | a914888 | 2019-07-08 15:45:24 +0000 | [diff] [blame] | 1 | // RUN: %clang_cc1 -verify -fopenmp -ferror-limit 100 -std=c++11 -o - %s -Wuninitialized |
Alexey Bataev | 758e55e | 2013-09-06 18:03:48 +0000 | [diff] [blame] | 2 | |
Alexey Bataev | a914888 | 2019-07-08 15:45:24 +0000 | [diff] [blame] | 3 | // RUN: %clang_cc1 -verify -fopenmp-simd -ferror-limit 100 -std=c++11 -o - %s -Wuninitialized |
Alexey Bataev | a8a9153a | 2017-12-29 18:07:07 +0000 | [diff] [blame] | 4 | |
Alexey Bataev | 758e55e | 2013-09-06 18:03:48 +0000 | [diff] [blame] | 5 | void foo() { |
| 6 | } |
| 7 | |
Alexey Bataev | c2c21ef | 2019-07-11 14:54:17 +0000 | [diff] [blame^] | 8 | void xxx(int argc) { |
| 9 | int x; // expected-note {{initialize the variable 'x' to silence this warning}} |
| 10 | #pragma omp parallel |
| 11 | argc = x; // expected-warning {{variable 'x' is uninitialized when used here}} |
| 12 | } |
| 13 | |
Alexey Bataev | 758e55e | 2013-09-06 18:03:48 +0000 | [diff] [blame] | 14 | #pragma omp parallel // expected-error {{unexpected OpenMP directive '#pragma omp parallel'}} |
| 15 | |
Alexey Bataev | 41ebe0c | 2019-05-09 18:14:57 +0000 | [diff] [blame] | 16 | int a; |
Alexey Bataev | 4bcad7f | 2016-02-10 10:50:12 +0000 | [diff] [blame] | 17 | struct S; |
| 18 | S& bar(); |
Alexey Bataev | 758e55e | 2013-09-06 18:03:48 +0000 | [diff] [blame] | 19 | int main(int argc, char **argv) { |
Alexey Bataev | 4bcad7f | 2016-02-10 10:50:12 +0000 | [diff] [blame] | 20 | S &s = bar(); |
| 21 | #pragma omp parallel |
| 22 | (void)&s; |
Alp Toker | b14a470 | 2013-12-18 19:10:54 +0000 | [diff] [blame] | 23 | #pragma omp parallel { // expected-warning {{extra tokens at the end of '#pragma omp parallel' are ignored}} |
| 24 | foo(); |
| 25 | #pragma omp parallel ( // expected-warning {{extra tokens at the end of '#pragma omp parallel' are ignored}} |
| 26 | foo(); |
| 27 | #pragma omp parallel [ // expected-warning {{extra tokens at the end of '#pragma omp parallel' are ignored}} |
| 28 | foo(); |
| 29 | #pragma omp parallel ] // expected-warning {{extra tokens at the end of '#pragma omp parallel' are ignored}} |
| 30 | foo(); |
| 31 | #pragma omp parallel ) // expected-warning {{extra tokens at the end of '#pragma omp parallel' are ignored}} |
| 32 | foo(); |
| 33 | #pragma omp parallel } // expected-warning {{extra tokens at the end of '#pragma omp parallel' are ignored}} |
| 34 | foo(); |
Alexey Bataev | 758e55e | 2013-09-06 18:03:48 +0000 | [diff] [blame] | 35 | #pragma omp parallel |
Alp Toker | 1d8362c | 2013-12-18 22:34:19 +0000 | [diff] [blame] | 36 | // expected-warning@+1 {{extra tokens at the end of '#pragma omp parallel' are ignored}} |
| 37 | #pragma omp parallel unknown() |
Alexey Bataev | 758e55e | 2013-09-06 18:03:48 +0000 | [diff] [blame] | 38 | foo(); |
| 39 | L1: |
| 40 | foo(); |
Alexey Bataev | f3c832a | 2018-01-09 19:21:04 +0000 | [diff] [blame] | 41 | #pragma omp parallel ordered // expected-error {{unexpected OpenMP clause 'ordered' in directive '#pragma omp parallel'}} |
| 42 | ; |
Alexey Bataev | 758e55e | 2013-09-06 18:03:48 +0000 | [diff] [blame] | 43 | #pragma omp parallel |
| 44 | ; |
| 45 | #pragma omp parallel |
| 46 | { |
| 47 | goto L1; // expected-error {{use of undeclared label 'L1'}} |
| 48 | argc++; |
| 49 | } |
| 50 | |
| 51 | for (int i = 0; i < 10; ++i) { |
| 52 | switch(argc) { |
| 53 | case (0): |
| 54 | #pragma omp parallel |
| 55 | { |
| 56 | foo(); |
| 57 | break; // expected-error {{'break' statement not in loop or switch statement}} |
| 58 | continue; // expected-error {{'continue' statement not in loop statement}} |
| 59 | } |
| 60 | default: |
| 61 | break; |
| 62 | } |
| 63 | } |
Alexey Bataev | 41ebe0c | 2019-05-09 18:14:57 +0000 | [diff] [blame] | 64 | #pragma omp parallel default(none) // expected-note 2 {{explicit data sharing attribute requested here}} |
| 65 | { |
| 66 | ++argc; // expected-error {{variable 'argc' must have explicitly specified data sharing attributes}} |
| 67 | ++a; // expected-error {{variable 'a' must have explicitly specified data sharing attributes}} |
| 68 | } |
Alexey Bataev | 758e55e | 2013-09-06 18:03:48 +0000 | [diff] [blame] | 69 | |
| 70 | goto L2; // expected-error {{use of undeclared label 'L2'}} |
| 71 | #pragma omp parallel |
| 72 | L2: |
| 73 | foo(); |
| 74 | #pragma omp parallel |
| 75 | { |
| 76 | return 1; // expected-error {{cannot return from OpenMP region}} |
| 77 | } |
| 78 | |
Richard Smith | 12a41bd | 2013-09-16 21:17:44 +0000 | [diff] [blame] | 79 | [[]] // expected-error {{an attribute list cannot appear here}} |
| 80 | #pragma omp parallel |
| 81 | for (int n = 0; n < 100; ++n) {} |
| 82 | |
Alexey Bataev | 758e55e | 2013-09-06 18:03:48 +0000 | [diff] [blame] | 83 | return 0; |
| 84 | } |
| 85 | |
Alexey Bataev | 41ebe0c | 2019-05-09 18:14:57 +0000 | [diff] [blame] | 86 | struct a { |
| 87 | static constexpr int b = 0; |
| 88 | }; |
| 89 | template <bool> struct c; |
| 90 | template <typename d, typename e> bool operator<(d, e); |
| 91 | struct f { |
| 92 | int cbegin; |
| 93 | }; |
| 94 | class g { |
| 95 | f blocks; |
| 96 | void j(); |
| 97 | }; |
| 98 | template <typename> struct is_error_code_enum : a {}; |
| 99 | struct h { |
| 100 | template <typename i, typename = c<is_error_code_enum<i>::b>> h(i); |
| 101 | }; |
| 102 | h operator<(h, h); |
| 103 | void g::j() { |
Alexey Bataev | 412254a | 2019-05-09 18:44:53 +0000 | [diff] [blame] | 104 | #pragma omp parallel for default(none) if(a::b) |
Alexey Bataev | 41ebe0c | 2019-05-09 18:14:57 +0000 | [diff] [blame] | 105 | for (auto a = blocks.cbegin; a < blocks; ++a) // expected-error {{invalid operands to binary expression ('f' and 'int')}} |
| 106 | ; |
| 107 | } |