Alexey Bataev | 1b59ab5 | 2014-02-27 08:29:12 +0000 | [diff] [blame^] | 1 | // RUN: %clang_cc1 -fsyntax-only -fopenmp -verify %s |
| 2 | |
| 3 | // expected-error@+1 {{unexpected OpenMP directive '#pragma omp simd'}} |
| 4 | #pragma omp simd |
| 5 | |
| 6 | // expected-error@+1 {{unexpected OpenMP directive '#pragma omp simd'}} |
| 7 | #pragma omp simd foo |
| 8 | |
| 9 | // expected-error@+1 {{unexpected OpenMP directive '#pragma omp simd'}} |
| 10 | #pragma omp simd safelen(4) |
| 11 | |
| 12 | void test_no_clause() |
| 13 | { |
| 14 | int i; |
| 15 | #pragma omp simd |
| 16 | for (i = 0; i < 16; ++i) ; |
| 17 | |
| 18 | // expected-error@+2 {{statement after '#pragma omp simd' must be a for loop}} |
| 19 | #pragma omp simd |
| 20 | ++i; |
| 21 | } |
| 22 | |
| 23 | void test_branch_protected_scope() |
| 24 | { |
| 25 | int i = 0; |
| 26 | L1: |
| 27 | ++i; |
| 28 | |
| 29 | int x[24]; |
| 30 | |
| 31 | #pragma omp simd |
| 32 | for (i = 0; i < 16; ++i) { |
| 33 | if (i == 5) |
| 34 | goto L1; // expected-error {{use of undeclared label 'L1'}} |
| 35 | else if (i == 6) |
| 36 | return; // expected-error {{cannot return from OpenMP region}} |
| 37 | else if (i == 7) |
| 38 | goto L2; |
| 39 | else if (i == 8) { |
| 40 | L2: |
| 41 | x[i]++; |
| 42 | } |
| 43 | } |
| 44 | |
| 45 | if (x[0] == 0) |
| 46 | goto L2; // expected-error {{use of undeclared label 'L2'}} |
| 47 | else if (x[1] == 1) |
| 48 | goto L1; |
| 49 | } |
| 50 | |
| 51 | void test_invalid_clause() |
| 52 | { |
| 53 | int i; |
| 54 | // expected-warning@+1 {{extra tokens at the end of '#pragma omp simd' are ignored}} |
| 55 | #pragma omp simd foo bar |
| 56 | for (i = 0; i < 16; ++i) ; |
| 57 | } |
| 58 | |
| 59 | void test_non_identifiers() |
| 60 | { |
| 61 | int i, x; |
| 62 | // expected-warning@+1 {{extra tokens at the end of '#pragma omp simd' are ignored}} |
| 63 | #pragma omp simd; |
| 64 | for (i = 0; i < 16; ++i) ; |
| 65 | // expected-error@+2 {{unexpected OpenMP clause 'firstprivate' in directive '#pragma omp simd'}} |
| 66 | // expected-warning@+1 {{extra tokens at the end of '#pragma omp simd' are ignored}} |
| 67 | #pragma omp simd firstprivate(x); |
| 68 | for (i = 0; i < 16; ++i) ; |
| 69 | // expected-warning@+1 {{extra tokens at the end of '#pragma omp simd' are ignored}} |
| 70 | #pragma omp simd , private(x); |
| 71 | for (i = 0; i < 16; ++i) ; |
| 72 | } |
| 73 | |