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