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 | 84d0b3e | 2014-07-08 08:12:03 +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 | c2c21ef | 2019-07-11 14:54:17 +0000 | [diff] [blame] | 5 | void 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 Bataev | 84d0b3e | 2014-07-08 08:12:03 +0000 | [diff] [blame] | 13 | void foo() { |
| 14 | } |
| 15 | |
| 16 | #pragma omp parallel sections // expected-error {{unexpected OpenMP directive '#pragma omp parallel sections'}} |
| 17 | |
| 18 | int 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 Bataev | 41ebe0c | 2019-05-09 18:14:57 +0000 | [diff] [blame] | 73 | #pragma omp parallel sections default(none) // expected-note {{explicit data sharing attribute requested here}} |
Alexey Bataev | 84d0b3e | 2014-07-08 08:12:03 +0000 | [diff] [blame] | 74 | { |
| 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 | } |