99 lines · cpp
1// RUN: %clang_cc1 -verify=expected,omp45 -fopenmp-version=45 -fopenmp -std=c++11 -o - %s -Wuninitialized2// RUN: %clang_cc1 -verify -fopenmp -std=c++11 -o - %s -Wuninitialized3 4// RUN: %clang_cc1 -verify=expected,omp45 -fopenmp-version=45 -fopenmp-simd -std=c++11 -o - %s -Wuninitialized5// RUN: %clang_cc1 -verify -fopenmp-simd -std=c++11 -o - %s -Wuninitialized6 7void xxx(int argc) {8 int x; // expected-note {{initialize the variable 'x' to silence this warning}}9#pragma omp target10#pragma omp teams11 argc = x; // expected-warning {{variable 'x' is uninitialized when used here}}12}13 14void foo() {15}16 17#pragma omp teams // expected-error {{unexpected OpenMP directive '#pragma omp teams'}}18 19int main(int argc, char **argv) {20 #pragma omp teams // omp45-error {{orphaned 'omp teams' directives are prohibited; perhaps you forget to enclose the directive into a target region?}}21 ;22 #pragma omp target23 #pragma omp teams24 f; // expected-error {{use of undeclared identifier 'f'}}25 #pragma omp target26 #pragma omp teams { // expected-warning {{extra tokens at the end of '#pragma omp teams' are ignored}}27 foo();28 #pragma omp target29 #pragma omp teams ( // expected-warning {{extra tokens at the end of '#pragma omp teams' are ignored}}30 foo();31 #pragma omp target32 #pragma omp teams [ // expected-warning {{extra tokens at the end of '#pragma omp teams' are ignored}}33 foo();34 #pragma omp target35 #pragma omp teams ] // expected-warning {{extra tokens at the end of '#pragma omp teams' are ignored}}36 foo();37 #pragma omp target38 #pragma omp teams ) // expected-warning {{extra tokens at the end of '#pragma omp teams' are ignored}}39 foo();40 #pragma omp target41 #pragma omp teams } // expected-warning {{extra tokens at the end of '#pragma omp teams' are ignored}}42 foo();43 #pragma omp target44 #pragma omp teams45 foo();46 // expected-warning@+2 {{extra tokens at the end of '#pragma omp teams' are ignored}}47 #pragma omp target48 #pragma omp teams unknown()49 foo();50 L1:51 foo();52 #pragma omp target53 #pragma omp teams54 ;55 #pragma omp target56 #pragma omp teams57 {58 goto L1; // expected-error {{use of undeclared label 'L1'}}59 argc++;60 }61 62 for (int i = 0; i < 10; ++i) {63 switch(argc) {64 case (0):65 #pragma omp target66 #pragma omp teams67 {68 foo();69 break; // expected-error {{'break' statement not in loop or switch statement}}70 continue; // expected-error {{'continue' statement not in loop statement}}71 }72 default:73 break;74 }75 }76 #pragma omp target77 #pragma omp teams default(none) // expected-note {{explicit data sharing attribute requested here}}78 ++argc; // expected-error {{variable 'argc' must have explicitly specified data sharing attributes}}79 80 goto L2; // expected-error {{use of undeclared label 'L2'}}81 #pragma omp target82 #pragma omp teams83 L2:84 foo();85 #pragma omp target86 #pragma omp teams87 {88 return 1; // expected-error {{cannot return from OpenMP region}}89 }90 91 [[]] // expected-error {{an attribute list cannot appear here}}92 #pragma omp target93 #pragma omp teams94 for (int n = 0; n < 100; ++n) {}95 96 return 0;97}98 99