1 // RUN: %clang_cc1 -verify -fopenmp -std=c++11 -o - %s 2 // RUN: not %clang_cc1 -fopenmp -std=c++11 -fopenmp-targets=aaa-bbb-ccc-ddd -o - %s 2>&1 | FileCheck %s 3 4 // RUN: %clang_cc1 -verify -fopenmp-simd -std=c++11 -o - %s 5 // CHECK: error: OpenMP target is invalid: 'aaa-bbb-ccc-ddd' 6 // RUN: not %clang_cc1 -fopenmp -std=c++11 -triple nvptx64-nvidia-cuda -o - %s 2>&1 | FileCheck --check-prefix CHECK-UNSUPPORTED-HOST-TARGET %s 7 // RUN: not %clang_cc1 -fopenmp -std=c++11 -triple nvptx-nvidia-cuda -o - %s 2>&1 | FileCheck --check-prefix CHECK-UNSUPPORTED-HOST-TARGET %s 8 // CHECK-UNSUPPORTED-HOST-TARGET: error: The target '{{nvptx64-nvidia-cuda|nvptx-nvidia-cuda}}' is not a supported OpenMP host target. 9 // RUN: not %clang_cc1 -fopenmp -std=c++11 -fopenmp-targets=hexagon-linux-gnu -o - %s 2>&1 | FileCheck --check-prefix CHECK-UNSUPPORTED-DEVICE-TARGET %s 10 // CHECK-UNSUPPORTED-DEVICE-TARGET: OpenMP target is invalid: 'hexagon-linux-gnu' 11 12 void foo() { 13 } 14 15 #pragma omp target // expected-error {{unexpected OpenMP directive '#pragma omp target'}} 16 17 int main(int argc, char **argv) { 18 #pragma omp target { // expected-warning {{extra tokens at the end of '#pragma omp target' are ignored}} 19 foo(); 20 #pragma omp target ( // expected-warning {{extra tokens at the end of '#pragma omp target' are ignored}} 21 foo(); 22 #pragma omp target [ // expected-warning {{extra tokens at the end of '#pragma omp target' are ignored}} 23 foo(); 24 #pragma omp target ] // expected-warning {{extra tokens at the end of '#pragma omp target' are ignored}} 25 foo(); 26 #pragma omp target ) // expected-warning {{extra tokens at the end of '#pragma omp target' are ignored}} 27 foo(); 28 #pragma omp target } // expected-warning {{extra tokens at the end of '#pragma omp target' are ignored}} 29 foo(); 30 #pragma omp target 31 foo(); 32 // expected-warning@+1 {{extra tokens at the end of '#pragma omp target' are ignored}} 33 #pragma omp target unknown() 34 foo(); 35 L1: 36 foo(); 37 #pragma omp target 38 ; 39 #pragma omp target 40 { 41 goto L1; // expected-error {{use of undeclared label 'L1'}} 42 argc++; 43 } 44 45 for (int i = 0; i < 10; ++i) { 46 switch(argc) { 47 case (0): 48 #pragma omp target 49 { 50 foo(); 51 break; // expected-error {{'break' statement not in loop or switch statement}} 52 continue; // expected-error {{'continue' statement not in loop statement}} 53 } 54 default: 55 break; 56 } 57 } 58 59 goto L2; // expected-error {{use of undeclared label 'L2'}} 60 #pragma omp target 61 L2: 62 foo(); 63 #pragma omp target 64 { 65 return 1; // expected-error {{cannot return from OpenMP region}} 66 } 67 68 [[]] // expected-error {{an attribute list cannot appear here}} 69 #pragma omp target 70 for (int n = 0; n < 100; ++n) {} 71 72 return 0; 73 } 74 75