diff options
author | Kelvin Li <kkwli0@gmail.com> | 2016-12-09 03:24:30 +0000 |
---|---|---|
committer | Kelvin Li <kkwli0@gmail.com> | 2016-12-09 03:24:30 +0000 |
commit | 732bd78b4ae905a419386752920f3c20c63c9747 (patch) | |
tree | 124fc050734b4ccba36b5b95547f43e48ab7380a /test | |
parent | 5b900dbb1bfe204a552930b746dda0e7ba6cc0dd (diff) |
[OpenMP] Sema and parsing for 'teams distribute parallel for' pragma
This patch is to implement sema and parsing for 'teams distribute parallel for' pragma.
Differential Revision: https://reviews.llvm.org/D27345
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@289179 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test')
16 files changed, 3812 insertions, 0 deletions
diff --git a/test/OpenMP/nesting_of_regions.cpp b/test/OpenMP/nesting_of_regions.cpp index 82dca93175..1b96bd2228 100644 --- a/test/OpenMP/nesting_of_regions.cpp +++ b/test/OpenMP/nesting_of_regions.cpp @@ -179,6 +179,12 @@ void foo() { for (int i = 0; i < 10; ++i) ; } +#pragma omp parallel + { +#pragma omp teams distribute parallel for // expected-error {{region cannot be closely nested inside 'parallel' region; perhaps you forget to enclose 'omp teams distribute parallel for' directive into a target region?}} + for (int i = 0; i < 10; ++i) + ; + } // SIMD DIRECTIVE #pragma omp simd @@ -395,6 +401,12 @@ void foo() { for (int j = 0; j < 10; ++j) ; } +#pragma omp simd + for (int i = 0; i < 10; ++i) { +#pragma omp teams distribute parallel for // expected-error {{OpenMP constructs may not be nested inside a simd region}} + for (int j = 0; j < 10; ++j) + ; + } // FOR DIRECTIVE #pragma omp for @@ -624,6 +636,12 @@ void foo() { for (int j = 0; j < 10; ++j) ; } +#pragma omp for + for (int i = 0; i < 10; ++i) { +#pragma omp teams distribute parallel for // expected-error {{region cannot be closely nested inside 'for' region; perhaps you forget to enclose 'omp teams distribute parallel for' directive into a target region?}} + for (int j = 0; j < 10; ++j) + ; + } // FOR SIMD DIRECTIVE #pragma omp for simd @@ -841,6 +859,12 @@ void foo() { for (int j = 0; j < 10; ++j) ; } +#pragma omp for simd + for (int i = 0; i < 10; ++i) { +#pragma omp teams distribute parallel for // expected-error {{OpenMP constructs may not be nested inside a simd region}} + for (int j = 0; j < 10; ++j) + ; + } // SECTIONS DIRECTIVE #pragma omp sections @@ -1075,6 +1099,12 @@ void foo() { for (int i = 0; i < 10; ++i) ; } +#pragma omp sections + { +#pragma omp teams distribute parallel for // expected-error {{region cannot be closely nested inside 'sections' region; perhaps you forget to enclose 'omp teams distribute parallel for' directive into a target region?}} + for (int i = 0; i < 10; ++i) + ; + } // SECTION DIRECTIVE #pragma omp section // expected-error {{orphaned 'omp section' directives are prohibited, it must be closely nested to a sections region}} @@ -1370,6 +1400,13 @@ void foo() { for (int i = 0; i < 10; ++i) ; } +#pragma omp sections + { +#pragma omp section +#pragma omp teams distribute parallel for // expected-error {{region cannot be closely nested inside 'section' region; perhaps you forget to enclose 'omp teams distribute parallel for' directive into a target region?}} + for (int i = 0; i < 10; ++i) + ; + } // SINGLE DIRECTIVE #pragma omp single @@ -1590,6 +1627,12 @@ void foo() { for (int i = 0; i < 10; ++i) ; } +#pragma omp single + { +#pragma omp teams distribute parallel for // expected-error {{region cannot be closely nested inside 'single' region; perhaps you forget to enclose 'omp teams distribute parallel for' directive into a target region?}} + for (int i = 0; i < 10; ++i) + ; + } // MASTER DIRECTIVE #pragma omp master @@ -1810,6 +1853,12 @@ void foo() { for (int i = 0; i < 10; ++i) ; } +#pragma omp master + { +#pragma omp teams distribute parallel for // expected-error {{region cannot be closely nested inside 'master' region; perhaps you forget to enclose 'omp teams distribute parallel for' directive into a target region?}} + for (int i = 0; i < 10; ++i) + ; + } // CRITICAL DIRECTIVE #pragma omp critical @@ -2044,6 +2093,12 @@ void foo() { for (int i = 0; i < 10; ++i) ; } +#pragma omp critical + { +#pragma omp teams distribute parallel for // expected-error {{region cannot be closely nested inside 'critical' region; perhaps you forget to enclose 'omp teams distribute parallel for' directive into a target region?}} + for (int i = 0; i < 10; ++i) + ; + } // PARALLEL FOR DIRECTIVE #pragma omp parallel for @@ -2278,6 +2333,12 @@ void foo() { for (int j = 0; j < 10; ++j) ; } +#pragma omp parallel for + for (int i = 0; i < 10; ++i) { +#pragma omp teams distribute parallel for // expected-error {{region cannot be closely nested inside 'parallel for' region; perhaps you forget to enclose 'omp teams distribute parallel for' directive into a target region?}} + for (int j = 0; j < 10; ++j) + ; + } // PARALLEL FOR SIMD DIRECTIVE #pragma omp parallel for simd @@ -2513,6 +2574,12 @@ void foo() { for (int j = 0; j < 10; ++j) ; } +#pragma omp parallel for simd + for (int i = 0; i < 10; ++i) { +#pragma omp teams distribute parallel for // expected-error {{OpenMP constructs may not be nested inside a simd region}} + for (int j = 0; j < 10; ++j) + ; + } // PARALLEL SECTIONS DIRECTIVE #pragma omp parallel sections @@ -2736,6 +2803,12 @@ void foo() { for (int i = 0; i < 10; ++i) ; } +#pragma omp parallel sections + { +#pragma omp teams distribute parallel for // expected-error {{region cannot be closely nested inside 'parallel sections' region; perhaps you forget to enclose 'omp teams distribute parallel for' directive into a target region?}} + for (int i = 0; i < 10; ++i) + ; + } // TASK DIRECTIVE #pragma omp task @@ -2906,6 +2979,12 @@ void foo() { for (int i = 0; i < 10; ++i) ; } +#pragma omp task + { +#pragma omp teams distribute parallel for // expected-error {{region cannot be closely nested inside 'task' region; perhaps you forget to enclose 'omp teams distribute parallel for' directive into a target region?}} + for (int i = 0; i < 10; ++i) + ; + } // ORDERED DIRECTIVE #pragma omp ordered @@ -3147,6 +3226,12 @@ void foo() { for (int i = 0; i < 10; ++i) ; } +#pragma omp ordered + { +#pragma omp teams distribute parallel for // expected-error {{region cannot be closely nested inside 'ordered' region; perhaps you forget to enclose 'omp teams distribute parallel for' directive into a target region?}} + for (int i = 0; i < 10; ++i) + ; + } // ATOMIC DIRECTIVE #pragma omp atomic @@ -3424,6 +3509,14 @@ void foo() { for (int i = 0; i < 10; ++i) ; } +#pragma omp atomic + // expected-error@+2 {{the statement for 'atomic' must be an expression statement of form '++x;', '--x;', 'x++;', 'x--;', 'x binop= expr;', 'x = x binop expr' or 'x = expr binop x', where x is an l-value expression with scalar type}} + // expected-note@+1 {{expected an expression statement}} + { +#pragma omp teams distribute parallel for // expected-error {{OpenMP constructs may not be nested inside an atomic region}} + for (int i = 0; i < 10; ++i) + ; + } // TARGET DIRECTIVE #pragma omp target @@ -3610,6 +3703,12 @@ void foo() { for (int i = 0; i < 10; ++i) ; } +#pragma omp target + { +#pragma omp teams distribute parallel for // OK + for (int i = 0; i < 10; ++i) + ; + } // TARGET PARALLEL DIRECTIVE #pragma omp target parallel @@ -3790,6 +3889,12 @@ void foo() { for (int i = 0; i < 10; ++i) ; } +#pragma omp target parallel + { +#pragma omp teams distribute parallel for // expected-error {{region cannot be closely nested inside 'target parallel' region; perhaps you forget to enclose 'omp teams distribute parallel for' directive into a target region?}} + for (int i = 0; i < 10; ++i) + ; + } // TARGET PARALLEL FOR DIRECTIVE #pragma omp target parallel for @@ -4024,6 +4129,12 @@ void foo() { for (int j = 0; j < 10; ++j) ; } +#pragma omp target parallel for + for (int i = 0; i < 10; ++i) { +#pragma omp teams distribute parallel for // expected-error {{region cannot be closely nested inside 'target parallel for' region; perhaps you forget to enclose 'omp teams distribute parallel for' directive into a target region?}} + for (int j = 0; j < 10; ++j) + ; + } // TEAMS DIRECTIVE #pragma omp teams // expected-error {{orphaned 'omp teams' directives are prohibited; perhaps you forget to enclose the directive into a target region?}} @@ -4252,6 +4363,13 @@ void foo() { for (int i = 0; i < 10; ++i) ; } +#pragma omp target +#pragma omp teams + { +#pragma omp teams distribute parallel for // expected-error {{region cannot be closely nested inside 'teams' region; perhaps you forget to enclose 'omp teams distribute parallel for' directive into a target region?}} + for (int i = 0; i < 10; ++i) + ; + } // TASKLOOP DIRECTIVE #pragma omp taskloop @@ -4477,6 +4595,12 @@ void foo() { for (int j = 0; j < 10; ++j) ++a; } +#pragma omp taskloop + for (int i = 0; i < 10; ++i) { +#pragma omp teams distribute parallel for // expected-error {{region cannot be closely nested inside 'taskloop' region; perhaps you forget to enclose 'omp teams distribute parallel for' directive into a target region?}} + for (int j = 0; j < 10; ++j) + ++a; + } // DISTRIBUTE DIRECTIVE #pragma omp target @@ -4734,6 +4858,14 @@ void foo() { for (int j = 0; j < 10; ++j) ; } +#pragma omp target +#pragma omp teams +#pragma omp distribute + for (int i = 0; i < 10; ++i) { +#pragma omp teams distribute parallel for // expected-error {{region cannot be closely nested inside 'distribute' region; perhaps you forget to enclose 'omp teams distribute parallel for' directive into a target region?}} + for (int j = 0; j < 10; ++j) + ; + } // DISTRIBUTE PARALLEL FOR DIRECTIVE #pragma omp target @@ -4999,6 +5131,14 @@ void foo() { for (int i = 0; i < 10; ++i) ; } +#pragma omp target +#pragma omp teams +#pragma omp distribute parallel for + for (int i = 0; i < 10; ++i) { +#pragma omp teams distribute parallel for // expected-error {{region cannot be closely nested inside 'distribute parallel for' region; perhaps you forget to enclose 'omp teams distribute parallel for' directive into a target region?}} + for (int i = 0; i < 10; ++i) + ; + } // DISTRIBUTE PARALLEL FOR SIMD DIRECTIVE #pragma omp target @@ -5272,6 +5412,14 @@ void foo() { for (int i = 0; i < 10; ++i) ++a; } +#pragma omp target +#pragma omp teams +#pragma omp distribute parallel for simd + for (int i = 0; i < 10; ++i) { +#pragma omp teams distribute parallel for // expected-error {{OpenMP constructs may not be nested inside a simd region}} + for (int i = 0; i < 10; ++i) + ++a; + } // TARGET SIMD DIRECTIVE #pragma omp target simd @@ -5961,6 +6109,13 @@ void foo() { for (int i = 0; i < 10; ++i) ++a; } +#pragma omp target +#pragma omp teams distribute + for (int i = 0; i < 10; ++i) { +#pragma omp teams distribute parallel for // expected-error {{region cannot be closely nested inside 'teams distribute' region; perhaps you forget to enclose 'omp teams distribute parallel for' directive into a target region?}} + for (int i = 0; i < 10; ++i) + ++a; + } // TEAMS DISTRIBUTE SIMD DIRECTIVE #pragma omp teams distribute simd // expected-error {{orphaned 'omp teams distribute simd' directives are prohibited; perhaps you forget to enclose the directive into a target region?}} @@ -6203,6 +6358,13 @@ void foo() { for (int i = 0; i < 10; ++i) ++a; } +#pragma omp target +#pragma omp teams distribute simd + for (int i = 0; i < 10; ++i) { +#pragma omp teams distribute parallel for // expected-error {{OpenMP constructs may not be nested inside a simd region}} + for (int i = 0; i < 10; ++i) + ++a; + } // TEAMS DISTRIBUTE PARALLEL FOR SIMD DIRECTIVE #pragma omp teams distribute parallel for simd // expected-error {{orphaned 'omp teams distribute parallel for simd' directives are prohibited; perhaps you forget to enclose the directive into a target region?}} @@ -6445,6 +6607,262 @@ void foo() { for (int i = 0; i < 10; ++i) ++a; } +#pragma omp target +#pragma omp teams distribute parallel for simd + for (int i = 0; i < 10; ++i) { +#pragma omp teams distribute parallel for // expected-error {{OpenMP constructs may not be nested inside a simd region}} + for (int i = 0; i < 10; ++i) + ++a; + } + +// TEAMS DISTRIBUTE PARALLEL FOR DIRECTIVE +#pragma omp teams distribute parallel for // expected-error {{orphaned 'omp teams distribute parallel for' directives are prohibited; perhaps you forget to enclose the directive into a target region?}} + for (int i = 0; i < 10; ++i) + ; +#pragma omp target +#pragma omp teams distribute parallel for + for (int i = 0; i < 10; ++i) { +#pragma omp distribute parallel for simd // expected-error {{region cannot be closely nested inside 'teams distribute parallel for' region; perhaps you forget to enclose 'omp distribute parallel for simd' directive into a teams region?}} + for (int i = 0; i < 10; ++i) + ; + } +#pragma omp target +#pragma omp teams distribute parallel for + for (int i = 0; i < 10; ++i) { +#pragma omp distribute // expected-error {{region cannot be closely nested inside 'teams distribute parallel for' region; perhaps you forget to enclose 'omp distribute' directive into a teams region?}} + for (int i = 0; i < 10; ++i) + ; + } +#pragma omp target +#pragma omp teams distribute parallel for + for (int i = 0; i < 10; ++i) { +#pragma omp for // expected-error {{region cannot be closely nested inside 'teams distribute parallel for' region; perhaps you forget to enclose 'omp for' directive into a parallel region?}} + for (int i = 0; i < 10; ++i) + ; + } +#pragma omp target +#pragma omp teams distribute parallel for + for (int i = 0; i < 10; ++i) { +#pragma omp simd // OK + for (int i = 0; i < 10; ++i) + ; + } +#pragma omp target +#pragma omp teams distribute parallel for + for (int i = 0; i < 10; ++i) { +#pragma omp for simd // expected-error {{region cannot be closely nested inside 'teams distribute parallel for' region; perhaps you forget to enclose 'omp for simd' directive into a parallel region?}} + for (int i = 0; i < 10; ++i) + ; + } +#pragma omp target +#pragma omp teams distribute parallel for + for (int i = 0; i < 10; ++i) { +#pragma omp parallel // OK + for (int i = 0; i < 10; ++i) + ; + } +#pragma omp target +#pragma omp teams distribute parallel for + for (int i = 0; i < 10; ++i) { +#pragma omp sections // expected-error {{region cannot be closely nested inside 'teams distribute parallel for' region; perhaps you forget to enclose 'omp sections' directive into a parallel region?}} + { + bar(); + } + } +#pragma omp target +#pragma omp teams distribute parallel for + for (int i = 0; i < 10; ++i) { +#pragma omp section // expected-error {{'omp section' directive must be closely nested to a sections region, not a teams distribute parallel for region}} + { + bar(); + } + } +#pragma omp target +#pragma omp teams distribute parallel for + for (int i = 0; i < 10; ++i) { +#pragma omp single // expected-error {{region cannot be closely nested inside 'teams distribute parallel for' region; perhaps you forget to enclose 'omp single' directive into a parallel region?}} + { + bar(); + } + } +#pragma omp target +#pragma omp teams distribute parallel for + for (int i = 0; i < 10; ++i) { +#pragma omp master // expected-error {{region cannot be closely nested inside 'teams distribute parallel for' region}} + { + bar(); + } + } +#pragma omp target +#pragma omp teams distribute parallel for + for (int i = 0; i < 10; ++i) { +#pragma omp critical // OK + { + bar(); + } + } +#pragma omp target +#pragma omp teams distribute parallel for + for (int i = 0; i < 10; ++i) { +#pragma omp parallel // OK + { +#pragma omp single + { + bar(); + } + } + } +#pragma omp target +#pragma omp teams distribute parallel for + for (int i = 0; i < 10; ++i) { +#pragma omp parallel for // OK + for (int i = 0; i < 10; ++i) + ; + } +#pragma omp target +#pragma omp teams distribute parallel for + for (int i = 0; i < 10; ++i) { +#pragma omp parallel for simd // OK + for (int i = 0; i < 10; ++i) + ; + } +#pragma omp target +#pragma omp teams distribute parallel for + for (int i = 0; i < 10; ++i) { +#pragma omp parallel sections // OK + { + bar(); + } + } +#pragma omp target +#pragma omp teams distribute parallel for + for (int i = 0; i < 10; ++i) { +#pragma omp task // OK + { + bar(); + } + } +#pragma omp target +#pragma omp teams distribute parallel for + for (int i = 0; i < 10; ++i) { +#pragma omp taskyield // OK + bar(); + } +#pragma omp target +#pragma omp teams distribute parallel for + for (int i = 0; i < 10; ++i) { +#pragma omp barrier // expected-error {{region cannot be closely nested inside 'teams distribute parallel for' region}} + bar(); + } +#pragma omp target +#pragma omp teams distribute parallel for + for (int i = 0; i < 10; ++i) { +#pragma omp taskwait // OK + bar(); + } +#pragma omp target +#pragma omp teams distribute parallel for + for (int i = 0; i < 10; ++i) { +#pragma omp flush // OK + bar(); + } +#pragma omp target +#pragma omp teams distribute parallel for + for (int i = 0; i < 10; ++i) { +#pragma omp ordered // expected-error {{region cannot be closely nested inside 'teams distribute parallel for' region; perhaps you forget to enclose 'omp ordered' directive into a for or a parallel for region with 'ordered' clause?}} + bar(); + } +#pragma omp target +#pragma omp teams distribute parallel for + for (int i = 0; i < 10; ++i) { +#pragma omp atomic // OK + ++a; + } +#pragma omp target +#pragma omp teams distribute parallel for + for (int i = 0; i < 10; ++i) { +#pragma omp target // expected-error {{region cannot be nested inside 'target' region}} + ++a; + } +#pragma omp target +#pragma omp teams distribute parallel for + for (int i = 0; i < 10; ++i) { +#pragma omp target parallel // expected-error {{region cannot be nested inside 'target' region}} + ++a; + } +#pragma omp target +#pragma omp teams distribute parallel for + for (int i = 0; i < 10; ++i) { +#pragma omp target parallel for // expected-error {{region cannot be nested inside 'target' region}} + for (int i = 0; i < 10; ++i) + ; + } +#pragma omp target +#pragma omp teams distribute parallel for + for (int i = 0; i < 10; ++i) { +#pragma omp target enter data map(to: a) // expected-error {{region cannot be nested inside 'target' region}} + ++a; + } +#pragma omp target +#pragma omp teams distribute parallel for + for (int i = 0; i < 10; ++i) { +#pragma omp target exit data map(from: a) // expected-error {{region cannot be nested inside 'target' region}} + ++a; + } +#pragma omp target +#pragma omp teams distribute parallel for + for (int i = 0; i < 10; ++i) { +#pragma omp teams // expected-error {{region cannot be closely nested inside 'teams distribute parallel for' region; perhaps you forget to enclose 'omp teams' directive into a target region?}} + ++a; + } +#pragma omp target +#pragma omp teams distribute parallel for + for (int i = 0; i < 10; ++i) { +#pragma omp target update to(a) // expected-error {{region cannot be nested inside 'target' region}} + ++a; + } +#pragma omp target +#pragma omp teams distribute parallel for + for (int i = 0; i < 10; ++i) { +#pragma omp distribute simd // expected-error {{region cannot be closely nested inside 'teams distribute parallel for' region; perhaps you forget to enclose 'omp distribute simd' directive into a teams region?}} + for (int i = 0; i < 10; ++i) + ++a; + } +#pragma omp target +#pragma omp teams distribute parallel for + for (int i = 0; i < 10; ++i) { +#pragma omp target simd // expected-error {{region cannot be nested inside 'target' region}} + for (int i = 0; i < 10; ++i) + ++a; + } +#pragma omp target +#pragma omp teams distribute parallel for + for (int i = 0; i < 10; ++i) { +#pragma omp teams distribute // expected-error {{region cannot be closely nested inside 'teams distribute parallel for' region; perhaps you forget to enclose 'omp teams distribute' directive into a target region?}} + for (int i = 0; i < 10; ++i) + ++a; + } +#pragma omp target +#pragma omp teams distribute parallel for + for (int i = 0; i < 10; ++i) { +#pragma omp teams distribute simd // expected-error {{region cannot be closely nested inside 'teams distribute parallel for' region; perhaps you forget to enclose 'omp teams distribute simd' directive into a target region?}} + for (int i = 0; i < 10; ++i) + ++a; + } +#pragma omp target +#pragma omp teams distribute parallel for + for (int i = 0; i < 10; ++i) { +#pragma omp teams distribute parallel for simd // expected-error {{region cannot be closely nested inside 'teams distribute parallel for' region; perhaps you forget to enclose 'omp teams distribute parallel for simd' directive into a target region?}} + for (int i = 0; i < 10; ++i) + ++a; + } +#pragma omp target +#pragma omp teams distribute parallel for + for (int i = 0; i < 10; ++i) { +#pragma omp teams distribute parallel for // expected-error {{region cannot be closely nested inside 'teams distribute parallel for' region; perhaps you forget to enclose 'omp teams distribute parallel for' directive into a target region?}} + for (int i = 0; i < 10; ++i) + ++a; + } } void foo() { @@ -6622,6 +7040,12 @@ void foo() { for (int i = 0; i < 10; ++i) ; } +#pragma omp parallel + { +#pragma omp teams distribute parallel for // expected-error {{region cannot be closely nested inside 'parallel' region; perhaps you forget to enclose 'omp teams distribute parallel for' directive into a target region?}} + for (int i = 0; i < 10; ++i) + ; + } // SIMD DIRECTIVE #pragma omp simd @@ -6822,6 +7246,12 @@ void foo() { for (int j = 0; j < 10; ++j) ; } +#pragma omp simd + for (int i = 0; i < 10; ++i) { +#pragma omp teams distribute parallel for // expected-error {{OpenMP constructs may not be nested inside a simd region}} + for (int j = 0; j < 10; ++j) + ; + } // FOR DIRECTIVE #pragma omp for @@ -7042,6 +7472,12 @@ void foo() { for (int j = 0; j < 10; ++j) ; } +#pragma omp for + for (int i = 0; i < 10; ++i) { +#pragma omp teams distribute parallel for // expected-error {{region cannot be closely nested inside 'for' region; perhaps you forget to enclose 'omp teams distribute parallel for' directive into a target region?}} + for (int j = 0; j < 10; ++j) + ; + } // FOR SIMD DIRECTIVE #pragma omp for simd @@ -7242,6 +7678,12 @@ void foo() { for (int j = 0; j < 10; ++j) ; } +#pragma omp for simd + for (int i = 0; i < 10; ++i) { +#pragma omp teams distribute parallel for // expected-error {{OpenMP constructs may not be nested inside a simd region}} + for (int j = 0; j < 10; ++j) + ; + } // SECTIONS DIRECTIVE #pragma omp sections @@ -7451,6 +7893,12 @@ void foo() { for (int i = 0; i < 10; ++i) ; } +#pragma omp sections + { +#pragma omp teams distribute parallel for // expected-error {{region cannot be closely nested inside 'sections' region; perhaps you forget to enclose 'omp teams distribute parallel for' directive into a target region?}} + for (int i = 0; i < 10; ++i) + ; + } // SECTION DIRECTIVE #pragma omp section // expected-error {{orphaned 'omp section' directives are prohibited, it must be closely nested to a sections region}} @@ -7756,6 +8204,13 @@ void foo() { for (int i = 0; i < 10; ++i) ; } +#pragma omp sections + { +#pragma omp section +#pragma omp teams distribute parallel for // expected-error {{region cannot be closely nested inside 'section' region; perhaps you forget to enclose 'omp teams distribute parallel for' directive into a target region?}} + for (int i = 0; i < 10; ++i) + ; + } // SINGLE DIRECTIVE #pragma omp single @@ -7966,6 +8421,12 @@ void foo() { for (int i = 0; i < 10; ++i) ; } +#pragma omp single + { +#pragma omp teams distribute parallel for // expected-error {{region cannot be closely nested inside 'single' region; perhaps you forget to enclose 'omp teams distribute parallel for' directive into a target region?}} + for (int i = 0; i < 10; ++i) + ; + } // MASTER DIRECTIVE #pragma omp master @@ -8186,6 +8647,12 @@ void foo() { for (int i = 0; i < 10; ++i) ; } +#pragma omp master + { +#pragma omp teams distribute parallel for // expected-error {{region cannot be closely nested inside 'master' region; perhaps you forget to enclose 'omp teams distribute parallel for' directive into a target region?}} + for (int i = 0; i < 10; ++i) + ; + } // CRITICAL DIRECTIVE #pragma omp critical @@ -8425,6 +8892,12 @@ void foo() { for (int i = 0; i < 10; ++i) ; } +#pragma omp critical + { +#pragma omp teams distribute parallel for // expected-error {{region cannot be closely nested inside 'critical' region; perhaps you forget to enclose 'omp teams distribute parallel for' directive into a target region?}} + for (int i = 0; i < 10; ++i) + ; + } // PARALLEL FOR DIRECTIVE #pragma omp parallel for @@ -8660,6 +9133,12 @@ void foo() { for (int j = 0; j < 10; ++j) ; } +#pragma omp parallel for + for (int i = 0; i < 10; ++i) { +#pragma omp teams distribute parallel for // expected-error {{region cannot be closely nested inside 'parallel for' region; perhaps you forget to enclose 'omp teams distribute parallel for' directive into a target region?}} + for (int j = 0; j < 10; ++j) + ; + } // PARALLEL FOR SIMD DIRECTIVE #pragma omp parallel for simd @@ -8895,6 +9374,12 @@ void foo() { for (int j = 0; j < 10; ++j) ; } +#pragma omp parallel for simd + for (int i = 0; i < 10; ++i) { +#pragma omp teams distribute parallel for // expected-error {{OpenMP constructs may not be nested inside a simd region}} + for (int j = 0; j < 10; ++j) + ; + } // PARALLEL SECTIONS DIRECTIVE #pragma omp parallel sections @@ -9114,6 +9599,12 @@ void foo() { for (int i = 0; i < 10; ++i) ; } +#pragma omp parallel sections + { +#pragma omp teams distribute parallel for // expected-error {{region cannot be closely nested inside 'parallel sections' region; perhaps you forget to enclose 'omp teams distribute parallel for' directive into a target region?}} + for (int i = 0; i < 10; ++i) + ; + } // TASK DIRECTIVE #pragma omp task @@ -9283,6 +9774,12 @@ void foo() { for (int i = 0; i < 10; ++i) ; } +#pragma omp task + { +#pragma omp teams distribute parallel for // expected-error {{region cannot be closely nested inside 'task' region; perhaps you forget to enclose 'omp teams distribute parallel for' directive into a target region?}} + for (int i = 0; i < 10; ++i) + ; + } // ATOMIC DIRECTIVE #pragma omp atomic @@ -9559,6 +10056,14 @@ void foo() { for (int i = 0; i < 10; ++i) ; } +#pragma omp atomic + // expected-error@+2 {{the statement for 'atomic' must be an expression statement of form '++x;', '--x;', 'x++;', 'x--;', 'x binop= expr;', 'x = x binop expr' or 'x = expr binop x', where x is an l-value expression with scalar type}} + // expected-note@+1 {{expected an expression statement}} + { +#pragma omp teams distribute parallel for // expected-error {{OpenMP constructs may not be nested inside an atomic region}} + for (int i = 0; i < 10; ++i) + ; + } // TARGET DIRECTIVE #pragma omp target @@ -9742,6 +10247,12 @@ void foo() { for (int i = 0; i < 10; ++i) ; } +#pragma omp target + { +#pragma omp teams distribute parallel for // OK + for (int i = 0; i < 10; ++i) + ; + } // TARGET PARALLEL DIRECTIVE #pragma omp target parallel @@ -9922,6 +10433,12 @@ void foo() { for (int i = 0; i < 10; ++i) ; } +#pragma omp target parallel + { +#pragma omp teams distribute parallel for // expected-error {{region cannot be closely nested inside 'target parallel' region; perhaps you forget to enclose 'omp teams distribute parallel for' directive into a target region?}} + for (int i = 0; i < 10; ++i) + ; + } // TARGET PARALLEL FOR DIRECTIVE #pragma omp target parallel for @@ -10157,6 +10674,12 @@ void foo() { for (int j = 0; j < 10; ++j) ; } +#pragma omp target parallel for + for (int i = 0; i < 10; ++i) { +#pragma omp teams distribute parallel for // expected-error {{region cannot be closely nested inside 'target parallel for' region; perhaps you forget to enclose 'omp teams distribute parallel for' directive into a target region?}} + for (int j = 0; j < 10; ++j) + ; + } // TEAMS DIRECTIVE #pragma omp target @@ -10387,6 +10910,13 @@ void foo() { for (int i = 0; i < 10; ++i) ; } +#pragma omp target +#pragma omp teams + { +#pragma omp teams distribute parallel for // expected-error {{region cannot be closely nested inside 'teams' region; perhaps you forget to enclose 'omp teams distribute parallel for' directive into a target region?}} + for (int i = 0; i < 10; ++i) + ; + } // TASKLOOP DIRECTIVE #pragma omp taskloop @@ -10612,6 +11142,12 @@ void foo() { for (int i = 0; i < 10; ++i) ; } +#pragma omp taskloop + for (int i = 0; i < 10; ++i) { +#pragma omp teams distribute parallel for // expected-error {{region cannot be closely nested inside 'taskloop' region; perhaps you forget to enclose 'omp teams distribute parallel for' directive into a target region?}} + for (int i = 0; i < 10; ++i) + ; + } // DISTRIBUTE DIRECTIVE #pragma omp target @@ -10877,6 +11413,14 @@ void foo() { for (int i = 0; i < 10; ++i) ++a; } +#pragma omp target +#pragma omp teams +#pragma omp distribute + for (int i = 0; i < 10; ++i) { +#pragma omp target parallel for // expected-error {{region cannot be nested inside 'target' region}} + for (int i = 0; i < 10; ++i) + ++a; + } // DISTRIBUTE PARALLEL FOR DIRECTIVE #pragma omp target @@ -11151,6 +11695,14 @@ void foo() { for (int i = 0; i < 10; ++i) ++a; } +#pragma omp target +#pragma omp teams +#pragma omp distribute parallel for + for (int i = 0; i < 10; ++i) { +#pragma omp teams distribute parallel for // expected-error {{region cannot be closely nested inside 'distribute parallel for' region; perhaps you forget to enclose 'omp teams distribute parallel for' directive into a target region?}} + for (int i = 0; i < 10; ++i) + ++a; + } // DISTRIBUTE PARALLEL FOR SIMD DIRECTIVE #pragma omp target @@ -11416,6 +11968,14 @@ void foo() { for (int i = 0; i < 10; ++i) ; } +#pragma omp target +#pragma omp teams +#pragma omp distribute parallel for simd + for (int i = 0; i < 10; ++i) { +#pragma omp teams distribute parallel for // expected-error {{OpenMP constructs may not be nested inside a simd region}} + for (int i = 0; i < 10; ++i) + ; + } // DISTRIBUTE SIMD DIRECTIVE #pragma omp target @@ -11681,6 +12241,14 @@ void foo() { for (int i = 0; i < 10; ++i) ; } +#pragma omp target +#pragma omp teams +#pragma omp distribute simd + for (int i = 0; i < 10; ++i) { +#pragma omp teams distribute parallel for // expected-error {{OpenMP constructs may not be nested inside a simd region}} + for (int i = 0; i < 10; ++i) + ; + } // TARGET SIMD DIRECTIVE #pragma omp target simd @@ -11880,6 +12448,12 @@ void foo() { for (int i = 0; i < 10; ++i) ; } +#pragma omp target simd + for (int i = 0; i < 10; ++i) { +#pragma omp teams distribute parallel for // expected-error {{OpenMP constructs may not be nested inside a simd region}} + for (int i = 0; i < 10; ++i) + ; + } // TEAMS DISTRIBUTE DIRECTIVE #pragma omp teams distribute // expected-error {{orphaned 'omp teams distribute' directives are prohibited; perhaps you forget to enclose the directive into a target region?}} @@ -12122,6 +12696,13 @@ void foo() { for (int i = 0; i < 10; ++i) ++a; } +#pragma omp target +#pragma omp teams distribute + for (int i = 0; i < 10; ++i) { +#pragma omp teams distribute parallel for // expected-error {{region cannot be closely nested inside 'teams distribute' region; perhaps you forget to enclose 'omp teams distribute parallel for' directive into a target region?}} + for (int i = 0; i < 10; ++i) + ++a; + } // TEAMS DISTRIBUTE SIMD DIRECTIVE #pragma omp teams distribute simd // expected-error {{orphaned 'omp teams distribute simd' directives are prohibited; perhaps you forget to enclose the directive into a target region?}} @@ -12364,6 +12945,13 @@ void foo() { for (int i = 0; i < 10; ++i) ++a; } +#pragma omp target +#pragma omp teams distribute simd + for (int i = 0; i < 10; ++i) { +#pragma omp teams distribute parallel for // expected-error {{OpenMP constructs may not be nested inside a simd region}} + for (int i = 0; i < 10; ++i) + ++a; + } // TEAMS DISTRIBUTE PARALLEL FOR SIMD DIRECTIVE #pragma omp teams distribute parallel for simd // expected-error {{orphaned 'omp teams distribute parallel for simd' directives are prohibited; perhaps you forget to enclose the directive into a target region?}} @@ -12606,6 +13194,265 @@ void foo() { for (int i = 0; i < 10; ++i) ++a; } +#pragma omp target +#pragma omp teams distribute parallel for simd + for (int i = 0; i < 10; ++i) { +#pragma omp teams distribute parallel for // expected-error {{OpenMP constructs may not be nested inside a simd region}} + for (int i = 0; i < 10; ++i) + ++a; + } + +//-------------------- + +// TEAMS DISTRIBUTE PARALLEL FOR DIRECTIVE +#pragma omp teams distribute parallel for // expected-error {{orphaned 'omp teams distribute parallel for' directives are prohibited; perhaps you forget to enclose the directive into a target region?}} + for (int i = 0; i < 10; ++i) + ; +#pragma omp target +#pragma omp teams distribute parallel for + for (int i = 0; i < 10; ++i) { +#pragma omp distribute parallel for simd // expected-error {{region cannot be closely nested inside 'teams distribute parallel for' region; perhaps you forget to enclose 'omp distribute parallel for simd' directive into a teams region?}} + for (int i = 0; i < 10; ++i) + ; + } +#pragma omp target +#pragma omp teams distribute parallel for + for (int i = 0; i < 10; ++i) { +#pragma omp distribute // expected-error {{region cannot be closely nested inside 'teams distribute parallel for' region; perhaps you forget to enclose 'omp distribute' directive into a teams region?}} + for (int i = 0; i < 10; ++i) + ; + } +#pragma omp target +#pragma omp teams distribute parallel for + for (int i = 0; i < 10; ++i) { +#pragma omp for // expected-error {{region cannot be closely nested inside 'teams distribute parallel for' region; perhaps you forget to enclose 'omp for' directive into a parallel region?}} + for (int i = 0; i < 10; ++i) + ; + } +#pragma omp target +#pragma omp teams distribute parallel for + for (int i = 0; i < 10; ++i) { +#pragma omp simd // OK + for (int i = 0; i < 10; ++i) + ; + } +#pragma omp target +#pragma omp teams distribute parallel for + for (int i = 0; i < 10; ++i) { +#pragma omp for simd // expected-error {{region cannot be closely nested inside 'teams distribute parallel for' region; perhaps you forget to enclose 'omp for simd' directive into a parallel region?}} + for (int i = 0; i < 10; ++i) + ; + } +#pragma omp target +#pragma omp teams distribute parallel for + for (int i = 0; i < 10; ++i) { +#pragma omp parallel // OK + for (int i = 0; i < 10; ++i) + ; + } +#pragma omp target +#pragma omp teams distribute parallel for + for (int i = 0; i < 10; ++i) { +#pragma omp sections // expected-error {{region cannot be closely nested inside 'teams distribute parallel for' region; perhaps you forget to enclose 'omp sections' directive into a parallel region?}} + { + bar(); + } + } +#pragma omp target +#pragma omp teams distribute parallel for + for (int i = 0; i < 10; ++i) { +#pragma omp section // expected-error {{'omp section' directive must be closely nested to a sections region, not a teams distribute parallel for region}} + { + bar(); + } + } +#pragma omp target +#pragma omp teams distribute parallel for + for (int i = 0; i < 10; ++i) { +#pragma omp single // expected-error {{region cannot be closely nested inside 'teams distribute parallel for' region; perhaps you forget to enclose 'omp single' directive into a parallel region?}} + { + bar(); + } + } +#pragma omp target +#pragma omp teams distribute parallel for + for (int i = 0; i < 10; ++i) { +#pragma omp master // expected-error {{region cannot be closely nested inside 'teams distribute parallel for' region}} + { + bar(); + } + } +#pragma omp target +#pragma omp teams distribute parallel for + for (int i = 0; i < 10; ++i) { +#pragma omp critical // OK + { + bar(); + } + } +#pragma omp target +#pragma omp teams distribute parallel for + for (int i = 0; i < 10; ++i) { +#pragma omp parallel // OK + { +#pragma omp single + { + bar(); + } + } + } +#pragma omp target +#pragma omp teams distribute parallel for + for (int i = 0; i < 10; ++i) { +#pragma omp parallel for // OK + for (int i = 0; i < 10; ++i) + ; + } +#pragma omp target +#pragma omp teams distribute parallel for + for (int i = 0; i < 10; ++i) { +#pragma omp parallel for simd // OK + for (int i = 0; i < 10; ++i) + ; + } +#pragma omp target +#pragma omp teams distribute parallel for + for (int i = 0; i < 10; ++i) { +#pragma omp parallel sections // OK + { + bar(); + } + } +#pragma omp target +#pragma omp teams distribute parallel for + for (int i = 0; i < 10; ++i) { +#pragma omp task // OK + { + bar(); + } + } +#pragma omp target +#pragma omp teams distribute parallel for + for (int i = 0; i < 10; ++i) { +#pragma omp taskyield // OK + bar(); + } +#pragma omp target +#pragma omp teams distribute parallel for + for (int i = 0; i < 10; ++i) { +#pragma omp barrier // expected-error {{region cannot be closely nested inside 'teams distribute parallel for' region}} + bar(); + } +#pragma omp target +#pragma omp teams distribute parallel for + for (int i = 0; i < 10; ++i) { +#pragma omp taskwait // OK + bar(); + } +#pragma omp target +#pragma omp teams distribute parallel for + for (int i = 0; i < 10; ++i) { +#pragma omp flush // OK + bar(); + } +#pragma omp target +#pragma omp teams distribute parallel for + for (int i = 0; i < 10; ++i) { +#pragma omp ordered // expected-error {{region cannot be closely nested inside 'teams distribute parallel for' region; perhaps you forget to enclose 'omp ordered' directive into a for or a parallel for region with 'ordered' clause?}} + bar(); + } +#pragma omp target +#pragma omp teams distribute parallel for + for (int i = 0; i < 10; ++i) { +#pragma omp atomic // OK + ++a; + } +#pragma omp target +#pragma omp teams distribute parallel for + for (int i = 0; i < 10; ++i) { +#pragma omp target // expected-error {{region cannot be nested inside 'target' region}} + ++a; + } +#pragma omp target +#pragma omp teams distribute parallel for + for (int i = 0; i < 10; ++i) { +#pragma omp target parallel // expected-error {{region cannot be nested inside 'target' region}} + ++a; + } +#pragma omp target +#pragma omp teams distribute parallel for + for (int i = 0; i < 10; ++i) { +#pragma omp target parallel for // expected-error {{region cannot be nested inside 'target' region}} + for (int i = 0; i < 10; ++i) + ; + } +#pragma omp target +#pragma omp teams distribute parallel for + for (int i = 0; i < 10; ++i) { +#pragma omp target enter data map(to: a) // expected-error {{region cannot be nested inside 'target' region}} + ++a; + } +#pragma omp target +#pragma omp teams distribute parallel for + for (int i = 0; i < 10; ++i) { +#pragma omp target exit data map(from: a) // expected-error {{region cannot be nested inside 'target' region}} + ++a; + } +#pragma omp target +#pragma omp teams distribute parallel for + for (int i = 0; i < 10; ++i) { +#pragma omp teams // expected-error {{region cannot be closely nested inside 'teams distribute parallel for' region; perhaps you forget to enclose 'omp teams' directive into a target region?}} + ++a; + } +#pragma omp target +#pragma omp teams distribute parallel for + for (int i = 0; i < 10; ++i) { +#pragma omp target update to(a) // expected-error {{region cannot be nested inside 'target' region}} + ++a; + } +#pragma omp target +#pragma omp teams distribute parallel for + for (int i = 0; i < 10; ++i) { +#pragma omp distribute simd // expected-error {{region cannot be closely nested inside 'teams distribute parallel for' region; perhaps you forget to enclose 'omp distribute simd' directive into a teams region?}} + for (int i = 0; i < 10; ++i) + ++a; + } +#pragma omp target +#pragma omp teams distribute parallel for + for (int i = 0; i < 10; ++i) { +#pragma omp target simd // expected-error {{region cannot be nested inside 'target' region}} + for (int i = 0; i < 10; ++i) + ++a; + } +#pragma omp target +#pragma omp teams distribute parallel for + for (int i = 0; i < 10; ++i) { +#pragma omp teams distribute // expected-error {{region cannot be closely nested inside 'teams distribute parallel for' region; perhaps you forget to enclose 'omp teams distribute' directive into a target region?}} + for (int i = 0; i < 10; ++i) + ++a; + } +#pragma omp target +#pragma omp teams distribute parallel for + for (int i = 0; i < 10; ++i) { +#pragma omp teams distribute simd // expected-error {{region cannot be closely nested inside 'teams distribute parallel for' region; perhaps you forget to enclose 'omp teams distribute simd' directive into a target region?}} + for (int i = 0; i < 10; ++i) + ++a; + } +#pragma omp target +#pragma omp teams distribute parallel for + for (int i = 0; i < 10; ++i) { +#pragma omp teams distribute parallel for simd // expected-error {{region cannot be closely nested inside 'teams distribute parallel for' region; perhaps you forget to enclose 'omp teams distribute parallel for simd' directive into a target region?}} + for (int i = 0; i < 10; ++i) + ++a; + } +#pragma omp target +#pragma omp teams distribute parallel for + for (int i = 0; i < 10; ++i) { +#pragma omp teams distribute parallel for // expected-error {{region cannot be closely nested inside 'teams distribute parallel for' region; perhaps you forget to enclose 'omp teams distribute parallel for' directive into a target region?}} + for (int i = 0; i < 10; ++i) + ++a; + } + return foo<int>(); } diff --git a/test/OpenMP/teams_distribute_parallel_for_ast_print.cpp b/test/OpenMP/teams_distribute_parallel_for_ast_print.cpp new file mode 100644 index 0000000000..ad14794116 --- /dev/null +++ b/test/OpenMP/teams_distribute_parallel_for_ast_print.cpp @@ -0,0 +1,203 @@ +// RUN: %clang_cc1 -verify -fopenmp -ast-print %s | FileCheck %s +// RUN: %clang_cc1 -fopenmp -x c++ -std=c++11 -emit-pch -o %t %s +// RUN: %clang_cc1 -fopenmp -std=c++11 -include-pch %t -fsyntax-only -verify %s -ast-print | FileCheck %s +// expected-no-diagnostics + +#ifndef HEADER +#define HEADER + +void foo() {} + +struct S { + S(): a(0) {} + S(int v) : a(v) {} + int a; + typedef int type; +}; + +template <typename T> +class S7 : public T { +protected: + T a; + S7() : a(0) {} + +public: + S7(typename T::type v) : a(v) { +#pragma omp target +#pragma omp teams distribute parallel for private(a) private(this->a) private(T::a) + for (int k = 0; k < a.a; ++k) + ++this->a.a; + } + S7 &operator=(S7 &s) { +#pragma omp target +#pragma omp teams distribute parallel for private(a) private(this->a) + for (int k = 0; k < s.a.a; ++k) + ++s.a.a; + + foo(); + return *this; + } + void foo() { + int b, argv, d, c, e, f; +#pragma omp target +#pragma omp teams distribute parallel for default(none), private(b) firstprivate(argv) shared(d) reduction(+:c) reduction(max:e) num_teams(f) thread_limit(d) + for (int k = 0; k < a.a; ++k) + ++a.a; + } +}; +// CHECK: #pragma omp target +// CHECK-NEXT: #pragma omp teams distribute parallel for private(this->a) private(this->a) private(T::a) +// CHECK: #pragma omp target +// CHECK-NEXT: #pragma omp teams distribute parallel for private(this->a) private(this->a) +// CHECK: #pragma omp target +// CHECK-NEXT: #pragma omp teams distribute parallel for default(none) private(b) firstprivate(argv) shared(d) reduction(+: c) reduction(max: e) num_teams(f) thread_limit(d) + +class S8 : public S7<S> { + S8() {} + +public: + S8(int v) : S7<S>(v){ +#pragma omp target +#pragma omp teams distribute parallel for private(a) private(this->a) private(S7<S>::a) + for (int k = 0; k < a.a; ++k) + ++this->a.a; + } + S8 &operator=(S8 &s) { +#pragma omp target +#pragma omp teams distribute parallel for private(a) private(this->a) + for (int k = 0; k < s.a.a; ++k) + ++s.a.a; + + bar(); + return *this; + } + void bar() { + int b, argv, d, c, e, f8; +#pragma omp target +#pragma omp teams distribute parallel for default(none), private(b) firstprivate(argv) shared(d) reduction(+:c) reduction(max:e) num_teams(f8) thread_limit(d) + for (int k = 0; k < a.a; ++k) + ++a.a; + } +}; +// CHECK: #pragma omp target +// CHECK-NEXT: #pragma omp teams distribute parallel for private(this->a) private(this->a) private(this->S::a) +// CHECK: #pragma omp target +// CHECK-NEXT: #pragma omp teams distribute parallel for private(this->a) private(this->a) private(this->S7<S>::a) +// CHECK: #pragma omp target +// CHECK-NEXT: #pragma omp teams distribute parallel for private(this->a) private(this->a) +// CHECK: #pragma omp target +// CHECK-NEXT: #pragma omp teams distribute parallel for default(none) private(b) firstprivate(argv) shared(d) reduction(+: c) reduction(max: e) num_teams(f8) thread_limit(d) + +template <class T, int N> +T tmain(T argc) { + T b = argc, c, d, e, f, g; + static T a; +// CHECK: static T a; + const T clen = 5; + const T alen = 16; + int arr[10]; +#pragma omp target +#pragma omp teams distribute parallel for + for (int i=0; i < 2; ++i) + a = 2; +// CHECK: #pragma omp target +// CHECK-NEXT: #pragma omp teams distribute parallel for +// CHECK-NEXT: for (int i = 0; i < 2; ++i) +// CHECK-NEXT: a = 2; +#pragma omp target +#pragma omp teams distribute parallel for private(argc, b), firstprivate(c, d), collapse(2) + for (int i = 0; i < 10; ++i) + for (int j = 0; j < 10; ++j) + foo(); +// CHECK: #pragma omp target +// CHECK-NEXT: #pragma omp teams distribute parallel for private(argc,b) firstprivate(c,d) collapse(2) +// CHECK-NEXT: for (int i = 0; i < 10; ++i) +// CHECK-NEXT: for (int j = 0; j < 10; ++j) +// CHECK-NEXT: foo(); + for (int i = 0; i < 10; ++i) + foo(); +// CHECK: for (int i = 0; i < 10; ++i) +// CHECK-NEXT: foo(); +#pragma omp target +#pragma omp teams distribute parallel for + for (int i = 0; i < 10; ++i) + foo(); +// CHECK: #pragma omp target +// CHECK-NEXT: #pragma omp teams distribute parallel for +// CHECK-NEXT: for (int i = 0; i < 10; ++i) +// CHECK-NEXT: foo(); +#pragma omp target +#pragma omp teams distribute parallel for default(none), private(b) firstprivate(argc) shared(d) reduction(+:c) reduction(max:e) num_teams(f) thread_limit(d) + for (int k = 0; k < 10; ++k) + e += d + argc; +// CHECK: #pragma omp target +// CHECK-NEXT: #pragma omp teams distribute parallel for default(none) private(b) firstprivate(argc) shared(d) reduction(+: c) reduction(max: e) num_teams(f) thread_limit(d) +// CHECK-NEXT: for (int k = 0; k < 10; ++k) +// CHECK-NEXT: e += d + argc; +#pragma omp target +#pragma omp teams distribute parallel for linear(d) + for (int k = 0; k < 10; ++k) + e += d + argc; +// CHECK: #pragma omp target +// CHECK-NEXT: #pragma omp teams distribute parallel for linear(d) +// CHECK-NEXT: for (int k = 0; k < 10; ++k) +// CHECK-NEXT: e += d + argc; + return T(); +} + +int main (int argc, char **argv) { + int b = argc, c, d, e, f, g; + static int a; +// CHECK: static int a; + const int clen = 5; + const int N = 10; + int arr[10]; +#pragma omp target +#pragma omp teams distribute parallel for + for (int i=0; i < 2; ++i) + a = 2; +// CHECK: #pragma omp target +// CHECK-NEXT: #pragma omp teams distribute parallel for +// CHECK-NEXT: for (int i = 0; i < 2; ++i) +// CHECK-NEXT: a = 2; +#pragma omp target +#pragma omp teams distribute parallel for private(argc,b),firstprivate(argv, c), collapse(2) + for (int i = 0; i < 10; ++i) + for (int j = 0; j < 10; ++j) + foo(); +// CHECK: #pragma omp target +// CHECK-NEXT: #pragma omp teams distribute parallel for private(argc,b) firstprivate(argv,c) collapse(2) +// CHECK-NEXT: for (int i = 0; i < 10; ++i) +// CHECK-NEXT: for (int j = 0; j < 10; ++j) +// CHECK-NEXT: foo(); + for (int i = 0; i < 10; ++i) + foo(); +// CHECK: for (int i = 0; i < 10; ++i) +// CHECK-NEXT: foo(); +#pragma omp target +#pragma omp teams distribute parallel for + for (int i = 0; i < 10; ++i)foo(); +// CHECK: #pragma omp target +// CHECK-NEXT: #pragma omp teams distribute parallel for +// CHECK-NEXT: for (int i = 0; i < 10; ++i) +// CHECK-NEXT: foo(); +#pragma omp target +#pragma omp teams distribute parallel for default(none), private(b) firstprivate(argc) shared(d) reduction(+:c) reduction(max:e) num_teams(f) thread_limit(d) + for (int k = 0; k < 10; ++k) + e += d + argc; +// CHECK: #pragma omp target +// CHECK-NEXT: #pragma omp teams distribute parallel for default(none) private(b) firstprivate(argc) shared(d) reduction(+: c) reduction(max: e) num_teams(f) thread_limit(d) +// CHECK-NEXT: for (int k = 0; k < 10; ++k) +// CHECK-NEXT: e += d + argc; +#pragma omp target +#pragma omp teams distribute parallel for linear(d) + for (int k = 0; k < 10; ++k) + e += d + argc; +// CHECK: #pragma omp target +// CHECK-NEXT: #pragma omp teams distribute parallel for linear(d) +// CHECK-NEXT: for (int k = 0; k < 10; ++k) +// CHECK-NEXT: e += d + argc; + return (0); +} + +#endif diff --git a/test/OpenMP/teams_distribute_parallel_for_collapse_messages.cpp b/test/OpenMP/teams_distribute_parallel_for_collapse_messages.cpp new file mode 100644 index 0000000000..d48de04fd1 --- /dev/null +++ b/test/OpenMP/teams_distribute_parallel_for_collapse_messages.cpp @@ -0,0 +1,150 @@ +// RUN: %clang_cc1 -verify -fopenmp %s + +void foo() { +} + +bool foobool(int argc) { + return argc; +} + +struct S1; // expected-note {{declared here}} + +template <class T, typename S, int N, int ST> // expected-note {{declared here}} +T tmain(T argc, S **argv) { //expected-note 2 {{declared here}} +#pragma omp target +#pragma omp teams distribute parallel for collapse // expected-error {{expected '(' after 'collapse'}} + for (int i = ST; i < N; i++) + argv[0][i] = argv[0][i] - argv[0][i-ST]; + +#pragma omp target +#pragma omp teams distribute parallel for collapse ( // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}} + for (int i = ST; i < N; i++) + + argv[0][i] = argv[0][i] - argv[0][i-ST]; +#pragma omp target +#pragma omp teams distribute parallel for collapse () // expected-error {{expected expression}} + for (int i = ST; i < N; i++) + argv[0][i] = argv[0][i] - argv[0][i-ST]; + +// expected-error@+4 {{expected ')'}} expected-note@+4 {{to match this '('}} +// expected-error@+3 2 {{expression is not an integral constant expression}} +// expected-note@+2 2 {{read of non-const variable 'argc' is not allowed in a constant expression}} +#pragma omp target +#pragma omp teams distribute parallel for collapse (argc + for (int i = ST; i < N; i++) + argv[0][i] = argv[0][i] - argv[0][i-ST]; + +// expected-error@+2 2 {{argument to 'collapse' clause must be a strictly positive integer value}} +#pragma omp target +#pragma omp teams distribute parallel for collapse (ST // expected-error {{expected ')'}} expected-note {{to match this '('}} + for (int i = ST; i < N; i++) + argv[0][i] = argv[0][i] - argv[0][i-ST]; + +#pragma omp target +#pragma omp teams distribute parallel for collapse (1)) // expected-warning {{extra tokens at the end of '#pragma omp teams distribute parallel for' are ignored}} + for (int i = ST; i < N; i++) + argv[0][i] = argv[0][i] - argv[0][i-ST]; + +#pragma omp target +#pragma omp teams distribute parallel for collapse ((ST > 0) ? 1 + ST : 2) // expected-note 2 {{as specified in 'collapse' clause}} + for (int i = ST; i < N; i++) + argv[0][i] = argv[0][i] - argv[0][i-ST]; // expected-error 2 {{expected 2 for loops after '#pragma omp teams distribute parallel for', but found only 1}} + +// expected-error@+4 2 {{directive '#pragma omp teams distribute parallel for' cannot contain more than one 'collapse' clause}} +// expected-error@+3 2 {{argument to 'collapse' clause must be a strictly positive integer value}} +// expected-error@+2 2 {{expression is not an integral constant expression}} +#pragma omp target +#pragma omp teams distribute parallel for collapse (foobool(argc)), collapse (true), collapse (-5) + for (int i = ST; i < N; i++) + argv[0][i] = argv[0][i] - argv[0][i-ST]; + +#pragma omp distribute collapse (S) // expected-error {{'S' does not refer to a value}} + for (int i = ST; i < N; i++) + argv[0][i] = argv[0][i] - argv[0][i-ST]; + +// expected-error@+2 2 {{expression is not an integral constant expression}} +#pragma omp target +#pragma omp teams distribute parallel for collapse (argv[1]=2) // expected-error {{expected ')'}} expected-note {{to match this '('}} + for (int i = ST; i < N; i++) + argv[0][i] = argv[0][i] - argv[0][i-ST]; + +#pragma omp target +#pragma omp teams distribute parallel for collapse (1) + for (int i = ST; i < N; i++) + argv[0][i] = argv[0][i] - argv[0][i-ST]; + +#pragma omp target +#pragma omp teams distribute parallel for collapse (N) // expected-error {{argument to 'collapse' clause must be a strictly positive integer value}} + for (T i = ST; i < N; i++) + argv[0][i] = argv[0][i] - argv[0][i-ST]; + +#pragma omp target +#pragma omp teams distribute parallel for collapse (2) // expected-note {{as specified in 'collapse' clause}} + foo(); // expected-error {{expected 2 for loops after '#pragma omp teams distribute parallel for'}} + return argc; +} + +int main(int argc, char **argv) { +#pragma omp target +#pragma omp teams distribute parallel for collapse // expected-error {{expected '(' after 'collapse'}} + for (int i = 4; i < 12; i++) + argv[0][i] = argv[0][i] - argv[0][i-4]; + +#pragma omp target +#pragma omp teams distribute parallel for collapse ( // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}} + for (int i = 4; i < 12; i++) + argv[0][i] = argv[0][i] - argv[0][i-4]; + +#pragma omp target +#pragma omp teams distribute parallel for collapse () // expected-error {{expected expression}} + for (int i = 4; i < 12; i++) + argv[0][i] = argv[0][i] - argv[0][i-4]; + +#pragma omp target +#pragma omp teams distribute parallel for collapse (4 // expected-error {{expected ')'}} expected-note {{to match this '('}} expected-note {{as specified in 'collapse' clause}} + for (int i = 4; i < 12; i++) + argv[0][i] = argv[0][i] - argv[0][i-4]; // expected-error {{expected 4 for loops after '#pragma omp teams distribute parallel for', but found only 1}} + +#pragma omp target +#pragma omp teams distribute parallel for collapse (2+2)) // expected-warning {{extra tokens at the end of '#pragma omp teams distribute parallel for' are ignored}} expected-note {{as specified in 'collapse' clause}} + for (int i = 4; i < 12; i++) + argv[0][i] = argv[0][i] - argv[0][i-4]; // expected-error {{expected 4 for loops after '#pragma omp teams distribute parallel for', but found only 1}} + +#pragma omp target +#pragma omp teams distribute parallel for collapse (foobool(1) > 0 ? 1 : 2) // expected-error {{expression is not an integral constant expression}} + for (int i = 4; i < 12; i++) + argv[0][i] = argv[0][i] - argv[0][i-4]; + +// expected-error@+4 {{expression is not an integral constant expression}} +// expected-error@+3 2 {{directive '#pragma omp teams distribute parallel for' cannot contain more than one 'collapse' clause}} +// expected-error@+2 2 {{argument to 'collapse' clause must be a strictly positive integer value}} +#pragma omp target +#pragma omp teams distribute parallel for collapse (foobool(argc)), collapse (true), collapse (-5) + for (int i = 4; i < 12; i++) + argv[0][i] = argv[0][i] - argv[0][i-4]; + +#pragma omp target +#pragma omp teams distribute parallel for collapse (S1) // expected-error {{'S1' does not refer to a value}} + for (int i = 4; i < 12; i++) + argv[0][i] = argv[0][i] - argv[0][i-4]; + +// expected-error@+2 {{expression is not an integral constant expression}} +#pragma omp target +#pragma omp teams distribute parallel for collapse (argv[1]=2) // expected-error {{expected ')'}} expected-note {{to match this '('}} + for (int i = 4; i < 12; i++) + argv[0][i] = argv[0][i] - argv[0][i-4]; + +// expected-error@+4 {{statement after '#pragma omp teams distribute parallel for' must be a for loop}} +// expected-note@+2 {{in instantiation of function template specialization 'tmain<int, char, -1, -2>' requested here}} +#pragma omp target +#pragma omp teams distribute parallel for collapse(collapse(tmain<int, char, -1, -2>(argc, argv) // expected-error 2 {{expected ')'}} expected-note 2 {{to match this '('}} + foo(); + +#pragma omp target +#pragma omp teams distribute parallel for collapse (2) // expected-note {{as specified in 'collapse' clause}} + foo(); // expected-error {{expected 2 for loops after '#pragma omp teams distribute parallel for'}} + +// expected-note@+1 {{in instantiation of function template specialization 'tmain<int, char, 1, 0>' requested here}} + return tmain<int, char, 1, 0>(argc, argv); +} + diff --git a/test/OpenMP/teams_distribute_parallel_for_default_messages.cpp b/test/OpenMP/teams_distribute_parallel_for_default_messages.cpp new file mode 100644 index 0000000000..4cd7e65510 --- /dev/null +++ b/test/OpenMP/teams_distribute_parallel_for_default_messages.cpp @@ -0,0 +1,30 @@ +// RUN: %clang_cc1 -verify -fopenmp %s + +void foo(); + +int main(int argc, char **argv) { + #pragma omp target + #pragma omp teams distribute parallel for default // expected-error {{expected '(' after 'default'}} + for (int i=0; i<200; i++) foo(); + #pragma omp target + #pragma omp teams distribute parallel for default ( // expected-error {{expected 'none' or 'shared' in OpenMP clause 'default'}} expected-error {{expected ')'}} expected-note {{to match this '('}} + for (int i=0; i<200; i++) foo(); + #pragma omp target + #pragma omp teams distribute parallel for default () // expected-error {{expected 'none' or 'shared' in OpenMP clause 'default'}} + for (int i=0; i<200; i++) foo(); + #pragma omp target + #pragma omp teams distribute parallel for default (none // expected-error {{expected ')'}} expected-note {{to match this '('}} + for (int i=0; i<200; i++) foo(); + #pragma omp target + #pragma omp teams distribute parallel for default (shared), default(shared) // expected-error {{directive '#pragma omp teams distribute parallel for' cannot contain more than one 'default' clause}} + for (int i=0; i<200; i++) foo(); + #pragma omp target + #pragma omp teams distribute parallel for default (x) // expected-error {{expected 'none' or 'shared' in OpenMP clause 'default'}} + for (int i=0; i<200; i++) foo(); + + #pragma omp target + #pragma omp teams distribute parallel for default(none) + for (int i=0; i<200; i++) ++argc; // expected-error {{variable 'argc' must have explicitly specified data sharing attributes}} + + return 0; +} diff --git a/test/OpenMP/teams_distribute_parallel_for_dist_schedule_messages.cpp b/test/OpenMP/teams_distribute_parallel_for_dist_schedule_messages.cpp new file mode 100644 index 0000000000..098abb7487 --- /dev/null +++ b/test/OpenMP/teams_distribute_parallel_for_dist_schedule_messages.cpp @@ -0,0 +1,104 @@ +// RUN: %clang_cc1 -verify -fopenmp %s + +void foo() { +} + +bool foobool(int argc) { + return argc; +} + +struct S1; // expected-note {{declared here}} expected-note {{declared here}} + +template <class T, int N> +T tmain(T argc) { + T b = argc, c, d, e, f, g; + char ** argv; + static T a; +// CHECK: static T a; + +#pragma omp target +#pragma omp teams distribute parallel for dist_schedule // expected-error {{expected '(' after 'dist_schedule'}} + for (int i = 0; i < 10; ++i) foo(); + +#pragma omp target +#pragma omp teams distribute parallel for dist_schedule ( // expected-error {{expected 'static' in OpenMP clause 'dist_schedule'}} expected-error {{expected ')'}} expected-note {{to match this '('}} + for (int i = 0; i < 10; ++i) foo(); + +#pragma omp target +#pragma omp teams distribute parallel for dist_schedule () // expected-error {{expected 'static' in OpenMP clause 'dist_schedule'}} + for (int i = 0; i < 10; ++i) foo(); + +#pragma omp target +#pragma omp teams distribute parallel for dist_schedule (static // expected-error {{expected ')'}} expected-note {{to match this '('}} + for (int i = 0; i < 10; ++i) foo(); + +#pragma omp target +#pragma omp teams distribute parallel for dist_schedule (static, // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}} + for (int i = 0; i < 10; ++i) foo(); + +#pragma omp target +#pragma omp teams distribute parallel for dist_schedule (argc)) // expected-error {{expected 'static' in OpenMP clause 'dist_schedule'}} expected-warning {{extra tokens at the end of '#pragma omp teams distribute parallel for' are ignored}} + for (int i = 0; i < 10; ++i) foo(); + +#pragma omp target +#pragma omp teams distribute parallel for dist_schedule (static, argc > 0 ? argv[1] : argv[2]) // expected-error2 {{expression must have integral or unscoped enumeration type, not 'char *'}} + for (int i = 0; i < 10; ++i) foo(); + +#pragma omp target +#pragma omp teams distribute parallel for dist_schedule (static), dist_schedule (static, 1) // expected-error {{directive '#pragma omp teams distribute parallel for' cannot contain more than one 'dist_schedule' clause}} + for (int i = 0; i < 10; ++i) foo(); + +#pragma omp target +#pragma omp teams distribute parallel for dist_schedule (static, S1) // expected-error {{'S1' does not refer to a value}} + for (int i = 0; i < 10; ++i) foo(); + +#pragma omp target +#pragma omp teams distribute parallel for dist_schedule (static, argv[1]=2) // expected-error {{expected ')'}} expected-note {{to match this '('}} expected-error3 {{expression must have integral or unscoped enumeration type, not 'char *'}} + for (int i = 0; i < 10; ++i) foo(); + + return T(); +} + +int main(int argc, char **argv) { +#pragma omp target +#pragma omp teams distribute parallel for dist_schedule // expected-error {{expected '(' after 'dist_schedule'}} + for (int i = 0; i < 10; ++i) foo(); + +#pragma omp target +#pragma omp teams distribute parallel for dist_schedule ( // expected-error {{expected 'static' in OpenMP clause 'dist_schedule'}} expected-error {{expected ')'}} expected-note {{to match this '('}} + for (int i = 0; i < 10; ++i) foo(); + +#pragma omp target +#pragma omp teams distribute parallel for dist_schedule () // expected-error {{expected 'static' in OpenMP clause 'dist_schedule'}} + for (int i = 0; i < 10; ++i) foo(); + +#pragma omp target +#pragma omp teams distribute parallel for dist_schedule (static // expected-error {{expected ')'}} expected-note {{to match this '('}} + for (int i = 0; i < 10; ++i) foo(); + +#pragma omp target +#pragma omp teams distribute parallel for dist_schedule (static, // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}} + for (int i = 0; i < 10; ++i) foo(); + +#pragma omp target +#pragma omp teams distribute parallel for dist_schedule (argc)) // expected-error {{expected 'static' in OpenMP clause 'dist_schedule'}} expected-warning {{extra tokens at the end of '#pragma omp teams distribute parallel for' are ignored}} + for (int i = 0; i < 10; ++i) foo(); + +#pragma omp target +#pragma omp teams distribute parallel for dist_schedule (static, argc > 0 ? argv[1] : argv[2]) // expected-error {{expression must have integral or unscoped enumeration type, not 'char *'}} + for (int i = 0; i < 10; ++i) foo(); + +#pragma omp target +#pragma omp teams distribute parallel for dist_schedule (static), dist_schedule (static, 1) // expected-error {{directive '#pragma omp teams distribute parallel for' cannot contain more than one 'dist_schedule' clause}} + for (int i = 0; i < 10; ++i) foo(); + +#pragma omp target +#pragma omp teams distribute parallel for dist_schedule (static, S1) // expected-error {{'S1' does not refer to a value}} + for (int i = 0; i < 10; ++i) foo(); + +#pragma omp target +#pragma omp teams distribute parallel for dist_schedule (static, argv[1]=2) // expected-error {{expression must have integral or unscoped enumeration type, not 'char *'}} expected-error {{expected ')'}} expected-note {{to match this '('}} + for (int i = 0; i < 10; ++i) foo(); + + return (tmain<int, 5>(argc) + tmain<char, 1>(argv[0][0])); // expected-note {{in instantiation of function template specialization 'tmain<int, 5>' requested here}} expected-note {{in instantiation of function template specialization 'tmain<char, 1>' requested here}} +} diff --git a/test/OpenMP/teams_distribute_parallel_for_firstprivate_messages.cpp b/test/OpenMP/teams_distribute_parallel_for_firstprivate_messages.cpp new file mode 100644 index 0000000000..e6314c210e --- /dev/null +++ b/test/OpenMP/teams_distribute_parallel_for_firstprivate_messages.cpp @@ -0,0 +1,152 @@ +// RUN: %clang_cc1 -verify -fopenmp %s + +void foo() { +} + +bool foobool(int argc) { + return argc; +} + +struct S1; // expected-note {{declared here}} expected-note{{forward declaration of 'S1'}} +extern S1 a; +class S2 { + mutable int a; + +public: + S2() : a(0) {} + S2(const S2 &s2) : a(s2.a) {} + static float S2s; + static const float S2sc; +}; +const float S2::S2sc = 0; +const S2 b; +const S2 ba[5]; +class S3 { + int a; + S3 &operator=(const S3 &s3); + +public: + S3() : a(0) {} // expected-note {{candidate constructor not viable: requires 0 arguments, but 1 was provided}} + S3(S3 &s3) : a(s3.a) {} // expected-note {{candidate constructor not viable: 1st argument ('const S3') would lose const qualifier}} +}; +const S3 c; +const S3 ca[5]; +extern const int f; +class S4 { + int a; + S4(); + S4(const S4 &s4); +public: + S4(int v):a(v) { } +}; +class S5 { + int a; + S5():a(0) {} + S5(const S5 &s5):a(s5.a) { } +public: + S5(int v):a(v) { } +}; +class S6 { + int a; +public: + S6() : a(0) { } +}; + +S3 h; +#pragma omp threadprivate(h) // expected-note {{defined as threadprivate or thread local}} + +int main(int argc, char **argv) { + const int d = 5; + const int da[5] = { 0 }; + S4 e(4); + S5 g(5); + S6 p; + int i; + int &j = i; + +#pragma omp target +#pragma omp teams distribute parallel for firstprivate // expected-error {{expected '(' after 'firstprivate'}} + for (i = 0; i < argc; ++i) foo(); + +#pragma omp target +#pragma omp teams distribute parallel for firstprivate ( // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}} + for (i = 0; i < argc; ++i) foo(); + +#pragma omp target +#pragma omp teams distribute parallel for firstprivate () // expected-error {{expected expression}} + for (i = 0; i < argc; ++i) foo(); + +#pragma omp target +#pragma omp teams distribute parallel for firstprivate (argc // expected-error {{expected ')'}} expected-note {{to match this '('}} + for (i = 0; i < argc; ++i) foo(); + +#pragma omp target +#pragma omp teams distribute parallel for firstprivate (argc, // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}} + for (i = 0; i < argc; ++i) foo(); + +#pragma omp target +#pragma omp teams distribute parallel for firstprivate (argc > 0 ? argv[1] : argv[2]) // expected-error {{expected variable name}} + for (i = 0; i < argc; ++i) foo(); + +#pragma omp target +#pragma omp teams distribute parallel for firstprivate (argc) + for (i = 0; i < argc; ++i) foo(); + +#pragma omp target +#pragma omp teams distribute parallel for firstprivate (S1) // expected-error {{'S1' does not refer to a value}} + for (i = 0; i < argc; ++i) foo(); + +#pragma omp target +#pragma omp teams distribute parallel for firstprivate (a, b, c, d, f) // expected-error {{firstprivate variable with incomplete type 'S1'}} + for (i = 0; i < argc; ++i) foo(); + +#pragma omp target +#pragma omp teams distribute parallel for firstprivate (argv[1]) // expected-error {{expected variable name}} + for (i = 0; i < argc; ++i) foo(); + +#pragma omp target +#pragma omp teams distribute parallel for firstprivate(ba) + for (i = 0; i < argc; ++i) foo(); + +#pragma omp target +#pragma omp teams distribute parallel for firstprivate(ca) // expected-error {{no matching constructor for initialization of 'S3'}} + for (i = 0; i < argc; ++i) foo(); + +#pragma omp target +#pragma omp teams distribute parallel for firstprivate(da) + for (i = 0; i < argc; ++i) foo(); + +#pragma omp target +#pragma omp teams distribute parallel for firstprivate(S2::S2s) + for (i = 0; i < argc; ++i) foo(); + +#pragma omp target +#pragma omp teams distribute parallel for firstprivate(S2::S2sc) + for (i = 0; i < argc; ++i) foo(); + +#pragma omp target +#pragma omp teams distribute parallel for firstprivate(h) // expected-error {{threadprivate or thread local variable cannot be firstprivate}} + for (i = 0; i < argc; ++i) foo(); + +#pragma omp target +#pragma omp teams distribute parallel for private(i), firstprivate(i) // expected-error {{private variable cannot be firstprivate}} expected-note {{defined as private}} + for (i = 0; i < argc; ++i) foo(); + +#pragma omp target +#pragma omp teams distribute parallel for firstprivate(i) + for (j = 0; j < argc; ++j) foo(); + +#pragma omp target +#pragma omp teams distribute parallel for firstprivate(i) // expected-note {{defined as firstprivate}} + for (i = 0; i < argc; ++i) foo(); // expected-error {{loop iteration variable in the associated loop of 'omp teams distribute parallel for' directive may not be firstprivate, predetermined as private}} + +#pragma omp target +#pragma omp teams distribute parallel for firstprivate(j) + for (i = 0; i < argc; ++i) foo(); + +#pragma omp target +#pragma omp teams distribute parallel for lastprivate(argc), firstprivate(argc) // OK + for (i = 0; i < argc; ++i) foo(); + + return 0; +} diff --git a/test/OpenMP/teams_distribute_parallel_for_if_messages.cpp b/test/OpenMP/teams_distribute_parallel_for_if_messages.cpp new file mode 100644 index 0000000000..67a89d1024 --- /dev/null +++ b/test/OpenMP/teams_distribute_parallel_for_if_messages.cpp @@ -0,0 +1,140 @@ +// RUN: %clang_cc1 -verify -fopenmp -ferror-limit 100 %s + +void foo() { +} + +bool foobool(int argc) { + return argc; +} + +struct S1; // expected-note {{declared here}} + +template <class T, class S> // expected-note {{declared here}} +int tmain(T argc, S **argv) { + T i; +#pragma omp target +#pragma omp teams distribute parallel for if // expected-error {{expected '(' after 'if'}} + for (i = 0; i < argc; ++i) foo(); +#pragma omp target +#pragma omp teams distribute parallel for if ( // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}} + for (i = 0; i < argc; ++i) foo(); +#pragma omp target +#pragma omp teams distribute parallel for if () // expected-error {{expected expression}} + for (i = 0; i < argc; ++i) foo(); +#pragma omp target +#pragma omp teams distribute parallel for if (argc // expected-error {{expected ')'}} expected-note {{to match this '('}} + for (i = 0; i < argc; ++i) foo(); +#pragma omp target +#pragma omp teams distribute parallel for if (argc)) // expected-warning {{extra tokens at the end of '#pragma omp teams distribute parallel for' are ignored}} + for (i = 0; i < argc; ++i) foo(); +#pragma omp target +#pragma omp teams distribute parallel for if (argc > 0 ? argv[1] : argv[2]) + for (i = 0; i < argc; ++i) foo(); +#pragma omp target +#pragma omp teams distribute parallel for if (foobool(argc)), if (true) // expected-error {{directive '#pragma omp teams distribute parallel for' cannot contain more than one 'if' clause}} + for (i = 0; i < argc; ++i) foo(); +#pragma omp target +#pragma omp teams distribute parallel for if (S) // expected-error {{'S' does not refer to a value}} + for (i = 0; i < argc; ++i) foo(); +#pragma omp target +#pragma omp teams distribute parallel for if (argv[1]=2) // expected-error {{expected ')'}} expected-note {{to match this '('}} + for (i = 0; i < argc; ++i) foo(); +#pragma omp target +#pragma omp teams distribute parallel for if (argc argc) // expected-error {{expected ')'}} expected-note {{to match this '('}} + for (i = 0; i < argc; ++i) foo(); +#pragma omp target +#pragma omp teams distribute parallel for if(argc) + for (i = 0; i < argc; ++i) foo(); +#pragma omp target +#pragma omp teams distribute parallel for if(parallel // expected-warning {{missing ':' after directive name modifier - ignoring}} expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}} + for (i = 0; i < argc; ++i) foo(); +#pragma omp target +#pragma omp teams distribute parallel for if(parallel : // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}} + for (i = 0; i < argc; ++i) foo(); +#pragma omp target +#pragma omp teams distribute parallel for if(parallel : argc // expected-error {{expected ')'}} expected-note {{to match this '('}} + for (i = 0; i < argc; ++i) foo(); +#pragma omp target +#pragma omp teams distribute parallel for if(parallel : argc) + for (i = 0; i < argc; ++i) foo(); +#pragma omp target +#pragma omp teams distribute parallel for if(parallel : argc) if (for:argc) // expected-error {{directive name modifier 'for' is not allowed for '#pragma omp teams distribute parallel for'}} + for (i = 0; i < argc; ++i) foo(); +#pragma omp target +#pragma omp teams distribute parallel for if(parallel : argc) if (parallel:argc) // expected-error {{directive '#pragma omp teams distribute parallel for' cannot contain more than one 'if' clause with 'parallel' name modifier}} + for (i = 0; i < argc; ++i) foo(); +#pragma omp target +#pragma omp teams distribute parallel for if(parallel : argc) if (argc) // expected-error {{no more 'if' clause is allowed}} expected-note {{previous clause with directive name modifier specified here}} + for (i = 0; i < argc; ++i) foo(); +#pragma omp target +#pragma omp teams distribute parallel for if(distribute : argc) // expected-error {{directive name modifier 'distribute' is not allowed for '#pragma omp teams distribute parallel for'}} + for (i = 0; i < argc; ++i) foo(); + + return 0; +} + +int main(int argc, char **argv) { + int i; +#pragma omp target +#pragma omp teams distribute parallel for if // expected-error {{expected '(' after 'if'}} + for (i = 0; i < argc; ++i) foo(); +#pragma omp target +#pragma omp teams distribute parallel for if ( // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}} + for (i = 0; i < argc; ++i) foo(); +#pragma omp target +#pragma omp teams distribute parallel for if () // expected-error {{expected expression}} + for (i = 0; i < argc; ++i) foo(); +#pragma omp target +#pragma omp teams distribute parallel for if (argc // expected-error {{expected ')'}} expected-note {{to match this '('}} + for (i = 0; i < argc; ++i) foo(); +#pragma omp target +#pragma omp teams distribute parallel for if (argc)) // expected-warning {{extra tokens at the end of '#pragma omp teams distribute parallel for' are ignored}} + for (i = 0; i < argc; ++i) foo(); +#pragma omp target +#pragma omp teams distribute parallel for if (argc > 0 ? argv[1] : argv[2]) + for (i = 0; i < argc; ++i) foo(); +#pragma omp target +#pragma omp teams distribute parallel for if (foobool(argc)), if (true) // expected-error {{directive '#pragma omp teams distribute parallel for' cannot contain more than one 'if' clause}} + for (i = 0; i < argc; ++i) foo(); +#pragma omp target +#pragma omp teams distribute parallel for if (S1) // expected-error {{'S1' does not refer to a value}} + for (i = 0; i < argc; ++i) foo(); +#pragma omp target +#pragma omp teams distribute parallel for if (argv[1]=2) // expected-error {{expected ')'}} expected-note {{to match this '('}} + for (i = 0; i < argc; ++i) foo(); +#pragma omp target +#pragma omp teams distribute parallel for if (argc argc) // expected-error {{expected ')'}} expected-note {{to match this '('}} + for (i = 0; i < argc; ++i) foo(); +#pragma omp target +#pragma omp teams distribute parallel for if (1 0) // expected-error {{expected ')'}} expected-note {{to match this '('}} + for (i = 0; i < argc; ++i) foo(); +#pragma omp target +#pragma omp teams distribute parallel for if(if(tmain(argc, argv) // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}} + for (i = 0; i < argc; ++i) foo(); +#pragma omp target +#pragma omp teams distribute parallel for if(parallel // expected-warning {{missing ':' after directive name modifier - ignoring}} expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}} + for (i = 0; i < argc; ++i) foo(); +#pragma omp target +#pragma omp teams distribute parallel for if(parallel : // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}} + for (i = 0; i < argc; ++i) foo(); +#pragma omp target +#pragma omp teams distribute parallel for if(parallel : argc // expected-error {{expected ')'}} expected-note {{to match this '('}} + for (i = 0; i < argc; ++i) foo(); +#pragma omp target +#pragma omp teams distribute parallel for if(parallel : argc) + for (i = 0; i < argc; ++i) foo(); +#pragma omp target +#pragma omp teams distribute parallel for if(parallel : argc) if (for:argc) // expected-error {{directive name modifier 'for' is not allowed for '#pragma omp teams distribute parallel for'}} + for (i = 0; i < argc; ++i) foo(); +#pragma omp target +#pragma omp teams distribute parallel for if(parallel : argc) if (parallel:argc) // expected-error {{directive '#pragma omp teams distribute parallel for' cannot contain more than one 'if' clause with 'parallel' name modifier}} + for (i = 0; i < argc; ++i) foo(); +#pragma omp target +#pragma omp teams distribute parallel for if(parallel : argc) if (argc) // expected-error {{no more 'if' clause is allowed}} expected-note {{previous clause with directive name modifier specified here}} + for (i = 0; i < argc; ++i) foo(); +#pragma omp target +#pragma omp teams distribute parallel for if(distribute : argc) // expected-error {{directive name modifier 'distribute' is not allowed for '#pragma omp teams distribute parallel for'}} + for (i = 0; i < argc; ++i) foo(); + + return tmain(argc, argv); +} diff --git a/test/OpenMP/teams_distribute_parallel_for_lastprivate_messages.cpp b/test/OpenMP/teams_distribute_parallel_for_lastprivate_messages.cpp new file mode 100644 index 0000000000..5691af71f7 --- /dev/null +++ b/test/OpenMP/teams_distribute_parallel_for_lastprivate_messages.cpp @@ -0,0 +1,272 @@ +// RUN: %clang_cc1 -verify -fopenmp %s + +void foo() { +} + +bool foobool(int argc) { + return argc; +} + +struct S1; // expected-note 2 {{declared here}} expected-note 2 {{forward declaration of 'S1'}} +extern S1 a; +class S2 { + mutable int a; + +public: + S2() : a(0) {} + S2(S2 &s2) : a(s2.a) {} + const S2 &operator =(const S2&) const; + S2 &operator =(const S2&); + static float S2s; // expected-note {{static data member is predetermined as shared}} + static const float S2sc; +}; +const float S2::S2sc = 0; // expected-note {{static data member is predetermined as shared}} +const S2 b; +const S2 ba[5]; +class S3 { + int a; + S3 &operator=(const S3 &s3); // expected-note 2 {{implicitly declared private here}} + +public: + S3() : a(0) {} + S3(S3 &s3) : a(s3.a) {} +}; +const S3 c; // expected-note {{global variable is predetermined as shared}} +const S3 ca[5]; // expected-note {{global variable is predetermined as shared}} +extern const int f; // expected-note {{global variable is predetermined as shared}} +class S4 { + int a; + S4(); // expected-note 3 {{implicitly declared private here}} + S4(const S4 &s4); + +public: + S4(int v) : a(v) {} +}; +class S5 { + int a; + S5() : a(0) {} // expected-note {{implicitly declared private here}} + +public: + S5(const S5 &s5) : a(s5.a) {} + S5(int v) : a(v) {} +}; +class S6 { + int a; + S6() : a(0) {} + +public: + S6(const S6 &s6) : a(s6.a) {} + S6(int v) : a(v) {} +}; + +S3 h; +#pragma omp threadprivate(h) // expected-note 2 {{defined as threadprivate or thread local}} + +template <class I, class C> +int foomain(int argc, char **argv) { + I e(4); + I g(5); + int i; + int &j = i; +#pragma omp target +#pragma omp teams distribute parallel for lastprivate // expected-error {{expected '(' after 'lastprivate'}} + for (int k = 0; k < argc; ++k) ++k; + +#pragma omp target +#pragma omp teams distribute parallel for lastprivate( // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}} + for (int k = 0; k < argc; ++k) ++k; + +#pragma omp target +#pragma omp teams distribute parallel for lastprivate() // expected-error {{expected expression}} + for (int k = 0; k < argc; ++k) ++k; + +#pragma omp target +#pragma omp teams distribute parallel for lastprivate(argc // expected-error {{expected ')'}} expected-note {{to match this '('}} + for (int k = 0; k < argc; ++k) ++k; + +#pragma omp target +#pragma omp teams distribute parallel for lastprivate(argc, // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}} + for (int k = 0; k < argc; ++k) ++k; + +#pragma omp target +#pragma omp teams distribute parallel for lastprivate(argc > 0 ? argv[1] : argv[2]) // expected-error {{expected variable name}} + for (int k = 0; k < argc; ++k) ++k; + +#pragma omp target +#pragma omp teams distribute parallel for lastprivate(argc) + for (int k = 0; k < argc; ++k) ++k; + +#pragma omp target +#pragma omp teams distribute parallel for lastprivate(S1) // expected-error {{'S1' does not refer to a value}} + for (int k = 0; k < argc; ++k) ++k; + +#pragma omp target +#pragma omp teams distribute parallel for lastprivate(a, b) // expected-error {{lastprivate variable with incomplete type 'S1'}} + for (int k = 0; k < argc; ++k) ++k; + +#pragma omp target +#pragma omp teams distribute parallel for lastprivate(argv[1]) // expected-error {{expected variable name}} + for (int k = 0; k < argc; ++k) ++k; + +#pragma omp target +#pragma omp teams distribute parallel for lastprivate(e, g) // expected-error 2 {{calling a private constructor of class 'S4'}} + for (int k = 0; k < argc; ++k) ++k; + +#pragma omp target +#pragma omp teams distribute parallel for lastprivate(h) // expected-error {{threadprivate or thread local variable cannot be lastprivate}} + for (int k = 0; k < argc; ++k) ++k; + + int v = 0; +#pragma omp target +#pragma omp teams distribute parallel for lastprivate(i) + for (int k = 0; k < argc; ++k) { + i = k; + v += i; + } + +#pragma omp target +#pragma omp teams distribute parallel for lastprivate(j) private(i) + for (int k = 0; k < argc; ++k) ++k; + +#pragma omp target +#pragma omp teams distribute parallel for lastprivate(i) + for (int k = 0; k < argc; ++k) ++k; + + return 0; +} + +void bar(S4 a[2]) { +#pragma omp target +#pragma omp teams distribute parallel for lastprivate(a) + for (int i = 0; i < 2; ++i) foo(); +} + +namespace A { +double x; +#pragma omp threadprivate(x) // expected-note {{defined as threadprivate or thread local}} +} +namespace B { +using A::x; +} + +int main(int argc, char **argv) { + const int d = 5; // expected-note {{constant variable is predetermined as shared}} + const int da[5] = {0}; // expected-note {{constant variable is predetermined as shared}} + S4 e(4); + S5 g(5); + S3 m; + S6 n(2); + int i; + int &j = i; +#pragma omp target +#pragma omp teams distribute parallel for lastprivate // expected-error {{expected '(' after 'lastprivate'}} + for (i = 0; i < argc; ++i) foo(); + +#pragma omp target +#pragma omp teams distribute parallel for lastprivate( // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}} + for (i = 0; i < argc; ++i) foo(); + +#pragma omp target +#pragma omp teams distribute parallel for lastprivate() // expected-error {{expected expression}} + for (i = 0; i < argc; ++i) foo(); + +#pragma omp target +#pragma omp teams distribute parallel for lastprivate(argc // expected-error {{expected ')'}} expected-note {{to match this '('}} + for (i = 0; i < argc; ++i) foo(); + +#pragma omp target +#pragma omp teams distribute parallel for lastprivate(argc, // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}} + for (i = 0; i < argc; ++i) foo(); + +#pragma omp target +#pragma omp teams distribute parallel for lastprivate(argc > 0 ? argv[1] : argv[2]) // expected-error {{expected variable name}} + for (i = 0; i < argc; ++i) foo(); + +#pragma omp target +#pragma omp teams distribute parallel for lastprivate(argc) + for (i = 0; i < argc; ++i) foo(); + +#pragma omp target +#pragma omp teams distribute parallel for lastprivate(S1) // expected-error {{'S1' does not refer to a value}} + for (i = 0; i < argc; ++i) foo(); + +#pragma omp target +#pragma omp teams distribute parallel for lastprivate(a, b, c, d, f) // expected-error {{lastprivate variable with incomplete type 'S1'}} expected-error 3 {{shared variable cannot be lastprivate}} + for (i = 0; i < argc; ++i) foo(); + +#pragma omp target +#pragma omp teams distribute parallel for lastprivate(argv[1]) // expected-error {{expected variable name}} + for (i = 0; i < argc; ++i) foo(); + +#pragma omp target +#pragma omp teams distribute parallel for lastprivate(2 * 2) // expected-error {{expected variable name}} + for (i = 0; i < argc; ++i) foo(); + +#pragma omp target +#pragma omp teams distribute parallel for lastprivate(ba) + for (i = 0; i < argc; ++i) foo(); + +#pragma omp target +#pragma omp teams distribute parallel for lastprivate(ca) // expected-error {{shared variable cannot be lastprivate}} + for (i = 0; i < argc; ++i) foo(); + +#pragma omp target +#pragma omp teams distribute parallel for lastprivate(da) // expected-error {{shared variable cannot be lastprivate}} + for (i = 0; i < argc; ++i) foo(); + + int xa; +#pragma omp target +#pragma omp teams distribute parallel for lastprivate(xa) // OK + for (i = 0; i < argc; ++i) foo(); + +#pragma omp target +#pragma omp teams distribute parallel for lastprivate(S2::S2s) // expected-error {{shared variable cannot be lastprivate}} + for (i = 0; i < argc; ++i) foo(); + +#pragma omp target +#pragma omp teams distribute parallel for lastprivate(S2::S2sc) // expected-error {{shared variable cannot be lastprivate}} + for (i = 0; i < argc; ++i) foo(); + +#pragma omp target +#pragma omp teams distribute parallel for lastprivate(e, g) // expected-error {{calling a private constructor of class 'S4'}} expected-error {{calling a private constructor of class 'S5'}} + for (i = 0; i < argc; ++i) foo(); + +#pragma omp target +#pragma omp teams distribute parallel for lastprivate(m) // expected-error {{'operator=' is a private member of 'S3'}} + for (i = 0; i < argc; ++i) foo(); + +#pragma omp target +#pragma omp teams distribute parallel for lastprivate(h) // expected-error {{threadprivate or thread local variable cannot be lastprivate}} + for (i = 0; i < argc; ++i) foo(); + +#pragma omp target +#pragma omp teams distribute parallel for lastprivate(B::x) // expected-error {{threadprivate or thread local variable cannot be lastprivate}} + for (i = 0; i < argc; ++i) foo(); + +#pragma omp target +#pragma omp teams distribute parallel for private(xa), lastprivate(xa) // expected-error {{private variable cannot be lastprivate}} expected-note {{defined as private}} + for (i = 0; i < argc; ++i) foo(); + +#pragma omp target +#pragma omp teams distribute parallel for lastprivate(xa) + for (i = 0; i < argc; ++i) foo(); + +#pragma omp target +#pragma omp teams distribute parallel for lastprivate(j) + for (i = 0; i < argc; ++i) foo(); + +#pragma omp target +#pragma omp teams distribute parallel for firstprivate(m) lastprivate(m) // expected-error {{'operator=' is a private member of 'S3'}} + for (i = 0; i < argc; ++i) foo(); + +#pragma omp target +#pragma omp teams distribute parallel for lastprivate(n) firstprivate(n) // OK + for (i = 0; i < argc; ++i) foo(); + + static int si; +#pragma omp target +#pragma omp teams distribute parallel for lastprivate(si) // OK + for (i = 0; i < argc; ++i) si = i + 1; + + return foomain<S4, S5>(argc, argv); // expected-note {{in instantiation of function template specialization 'foomain<S4, S5>' requested here}} +} diff --git a/test/OpenMP/teams_distribute_parallel_for_linear_messages.cpp b/test/OpenMP/teams_distribute_parallel_for_linear_messages.cpp new file mode 100644 index 0000000000..b14fb2328b --- /dev/null +++ b/test/OpenMP/teams_distribute_parallel_for_linear_messages.cpp @@ -0,0 +1,293 @@ +// RUN: %clang_cc1 -verify -fopenmp %s + +namespace X { + int x; +}; + +struct B { + static int ib; // expected-note {{'B::ib' declared here}} + static int bfoo() { return 8; } +}; + +int bfoo() { return 4; } + +int z; +const int C1 = 1; +const int C2 = 2; +void test_linear_colons() +{ + int B = 0; + +#pragma omp target +#pragma omp teams distribute parallel for linear(B:bfoo()) + for (int i = 0; i < 10; ++i) ; + +#pragma omp target +#pragma omp teams distribute parallel for linear(B::ib:B:bfoo()) // expected-error {{unexpected ':' in nested name specifier; did you mean '::'}} + for (int i = 0; i < 10; ++i) ; + +#pragma omp target +#pragma omp teams distribute parallel for linear(B:ib) // expected-error {{use of undeclared identifier 'ib'; did you mean 'B::ib'}} + for (int i = 0; i < 10; ++i) ; + +#pragma omp target +#pragma omp teams distribute parallel for linear(z:B:ib) // expected-error {{unexpected ':' in nested name specifier; did you mean '::'?}} + for (int i = 0; i < 10; ++i) ; + +#pragma omp target +#pragma omp teams distribute parallel for linear(B:B::bfoo()) + for (int i = 0; i < 10; ++i) ; + +#pragma omp target +#pragma omp teams distribute parallel for linear(X::x : ::z) + for (int i = 0; i < 10; ++i) ; + +#pragma omp target +#pragma omp teams distribute parallel for linear(B,::z, X::x) + for (int i = 0; i < 10; ++i) ; + +#pragma omp target +#pragma omp teams distribute parallel for linear(::z) + for (int i = 0; i < 10; ++i) ; + +#pragma omp target +#pragma omp teams distribute parallel for linear(B::bfoo()) // expected-error {{expected variable name}} + for (int i = 0; i < 10; ++i) ; + +#pragma omp target +#pragma omp teams distribute parallel for linear(B::ib,B:C1+C2) + for (int i = 0; i < 10; ++i) ; +} + +template<int L, class T, class N> T test_template(T* arr, N num) { + N i; + T sum = (T)0; + T ind2 = - num * L; // expected-note {{'ind2' defined here}} + +#pragma omp target +#pragma omp teams distribute parallel for linear(ind2:L) // expected-error {{argument of a linear clause should be of integral or pointer type}} + for (i = 0; i < num; ++i) { + T cur = arr[(int)ind2]; + ind2 += L; + sum += cur; + } + return T(); +} + +template<int LEN> int test_warn() { + int ind2 = 0; + #pragma omp target + #pragma omp teams distribute parallel for linear(ind2:LEN) // expected-warning {{zero linear step (ind2 should probably be const)}} + for (int i = 0; i < 100; i++) { + ind2 += LEN; + } + return ind2; +} + +struct S1; // expected-note 2 {{declared here}} expected-note 2 {{forward declaration of 'S1'}} +extern S1 a; +class S2 { + mutable int a; +public: + S2():a(0) { } +}; +const S2 b; // expected-note 2 {{'b' defined here}} +const S2 ba[5]; +class S3 { + int a; +public: + S3():a(0) { } +}; +const S3 ca[5]; +class S4 { + int a; + S4(); +public: + S4(int v):a(v) { } +}; +class S5 { + int a; + S5():a(0) {} +public: + S5(int v):a(v) { } +}; + +S3 h; +#pragma omp threadprivate(h) // expected-note 2 {{defined as threadprivate or thread local}} + +template<class I, class C> int foomain(I argc, C **argv) { + I e(4); + I g(5); + int i; + int &j = i; + +#pragma omp target +#pragma omp teams distribute parallel for linear // expected-error {{expected '(' after 'linear'}} + for (int k = 0; k < argc; ++k) ++k; + +#pragma omp target +#pragma omp teams distribute parallel for linear ( // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}} + for (int k = 0; k < argc; ++k) ++k; + +#pragma omp target +#pragma omp teams distribute parallel for linear () // expected-error {{expected expression}} + for (int k = 0; k < argc; ++k) ++k; + +#pragma omp target +#pragma omp teams distribute parallel for linear (argc // expected-error {{expected ')'}} expected-note {{to match this '('}} + for (int k = 0; k < argc; ++k) ++k; + +#pragma omp target +#pragma omp teams distribute parallel for linear (argc, // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}} + for (int k = 0; k < argc; ++k) ++k; + +#pragma omp target +#pragma omp teams distribute parallel for linear (argc > 0 ? argv[1] : argv[2]) // expected-error {{expected variable name}} + for (int k = 0; k < argc; ++k) ++k; + +#pragma omp target +#pragma omp teams distribute parallel for linear (argc : 5) + for (int k = 0; k < argc; ++k) ++k; + +#pragma omp target +#pragma omp teams distribute parallel for linear (S1) // expected-error {{'S1' does not refer to a value}} + for (int k = 0; k < argc; ++k) ++k; + +#pragma omp target +#pragma omp teams distribute parallel for linear (a, b:B::ib) // expected-error {{linear variable with incomplete type 'S1'}} expected-error {{const-qualified variable cannot be linear}} + for (int k = 0; k < argc; ++k) ++k; + +#pragma omp target +#pragma omp teams distribute parallel for linear (argv[1]) // expected-error {{expected variable name}} + for (int k = 0; k < argc; ++k) ++k; + +#pragma omp target +#pragma omp teams distribute parallel for linear(e, g) + for (int k = 0; k < argc; ++k) ++k; + +#pragma omp target +#pragma omp teams distribute parallel for linear(h) // expected-error {{threadprivate or thread local variable cannot be linear}} + for (int k = 0; k < argc; ++k) ++k; + +#pragma omp target +#pragma omp teams distribute parallel for linear(i) + for (int k = 0; k < argc; ++k) ++k; + + #pragma omp parallel + { + int v = 0; + int i; + #pragma omp target + #pragma omp teams distribute parallel for linear(v:i) + for (int k = 0; k < argc; ++k) { i = k; v += i; } + } + +#pragma omp target +#pragma omp teams distribute parallel for linear(j) + for (int k = 0; k < argc; ++k) ++k; + + int v = 0; + +#pragma omp target +#pragma omp teams distribute parallel for linear(v:j) + for (int k = 0; k < argc; ++k) { ++k; v += j; } + +#pragma omp target +#pragma omp teams distribute parallel for linear(i) + for (int k = 0; k < argc; ++k) ++k; + return 0; +} + +namespace A { +double x; +#pragma omp threadprivate(x) // expected-note {{defined as threadprivate or thread local}} +} +namespace C { +using A::x; +} + +int main(int argc, char **argv) { + double darr[100]; + // expected-note@+1 {{in instantiation of function template specialization 'test_template<-4, double, int>' requested here}} + test_template<-4>(darr, 4); + // expected-note@+1 {{in instantiation of function template specialization 'test_warn<0>' requested here}} + test_warn<0>(); + + S4 e(4); // expected-note {{'e' defined here}} + S5 g(5); // expected-note {{'g' defined here}} + int i; + int &j = i; + +#pragma omp target +#pragma omp teams distribute parallel for linear // expected-error {{expected '(' after 'linear'}} + for (int k = 0; k < argc; ++k) ++k; + +#pragma omp target +#pragma omp teams distribute parallel for linear ( // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}} + for (int k = 0; k < argc; ++k) ++k; + +#pragma omp target +#pragma omp teams distribute parallel for linear () // expected-error {{expected expression}} + for (int k = 0; k < argc; ++k) ++k; + +#pragma omp target +#pragma omp teams distribute parallel for linear (argc // expected-error {{expected ')'}} expected-note {{to match this '('}} + for (int k = 0; k < argc; ++k) ++k; + +#pragma omp target +#pragma omp teams distribute parallel for linear (argc, // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}} + for (int k = 0; k < argc; ++k) ++k; + +#pragma omp target +#pragma omp teams distribute parallel for linear (argc > 0 ? argv[1] : argv[2]) // expected-error {{expected variable name}} + for (int k = 0; k < argc; ++k) ++k; + +#pragma omp target +#pragma omp teams distribute parallel for linear (argc) + for (int k = 0; k < argc; ++k) ++k; + +#pragma omp target +#pragma omp teams distribute parallel for linear (S1) // expected-error {{'S1' does not refer to a value}} + for (int k = 0; k < argc; ++k) ++k; + + +#pragma omp target +#pragma omp teams distribute parallel for linear (a, b) // expected-error {{linear variable with incomplete type 'S1'}} expected-error {{const-qualified variable cannot be linear}} + for (int k = 0; k < argc; ++k) ++k; + +#pragma omp target +#pragma omp teams distribute parallel for linear (argv[1]) // expected-error {{expected variable name}} + for (int k = 0; k < argc; ++k) ++k; + +#pragma omp target +#pragma omp teams distribute parallel for linear(e, g) // expected-error {{argument of a linear clause should be of integral or pointer type, not 'S4'}} expected-error {{argument of a linear clause should be of integral or pointer type, not 'S5'}} + for (int k = 0; k < argc; ++k) ++k; + +#pragma omp target +#pragma omp teams distribute parallel for linear(h, C::x) // expected-error 2 {{threadprivate or thread local variable cannot be linear}} + for (int k = 0; k < argc; ++k) ++k; + + #pragma omp parallel + { + int i; + #pragma omp target + #pragma omp teams distribute parallel for linear(i) + for (int k = 0; k < argc; ++k) ++k; + + #pragma omp target + #pragma omp teams distribute parallel for linear(i : 4) + for (int k = 0; k < argc; ++k) { ++k; i += 4; } + } + +#pragma omp target +#pragma omp teams distribute parallel for linear(j) + for (int k = 0; k < argc; ++k) ++k; + +#pragma omp target +#pragma omp teams distribute parallel for linear(i) + for (int k = 0; k < argc; ++k) ++k; + + foomain<int,char>(argc,argv); // expected-note {{in instantiation of function template specialization 'foomain<int, char>' requested here}} + return 0; +} + diff --git a/test/OpenMP/teams_distribute_parallel_for_loop_messages.cpp b/test/OpenMP/teams_distribute_parallel_for_loop_messages.cpp new file mode 100644 index 0000000000..ea392fb93e --- /dev/null +++ b/test/OpenMP/teams_distribute_parallel_for_loop_messages.cpp @@ -0,0 +1,714 @@ +// RUN: %clang_cc1 -fsyntax-only -fopenmp -x c++ -std=c++11 -fexceptions -fcxx-exceptions -verify %s + +class S { + int a; + S() : a(0) {} + +public: + S(int v) : a(v) {} + S(const S &s) : a(s.a) {} +}; + +static int sii; +// expected-note@+1 {{defined as threadprivate or thread local}} +#pragma omp threadprivate(sii) +static int globalii; + +int test_iteration_spaces() { + const int N = 100; + float a[N], b[N], c[N]; + int ii, jj, kk; + float fii; + double dii; +#pragma omp target +#pragma omp teams distribute parallel for + for (int i = 0; i < 10; i += 1) { + c[i] = a[i] + b[i]; + } +#pragma omp target +#pragma omp teams distribute parallel for + for (char i = 0; i < 10; i++) { + c[i] = a[i] + b[i]; + } +#pragma omp target +#pragma omp teams distribute parallel for + for (char i = 0; i < 10; i += '\1') { + c[i] = a[i] + b[i]; + } +#pragma omp target +#pragma omp teams distribute parallel for + for (long long i = 0; i < 10; i++) { + c[i] = a[i] + b[i]; + } +#pragma omp target +#pragma omp teams distribute parallel for +// expected-error@+1 {{expression must have integral or unscoped enumeration type, not 'double'}} + for (long long i = 0; i < 10; i += 1.5) { + c[i] = a[i] + b[i]; + } +#pragma omp target +#pragma omp teams distribute parallel for + for (long long i = 0; i < 'z'; i += 1u) { + c[i] = a[i] + b[i]; + } +#pragma omp target +#pragma omp teams distribute parallel for +// expected-error@+1 {{variable must be of integer or random access iterator type}} + for (float fi = 0; fi < 10.0; fi++) { + c[(int)fi] = a[(int)fi] + b[(int)fi]; + } +#pragma omp target +#pragma omp teams distribute parallel for +// expected-error@+1 {{variable must be of integer or random access iterator type}} + for (double fi = 0; fi < 10.0; fi++) { + c[(int)fi] = a[(int)fi] + b[(int)fi]; + } +#pragma omp target +#pragma omp teams distribute parallel for +// expected-error@+1 {{initialization clause of OpenMP for loop is not in canonical form ('var = init' or 'T var = init')}} + for (int &ref = ii; ref < 10; ref++) { + } +#pragma omp target +#pragma omp teams distribute parallel for +// expected-error@+1 {{initialization clause of OpenMP for loop is not in canonical form ('var = init' or 'T var = init')}} + for (int i; i < 10; i++) + c[i] = a[i]; + +#pragma omp target +#pragma omp teams distribute parallel for +// expected-error@+1 {{initialization clause of OpenMP for loop is not in canonical form ('var = init' or 'T var = init')}} + for (int i = 0, j = 0; i < 10; ++i) + c[i] = a[i]; + +#pragma omp target +#pragma omp teams distribute parallel for +// expected-error@+1 {{initialization clause of OpenMP for loop is not in canonical form ('var = init' or 'T var = init')}} + for (; ii < 10; ++ii) + c[ii] = a[ii]; + +#pragma omp target +#pragma omp teams distribute parallel for +// expected-warning@+2 {{expression result unused}} +// expected-error@+1 {{initialization clause of OpenMP for loop is not in canonical form ('var = init' or 'T var = init')}} + for (ii + 1; ii < 10; ++ii) + c[ii] = a[ii]; + +#pragma omp target +#pragma omp teams distribute parallel for +// expected-error@+1 {{initialization clause of OpenMP for loop is not in canonical form ('var = init' or 'T var = init')}} + for (c[ii] = 0; ii < 10; ++ii) + c[ii] = a[ii]; + +#pragma omp target +#pragma omp teams distribute parallel for +// Ok to skip parenthesises. + for (((ii)) = 0; ii < 10; ++ii) + c[ii] = a[ii]; + +#pragma omp target +#pragma omp teams distribute parallel for +// expected-error@+1 {{condition of OpenMP for loop must be a relational comparison ('<', '<=', '>', or '>=') of loop variable 'i'}} + for (int i = 0; i; i++) + c[i] = a[i]; + +#pragma omp target +#pragma omp teams distribute parallel for +// expected-error@+2 {{condition of OpenMP for loop must be a relational comparison ('<', '<=', '>', or '>=') of loop variable 'i'}} +// expected-error@+1 {{increment clause of OpenMP for loop must perform simple addition or subtraction on loop variable 'i'}} + for (int i = 0; jj < kk; ii++) + c[i] = a[i]; + +#pragma omp target +#pragma omp teams distribute parallel for +// expected-error@+1 {{condition of OpenMP for loop must be a relational comparison ('<', '<=', '>', or '>=') of loop variable 'i'}} + for (int i = 0; !!i; i++) + c[i] = a[i]; + +#pragma omp target +#pragma omp teams distribute parallel for +// expected-error@+1 {{condition of OpenMP for loop must be a relational comparison ('<', '<=', '>', or '>=') of loop variable 'i'}} + for (int i = 0; i != 1; i++) + c[i] = a[i]; + +#pragma omp target +#pragma omp teams distribute parallel for +// expected-error@+1 {{condition of OpenMP for loop must be a relational comparison ('<', '<=', '>', or '>=') of loop variable 'i'}} + for (int i = 0;; i++) + c[i] = a[i]; + +// Ok. +#pragma omp target +#pragma omp teams distribute parallel for + for (int i = 11; i > 10; i--) + c[i] = a[i]; + +// Ok. +#pragma omp target +#pragma omp teams distribute parallel for + for (int i = 0; i < 10; ++i) + c[i] = a[i]; + +// Ok. +#pragma omp target +#pragma omp teams distribute parallel for + for (ii = 0; ii < 10; ++ii) + c[ii] = a[ii]; + +#pragma omp target +#pragma omp teams distribute parallel for +// expected-error@+1 {{increment clause of OpenMP for loop must perform simple addition or subtraction on loop variable 'ii'}} + for (ii = 0; ii < 10; ++jj) + c[ii] = a[jj]; + +#pragma omp target +#pragma omp teams distribute parallel for +// expected-error@+1 {{increment clause of OpenMP for loop must perform simple addition or subtraction on loop variable 'ii'}} + for (ii = 0; ii < 10; ++++ii) + c[ii] = a[ii]; + +// Ok but undefined behavior (in general, cannot check that incr +// is really loop-invariant). +#pragma omp target +#pragma omp teams distribute parallel for + for (ii = 0; ii < 10; ii = ii + ii) + c[ii] = a[ii]; + +#pragma omp target +#pragma omp teams distribute parallel for +// expected-error@+1 {{expression must have integral or unscoped enumeration type, not 'float'}} + for (ii = 0; ii < 10; ii = ii + 1.0f) + c[ii] = a[ii]; + +// Ok - step was converted to integer type. +#pragma omp target +#pragma omp teams distribute parallel for + for (ii = 0; ii < 10; ii = ii + (int)1.1f) + c[ii] = a[ii]; + +#pragma omp target +#pragma omp teams distribute parallel for +// expected-error@+1 {{increment clause of OpenMP for loop must perform simple addition or subtraction on loop variable 'ii'}} + for (ii = 0; ii < 10; jj = ii + 2) + c[ii] = a[ii]; + +#pragma omp target +#pragma omp teams distribute parallel for +// expected-warning@+2 {{relational comparison result unused}} +// expected-error@+1 {{increment clause of OpenMP for loop must perform simple addition or subtraction on loop variable 'ii'}} + for (ii = 0; ii<10; jj> kk + 2) + c[ii] = a[ii]; + +#pragma omp target +#pragma omp teams distribute parallel for +// expected-error@+1 {{increment clause of OpenMP for loop must perform simple addition or subtraction on loop variable 'ii'}} + for (ii = 0; ii < 10;) + c[ii] = a[ii]; + +#pragma omp target +#pragma omp teams distribute parallel for +// expected-warning@+2 {{expression result unused}} +// expected-error@+1 {{increment clause of OpenMP for loop must perform simple addition or subtraction on loop variable 'ii'}} + for (ii = 0; ii < 10; !ii) + c[ii] = a[ii]; + +#pragma omp target +#pragma omp teams distribute parallel for +// expected-error@+1 {{increment clause of OpenMP for loop must perform simple addition or subtraction on loop variable 'ii'}} + for (ii = 0; ii < 10; ii ? ++ii : ++jj) + c[ii] = a[ii]; + +#pragma omp target +#pragma omp teams distribute parallel for +// expected-error@+1 {{increment clause of OpenMP for loop must perform simple addition or subtraction on loop variable 'ii'}} + for (ii = 0; ii < 10; ii = ii < 10) + c[ii] = a[ii]; + +#pragma omp target +#pragma omp teams distribute parallel for +// expected-note@+2 {{loop step is expected to be positive due to this condition}} +// expected-error@+1 {{increment expression must cause 'ii' to increase on each iteration of OpenMP for loop}} + for (ii = 0; ii < 10; ii = ii + 0) + c[ii] = a[ii]; + +#pragma omp target +#pragma omp teams distribute parallel for +// expected-note@+2 {{loop step is expected to be positive due to this condition}} +// expected-error@+1 {{increment expression must cause 'ii' to increase on each iteration of OpenMP for loop}} + for (ii = 0; ii < 10; ii = ii + (int)(0.8 - 0.45)) + c[ii] = a[ii]; + +#pragma omp target +#pragma omp teams distribute parallel for +// expected-note@+2 {{loop step is expected to be positive due to this condition}} +// expected-error@+1 {{increment expression must cause 'ii' to increase on each iteration of OpenMP for loop}} + for (ii = 0; (ii) < 10; ii -= 25) + c[ii] = a[ii]; + +#pragma omp target +#pragma omp teams distribute parallel for +// expected-note@+2 {{loop step is expected to be positive due to this condition}} +// expected-error@+1 {{increment expression must cause 'ii' to increase on each iteration of OpenMP for loop}} + for (ii = 0; (ii < 10); ii -= 0) + c[ii] = a[ii]; + +#pragma omp target +#pragma omp teams distribute parallel for +// expected-note@+2 {{loop step is expected to be negative due to this condition}} +// expected-error@+1 {{increment expression must cause 'ii' to decrease on each iteration of OpenMP for loop}} + for (ii = 0; ii > 10; (ii += 0)) + c[ii] = a[ii]; + +#pragma omp target +#pragma omp teams distribute parallel for +// expected-note@+2 {{loop step is expected to be positive due to this condition}} +// expected-error@+1 {{increment expression must cause 'ii' to increase on each iteration of OpenMP for loop}} + for (ii = 0; ii < 10; (ii) = (1 - 1) + (ii)) + c[ii] = a[ii]; + +#pragma omp target +#pragma omp teams distribute parallel for +// expected-note@+2 {{loop step is expected to be negative due to this condition}} +// expected-error@+1 {{increment expression must cause 'ii' to decrease on each iteration of OpenMP for loop}} + for ((ii = 0); ii > 10; (ii -= 0)) + c[ii] = a[ii]; + +#pragma omp target +#pragma omp teams distribute parallel for +// expected-note@+2 {{loop step is expected to be positive due to this condition}} +// expected-error@+1 {{increment expression must cause 'ii' to increase on each iteration of OpenMP for loop}} + for (ii = 0; (ii < 10); (ii -= 0)) + c[ii] = a[ii]; + +#pragma omp target +#pragma omp teams distribute parallel for firstprivate(ii) // expected-note {{defined as firstprivate}} +// expected-error@+1 {{loop iteration variable in the associated loop of 'omp teams distribute parallel for' directive may not be firstprivate, predetermined as private}} + for (ii = 0; ii < 10; ii++) + c[ii] = a[ii]; + +#pragma omp target +#pragma omp teams distribute parallel for private(ii) // OK + for (ii = 0; ii < 10; ii++) + c[ii] = a[ii]; + +#pragma omp target +#pragma omp teams distribute parallel for lastprivate(ii) // OK + for (ii = 0; ii < 10; ii++) + c[ii] = a[ii]; + +#pragma omp target +#pragma omp teams distribute parallel for +// expected-error@+1 {{loop iteration variable in the associated loop of 'omp teams distribute parallel for' directive may not be threadprivate or thread local, predetermined as private}} + for (sii = 0; sii < 10; sii++) + c[sii] = a[sii]; + + { +#pragma omp target +#pragma omp teams distribute parallel for collapse(2) + for (ii = 0; ii < 10; ii += 1) + for (globalii = 0; globalii < 10; globalii += 1) + c[globalii] += a[globalii] + ii; + } + +#pragma omp target +#pragma omp teams distribute parallel for +// expected-error@+1 {{statement after '#pragma omp teams distribute parallel for' must be a for loop}} + for (auto &item : a) { + item = item + 1; + } + +#pragma omp target +#pragma omp teams distribute parallel for +// expected-note@+2 {{loop step is expected to be positive due to this condition}} +// expected-error@+1 {{increment expression must cause 'i' to increase on each iteration of OpenMP for loop}} + for (unsigned i = 9; i < 10; i--) { + c[i] = a[i] + b[i]; + } + + int(*lb)[4] = nullptr; +#pragma omp target +#pragma omp teams distribute parallel for + for (int(*p)[4] = lb; p < lb + 8; ++p) { + } + +#pragma omp target +#pragma omp teams distribute parallel for +// expected-warning@+1 {{initialization clause of OpenMP for loop is not in canonical form ('var = init' or 'T var = init')}} + for (int a{0}; a < 10; ++a) { + } + + return 0; +} + +// Iterators allowed in openmp for-loops. +namespace std { +struct random_access_iterator_tag {}; +template <class Iter> +struct iterator_traits { + typedef typename Iter::difference_type difference_type; + typedef typename Iter::iterator_category iterator_category; +}; +template <class Iter> +typename iterator_traits<Iter>::difference_type +distance(Iter first, Iter last) { return first - last; } +} +class Iter0 { +public: + Iter0() {} + Iter0(const Iter0 &) {} + Iter0 operator++() { return *this; } + Iter0 operator--() { return *this; } + bool operator<(Iter0 a) { return true; } +}; +// expected-note@+2 {{candidate function not viable: no known conversion from 'GoodIter' to 'Iter0' for 1st argument}} +// expected-note@+1 2 {{candidate function not viable: no known conversion from 'Iter1' to 'Iter0' for 1st argument}} +int operator-(Iter0 a, Iter0 b) { return 0; } +class Iter1 { +public: + Iter1(float f = 0.0f, double d = 0.0) {} + Iter1(const Iter1 &) {} + Iter1 operator++() { return *this; } + Iter1 operator--() { return *this; } + bool operator<(Iter1 a) { return true; } + bool operator>=(Iter1 a) { return false; } +}; +class GoodIter { +public: + GoodIter() {} + GoodIter(const GoodIter &) {} + GoodIter(int fst, int snd) {} + GoodIter &operator=(const GoodIter &that) { return *this; } + GoodIter &operator=(const Iter0 &that) { return *this; } + GoodIter &operator+=(int x) { return *this; } + explicit GoodIter(void *) {} + GoodIter operator++() { return *this; } + GoodIter operator--() { return *this; } + bool operator!() { return true; } + bool operator<(GoodIter a) { return true; } + bool operator<=(GoodIter a) { return true; } + bool operator>=(GoodIter a) { return false; } + typedef int difference_type; + typedef std::random_access_iterator_tag iterator_category; +}; +// expected-note@+2 {{candidate function not viable: no known conversion from 'const Iter0' to 'GoodIter' for 2nd argument}} +// expected-note@+1 2 {{candidate function not viable: no known conversion from 'Iter1' to 'GoodIter' for 1st argument}} +int operator-(GoodIter a, GoodIter b) { return 0; } +// expected-note@+1 3 {{candidate function not viable: requires single argument 'a', but 2 arguments were provided}} +GoodIter operator-(GoodIter a) { return a; } +// expected-note@+2 {{candidate function not viable: no known conversion from 'const Iter0' to 'int' for 2nd argument}} +// expected-note@+1 2 {{candidate function not viable: no known conversion from 'Iter1' to 'GoodIter' for 1st argument}} +GoodIter operator-(GoodIter a, int v) { return GoodIter(); } +// expected-note@+1 2 {{candidate function not viable: no known conversion from 'Iter0' to 'GoodIter' for 1st argument}} +GoodIter operator+(GoodIter a, int v) { return GoodIter(); } +// expected-note@+2 {{candidate function not viable: no known conversion from 'GoodIter' to 'int' for 1st argument}} +// expected-note@+1 2 {{candidate function not viable: no known conversion from 'Iter1' to 'int' for 1st argument}} +GoodIter operator-(int v, GoodIter a) { return GoodIter(); } +// expected-note@+1 2 {{candidate function not viable: no known conversion from 'Iter0' to 'int' for 1st argument}} +GoodIter operator+(int v, GoodIter a) { return GoodIter(); } + +int test_with_random_access_iterator() { + GoodIter begin, end; + Iter0 begin0, end0; +#pragma omp target +#pragma omp teams distribute parallel for + for (GoodIter I = begin; I < end; ++I) + ++I; +#pragma omp target +#pragma omp teams distribute parallel for +// expected-error@+1 {{initialization clause of OpenMP for loop is not in canonical form ('var = init' or 'T var = init')}} + for (GoodIter &I = begin; I < end; ++I) + ++I; +#pragma omp target +#pragma omp teams distribute parallel for + for (GoodIter I = begin; I >= end; --I) + ++I; +#pragma omp target +#pragma omp teams distribute parallel for +// expected-warning@+1 {{initialization clause of OpenMP for loop is not in canonical form ('var = init' or 'T var = init')}} + for (GoodIter I(begin); I < end; ++I) + ++I; +#pragma omp target +#pragma omp teams distribute parallel for +// expected-warning@+1 {{initialization clause of OpenMP for loop is not in canonical form ('var = init' or 'T var = init')}} + for (GoodIter I(nullptr); I < end; ++I) + ++I; +#pragma omp target +#pragma omp teams distribute parallel for +// expected-warning@+1 {{initialization clause of OpenMP for loop is not in canonical form ('var = init' or 'T var = init')}} + for (GoodIter I(0); I < end; ++I) + ++I; +#pragma omp target +#pragma omp teams distribute parallel for +// expected-warning@+1 {{initialization clause of OpenMP for loop is not in canonical form ('var = init' or 'T var = init')}} + for (GoodIter I(1, 2); I < end; ++I) + ++I; +#pragma omp target +#pragma omp teams distribute parallel for + for (begin = GoodIter(0); begin < end; ++begin) + ++begin; +#pragma omp target +#pragma omp teams distribute parallel for +// expected-error@+2 {{invalid operands to binary expression ('GoodIter' and 'const Iter0')}} +// expected-error@+1 {{could not calculate number of iterations calling 'operator-' with upper and lower loop bounds}} + for (begin = begin0; begin < end; ++begin) + ++begin; +#pragma omp target +#pragma omp teams distribute parallel for +// expected-error@+1 {{initialization clause of OpenMP for loop is not in canonical form ('var = init' or 'T var = init')}} + for (++begin; begin < end; ++begin) + ++begin; +#pragma omp target +#pragma omp teams distribute parallel for + for (begin = end; begin < end; ++begin) + ++begin; +#pragma omp target +#pragma omp teams distribute parallel for +// expected-error@+1 {{condition of OpenMP for loop must be a relational comparison ('<', '<=', '>', or '>=') of loop variable 'I'}} + for (GoodIter I = begin; I - I; ++I) + ++I; +#pragma omp target +#pragma omp teams distribute parallel for +// expected-error@+1 {{condition of OpenMP for loop must be a relational comparison ('<', '<=', '>', or '>=') of loop variable 'I'}} + for (GoodIter I = begin; begin < end; ++I) + ++I; +#pragma omp target +#pragma omp teams distribute parallel for +// expected-error@+1 {{condition of OpenMP for loop must be a relational comparison ('<', '<=', '>', or '>=') of loop variable 'I'}} + for (GoodIter I = begin; !I; ++I) + ++I; +#pragma omp target +#pragma omp teams distribute parallel for +// expected-note@+2 {{loop step is expected to be negative due to this condition}} +// expected-error@+1 {{increment expression must cause 'I' to decrease on each iteration of OpenMP for loop}} + for (GoodIter I = begin; I >= end; I = I + 1) + ++I; +#pragma omp target +#pragma omp teams distribute parallel for + for (GoodIter I = begin; I >= end; I = I - 1) + ++I; +#pragma omp target +#pragma omp teams distribute parallel for +// expected-error@+1 {{increment clause of OpenMP for loop must perform simple addition or subtraction on loop variable 'I'}} + for (GoodIter I = begin; I >= end; I = -I) + ++I; +#pragma omp target +#pragma omp teams distribute parallel for +// expected-note@+2 {{loop step is expected to be negative due to this condition}} +// expected-error@+1 {{increment expression must cause 'I' to decrease on each iteration of OpenMP for loop}} + for (GoodIter I = begin; I >= end; I = 2 + I) + ++I; +#pragma omp target +#pragma omp teams distribute parallel for +// expected-error@+1 {{increment clause of OpenMP for loop must perform simple addition or subtraction on loop variable 'I'}} + for (GoodIter I = begin; I >= end; I = 2 - I) + ++I; +#pragma omp target +#pragma omp teams distribute parallel for +// expected-error@+1 {{invalid operands to binary expression ('Iter0' and 'int')}} + for (Iter0 I = begin0; I < end0; ++I) + ++I; +#pragma omp target +#pragma omp teams distribute parallel for +// Initializer is constructor without params. +// expected-error@+2 {{invalid operands to binary expression ('Iter0' and 'int')}} +// expected-warning@+1 {{initialization clause of OpenMP for loop is not in canonical form ('var = init' or 'T var = init')}} + for (Iter0 I; I < end0; ++I) + ++I; + Iter1 begin1, end1; +#pragma omp target +#pragma omp teams distribute parallel for +// expected-error@+2 {{invalid operands to binary expression ('Iter1' and 'Iter1')}} +// expected-error@+1 {{could not calculate number of iterations calling 'operator-' with upper and lower loop bounds}} + for (Iter1 I = begin1; I < end1; ++I) + ++I; +#pragma omp target +#pragma omp teams distribute parallel for +// expected-note@+2 {{loop step is expected to be negative due to this condition}} +// expected-error@+1 {{increment expression must cause 'I' to decrease on each iteration of OpenMP for loop}} + for (Iter1 I = begin1; I >= end1; ++I) + ++I; +#pragma omp target +#pragma omp teams distribute parallel for +// expected-error@+4 {{invalid operands to binary expression ('Iter1' and 'float')}} +// expected-error@+3 {{could not calculate number of iterations calling 'operator-' with upper and lower loop bounds}} +// Initializer is constructor with all default params. +// expected-warning@+1 {{initialization clause of OpenMP for loop is not in canonical form ('var = init' or 'T var = init')}} + for (Iter1 I; I < end1; ++I) { + } + return 0; +} + +template <typename IT, int ST> +class TC { +public: + int dotest_lt(IT begin, IT end) { +#pragma omp target +#pragma omp teams distribute parallel for +// expected-note@+2 {{loop step is expected to be positive due to this condition}} +// expected-error@+1 {{increment expression must cause 'I' to increase on each iteration of OpenMP for loop}} + for (IT I = begin; I < end; I = I + ST) { + ++I; + } +#pragma omp target +#pragma omp teams distribute parallel for +// expected-note@+2 {{loop step is expected to be positive due to this condition}} +// expected-error@+1 {{increment expression must cause 'I' to increase on each iteration of OpenMP for loop}} + for (IT I = begin; I <= end; I += ST) { + ++I; + } +#pragma omp target +#pragma omp teams distribute parallel for + for (IT I = begin; I < end; ++I) { + ++I; + } + } + + static IT step() { + return IT(ST); + } +}; +template <typename IT, int ST = 0> +int dotest_gt(IT begin, IT end) { +#pragma omp target +#pragma omp teams distribute parallel for +// expected-note@+2 2 {{loop step is expected to be negative due to this condition}} +// expected-error@+1 2 {{increment expression must cause 'I' to decrease on each iteration of OpenMP for loop}} + for (IT I = begin; I >= end; I = I + ST) { + ++I; + } +#pragma omp target +#pragma omp teams distribute parallel for +// expected-note@+2 2 {{loop step is expected to be negative due to this condition}} +// expected-error@+1 2 {{increment expression must cause 'I' to decrease on each iteration of OpenMP for loop}} + for (IT I = begin; I >= end; I += ST) { + ++I; + } + +#pragma omp target +#pragma omp teams distribute parallel for +// expected-note@+2 {{loop step is expected to be negative due to this condition}} +// expected-error@+1 {{increment expression must cause 'I' to decrease on each iteration of OpenMP for loop}} + for (IT I = begin; I >= end; ++I) { + ++I; + } + +#pragma omp target +#pragma omp teams distribute parallel for + for (IT I = begin; I < end; I += TC<int, ST>::step()) { + ++I; + } +} + +void test_with_template() { + GoodIter begin, end; + TC<GoodIter, 100> t1; + TC<GoodIter, -100> t2; + t1.dotest_lt(begin, end); + t2.dotest_lt(begin, end); // expected-note {{in instantiation of member function 'TC<GoodIter, -100>::dotest_lt' requested here}} + dotest_gt(begin, end); // expected-note {{in instantiation of function template specialization 'dotest_gt<GoodIter, 0>' requested here}} + dotest_gt<unsigned, -10>(0, 100); // expected-note {{in instantiation of function template specialization 'dotest_gt<unsigned int, -10>' requested here}} +} + +void test_loop_break() { + const int N = 100; + float a[N], b[N], c[N]; +#pragma omp target +#pragma omp teams distribute parallel for + for (int i = 0; i < 10; i++) { + c[i] = a[i] + b[i]; + for (int j = 0; j < 10; ++j) { + if (a[i] > b[j]) + break; // OK in nested loop + } + switch (i) { + case 1: + b[i]++; + break; + default: + break; + } + if (c[i] > 10) + break; // expected-error {{'break' statement cannot be used in OpenMP for loop}} + + if (c[i] > 11) + break; // expected-error {{'break' statement cannot be used in OpenMP for loop}} + } + +#pragma omp target +#pragma omp teams distribute parallel for + for (int i = 0; i < 10; i++) { + for (int j = 0; j < 10; j++) { + c[i] = a[i] + b[i]; + if (c[i] > 10) { + if (c[i] < 20) { + break; // OK + } + } + } + } +} + +void test_loop_eh() { + const int N = 100; + float a[N], b[N], c[N]; +#pragma omp target +#pragma omp teams distribute parallel for + for (int i = 0; i < 10; i++) { + c[i] = a[i] + b[i]; + try { // OK + for (int j = 0; j < 10; ++j) { + if (a[i] > b[j]) + throw a[i]; // OK + } + throw a[i]; // OK + } catch (float f) { + if (f > 0.1) + throw a[i]; // OK + return; // expected-error {{cannot return from OpenMP region}} + } + switch (i) { + case 1: + b[i]++; + break; + default: + break; + } + for (int j = 0; j < 10; j++) { + if (c[i] > 10) + throw c[i]; // OK + } + } + if (c[9] > 10) + throw c[9]; // OK + +#pragma omp target +#pragma omp teams distribute parallel for + for (int i = 0; i < 10; ++i) { + struct S { + void g() { throw 0; } + }; + } +} + +void test_loop_firstprivate_lastprivate() { + S s(4); +#pragma omp target +#pragma omp teams distribute parallel for lastprivate(s) firstprivate(s) + for (int i = 0; i < 16; ++i) + ; +} + +void test_ordered() { +#pragma omp target +#pragma omp teams distribute parallel for ordered // expected-error {{unexpected OpenMP clause 'ordered' in directive '#pragma omp teams distribute parallel for'}} + for (int i = 0; i < 16; ++i) + ; +} + +void test_nowait() { +#pragma omp target +// expected-error@+1 2 {{unexpected OpenMP clause 'nowait' in directive '#pragma omp teams distribute parallel for'}} +#pragma omp teams distribute parallel for nowait nowait // expected-error {{directive '#pragma omp teams distribute parallel for' cannot contain more than one 'nowait' clause}} + for (int i = 0; i < 16; ++i) + ; +} + diff --git a/test/OpenMP/teams_distribute_parallel_for_messages.cpp b/test/OpenMP/teams_distribute_parallel_for_messages.cpp new file mode 100644 index 0000000000..c3536cd861 --- /dev/null +++ b/test/OpenMP/teams_distribute_parallel_for_messages.cpp @@ -0,0 +1,109 @@ +// RUN: %clang_cc1 -verify -fopenmp -std=c++11 %s + +void foo() { +} + +static int pvt; +#pragma omp threadprivate(pvt) + +#pragma omp teams distribute parallel for // expected-error {{unexpected OpenMP directive '#pragma omp teams distribute parallel for'}} + +int main(int argc, char **argv) { +#pragma omp target +#pragma omp teams distribute parallel for { // expected-warning {{extra tokens at the end of '#pragma omp teams distribute parallel for' are ignored}} + for (int i = 0; i < argc; ++i) + foo(); +#pragma omp target +#pragma omp teams distribute parallel for ( // expected-warning {{extra tokens at the end of '#pragma omp teams distribute parallel for' are ignored}} + for (int i = 0; i < argc; ++i) + foo(); +#pragma omp target +#pragma omp teams distribute parallel for[ // expected-warning {{extra tokens at the end of '#pragma omp teams distribute parallel for' are ignored}} + for (int i = 0; i < argc; ++i) + foo(); +#pragma omp target +#pragma omp teams distribute parallel for] // expected-warning {{extra tokens at the end of '#pragma omp teams distribute parallel for' are ignored}} + for (int i = 0; i < argc; ++i) + foo(); +#pragma omp target +#pragma omp teams distribute parallel for) // expected-warning {{extra tokens at the end of '#pragma omp teams distribute parallel for' are ignored}} + for (int i = 0; i < argc; ++i) + foo(); +#pragma omp target +#pragma omp teams distribute parallel for } // expected-warning {{extra tokens at the end of '#pragma omp teams distribute parallel for' are ignored}} + for (int i = 0; i < argc; ++i) + foo(); +#pragma omp target +#pragma omp teams distribute parallel for + for (int i = 0; i < argc; ++i) + foo(); +// expected-warning@+2 {{extra tokens at the end of '#pragma omp teams distribute parallel for' are ignored}} +#pragma omp target +#pragma omp teams distribute parallel for unknown() + for (int i = 0; i < argc; ++i) + foo(); +L1: + for (int i = 0; i < argc; ++i) + foo(); +#pragma omp target +#pragma omp teams distribute parallel for + for (int i = 0; i < argc; ++i) + foo(); +#pragma omp target +#pragma omp teams distribute parallel for + for (int i = 0; i < argc; ++i) { + goto L1; // expected-error {{use of undeclared label 'L1'}} + argc++; + } + + for (int i = 0; i < 10; ++i) { + switch (argc) { + case (0): +#pragma omp target +#pragma omp teams distribute parallel for + for (int i = 0; i < argc; ++i) { + foo(); + break; // expected-error {{'break' statement cannot be used in OpenMP for loop}} + continue; + } + default: + break; + } + } +#pragma omp target +#pragma omp teams distribute parallel for default(none) + for (int i = 0; i < 10; ++i) + ++argc; // expected-error {{ariable 'argc' must have explicitly specified data sharing attributes}} + + goto L2; // expected-error {{use of undeclared label 'L2'}} +#pragma omp target +#pragma omp teams distribute parallel for + for (int i = 0; i < argc; ++i) + L2: + foo(); +#pragma omp target +#pragma omp teams distribute parallel for + for (int i = 0; i < argc; ++i) { + return 1; // expected-error {{cannot return from OpenMP region}} + } + + [[]] // expected-error {{an attribute list cannot appear here}} +#pragma omp target +#pragma omp teams distribute parallel for + for (int n = 0; n < 100; ++n) { + } + +#pragma omp target +#pragma omp teams distribute parallel for copyin(pvt) // expected-error {{unexpected OpenMP clause 'copyin' in directive '#pragma omp teams distribute parallel for'}} + for (int n = 0; n < 100; ++n) {} + + return 0; +} + +void test_ordered() { +#pragma omp target +#pragma omp teams distribute parallel for ordered // expected-error {{unexpected OpenMP clause 'ordered' in directive '#pragma omp teams distribute parallel for'}} + for (int i = 0; i < 16; ++i) + ; +} + diff --git a/test/OpenMP/teams_distribute_parallel_for_num_teams_messages.cpp b/test/OpenMP/teams_distribute_parallel_for_num_teams_messages.cpp new file mode 100644 index 0000000000..63bc91e8ec --- /dev/null +++ b/test/OpenMP/teams_distribute_parallel_for_num_teams_messages.cpp @@ -0,0 +1,111 @@ +// RUN: %clang_cc1 -verify -fopenmp -std=c++11 -ferror-limit 100 -o - %s + +void foo() { +} + +bool foobool(int argc) { + return argc; +} + +struct S1; // expected-note 2 {{declared here}} + +template <typename T, int C> // expected-note {{declared here}} +T tmain(T argc) { + char **a; +#pragma omp target +#pragma omp teams distribute parallel for num_teams(C) + for (int i=0; i<100; i++) foo(); +#pragma omp target +#pragma omp teams distribute parallel for num_teams(T) // expected-error {{'T' does not refer to a value}} + for (int i=0; i<100; i++) foo(); +#pragma omp target +#pragma omp teams distribute parallel for num_teams // expected-error {{expected '(' after 'num_teams'}} + for (int i=0; i<100; i++) foo(); +#pragma omp target +#pragma omp teams distribute parallel for num_teams( // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}} + for (int i=0; i<100; i++) foo(); +#pragma omp target +#pragma omp teams distribute parallel for num_teams() // expected-error {{expected expression}} + for (int i=0; i<100; i++) foo(); +#pragma omp target +#pragma omp teams distribute parallel for num_teams(argc // expected-error {{expected ')'}} expected-note {{to match this '('}} + for (int i=0; i<100; i++) foo(); +#pragma omp target +#pragma omp teams distribute parallel for num_teams(argc)) // expected-warning {{extra tokens at the end of '#pragma omp teams distribute parallel for' are ignored}} + for (int i=0; i<100; i++) foo(); +#pragma omp target +#pragma omp teams distribute parallel for num_teams(argc > 0 ? a[1] : a[2]) // expected-error {{expression must have integral or unscoped enumeration type, not 'char *'}} + for (int i=0; i<100; i++) foo(); +#pragma omp target +#pragma omp teams distribute parallel for num_teams(argc + argc) + for (int i=0; i<100; i++) foo(); +#pragma omp target +#pragma omp teams distribute parallel for num_teams(argc), num_teams (argc+1) // expected-error {{directive '#pragma omp teams distribute parallel for' cannot contain more than one 'num_teams' clause}} + for (int i=0; i<100; i++) foo(); +#pragma omp target +#pragma omp teams distribute parallel for num_teams(S1) // expected-error {{'S1' does not refer to a value}} + for (int i=0; i<100; i++) foo(); +#pragma omp target +#pragma omp teams distribute parallel for num_teams(-2) // expected-error {{argument to 'num_teams' clause must be a strictly positive integer value}} + for (int i=0; i<100; i++) foo(); +#pragma omp target +#pragma omp teams distribute parallel for num_teams(-10u) + for (int i=0; i<100; i++) foo(); +#pragma omp target +#pragma omp teams distribute parallel for num_teams(3.14) // expected-error 2 {{expression must have integral or unscoped enumeration type, not 'double'}} + for (int i=0; i<100; i++) foo(); + + return 0; +} + +int main(int argc, char **argv) { +#pragma omp target +#pragma omp teams distribute parallel for num_teams // expected-error {{expected '(' after 'num_teams'}} + for (int i=0; i<100; i++) foo(); + +#pragma omp target +#pragma omp teams distribute parallel for num_teams ( // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}} + for (int i=0; i<100; i++) foo(); + +#pragma omp target +#pragma omp teams distribute parallel for num_teams () // expected-error {{expected expression}} + for (int i=0; i<100; i++) foo(); + +#pragma omp target +#pragma omp teams distribute parallel for num_teams (argc // expected-error {{expected ')'}} expected-note {{to match this '('}} + for (int i=0; i<100; i++) foo(); + +#pragma omp target +#pragma omp teams distribute parallel for num_teams (argc)) // expected-warning {{extra tokens at the end of '#pragma omp teams distribute parallel for' are ignored}} + for (int i=0; i<100; i++) foo(); + +#pragma omp target +#pragma omp teams distribute parallel for num_teams (argc > 0 ? argv[1] : argv[2]) // expected-error {{expression must have integral or unscoped enumeration type, not 'char *'}} + for (int i=0; i<100; i++) foo(); + +#pragma omp target +#pragma omp teams distribute parallel for num_teams (argc + argc) + for (int i=0; i<100; i++) foo(); + +#pragma omp target +#pragma omp teams distribute parallel for num_teams (argc), num_teams (argc+1) // expected-error {{directive '#pragma omp teams distribute parallel for' cannot contain more than one 'num_teams' clause}} + for (int i=0; i<100; i++) foo(); + +#pragma omp target +#pragma omp teams distribute parallel for num_teams (S1) // expected-error {{'S1' does not refer to a value}} + for (int i=0; i<100; i++) foo(); + +#pragma omp target +#pragma omp teams distribute parallel for num_teams (-2) // expected-error {{argument to 'num_teams' clause must be a strictly positive integer value}} + for (int i=0; i<100; i++) foo(); + +#pragma omp target +#pragma omp teams distribute parallel for num_teams (-10u) + for (int i=0; i<100; i++) foo(); + +#pragma omp target +#pragma omp teams distribute parallel for num_teams (3.14) // expected-error {{expression must have integral or unscoped enumeration type, not 'double'}} + for (int i=0; i<100; i++) foo(); + + return tmain<int, 10>(argc); // expected-note {{in instantiation of function template specialization 'tmain<int, 10>' requested here}} +} diff --git a/test/OpenMP/teams_distribute_parallel_for_private_messages.cpp b/test/OpenMP/teams_distribute_parallel_for_private_messages.cpp new file mode 100644 index 0000000000..6e72905d75 --- /dev/null +++ b/test/OpenMP/teams_distribute_parallel_for_private_messages.cpp @@ -0,0 +1,146 @@ +// RUN: %clang_cc1 -verify -fopenmp %s + +void foo() { +} + +bool foobool(int argc) { + return argc; +} + +struct S1; // expected-note {{declared here}} expected-note {{forward declaration of 'S1'}} +extern S1 a; +class S2 { + mutable int a; +public: + S2():a(0) { } + static float S2s; // expected-note {{predetermined as shared}} +}; +const S2 b; +const S2 ba[5]; +class S3 { + int a; +public: + S3():a(0) { } +}; +const S3 c; // expected-note {{predetermined as shared}} +const S3 ca[5]; // expected-note {{predetermined as shared}} +extern const int f; // expected-note {{predetermined as shared}} +class S4 { + int a; + S4(); // expected-note {{implicitly declared private here}} +public: + S4(int v):a(v) { } +}; +class S5 { + int a; + S5():a(0) {} // expected-note {{implicitly declared private here}} +public: + S5(int v):a(v) { } +}; + +S3 h; +#pragma omp threadprivate(h) // expected-note {{defined as threadprivate or thread local}} + + +int main(int argc, char **argv) { + const int d = 5; // expected-note {{predetermined as shared}} + const int da[5] = { 0 }; // expected-note {{predetermined as shared}} + S4 e(4); + S5 g(5); + int i; + int &j = i; + + #pragma omp target + #pragma omp teams distribute parallel for private // expected-error {{expected '(' after 'private'}} + for (int k = 0; k < argc; ++k) ++k; + + #pragma omp target + #pragma omp teams distribute parallel for private ( // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}} + for (int k = 0; k < argc; ++k) ++k; + + #pragma omp target + #pragma omp teams distribute parallel for private () // expected-error {{expected expression}} + for (int k = 0; k < argc; ++k) ++k; + + #pragma omp target + #pragma omp teams distribute parallel for private (argc // expected-error {{expected ')'}} expected-note {{to match this '('}} + for (int k = 0; k < argc; ++k) ++k; + + #pragma omp target + #pragma omp teams distribute parallel for private (argc, // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}} + for (int k = 0; k < argc; ++k) ++k; + + #pragma omp target + #pragma omp teams distribute parallel for private (argc > 0 ? argv[1] : argv[2]) // expected-error {{expected variable name}} + for (int k = 0; k < argc; ++k) ++k; + + #pragma omp target + #pragma omp teams distribute parallel for private (argc) + for (int k = 0; k < argc; ++k) ++k; + + #pragma omp target + #pragma omp teams distribute parallel for private (S1) // expected-error {{'S1' does not refer to a value}} + for (int k = 0; k < argc; ++k) ++k; + + #pragma omp target + #pragma omp teams distribute parallel for private (a, b, c, d, f) // expected-error {{private variable with incomplete type 'S1'}} expected-error 3 {{shared variable cannot be private}} + for (int k = 0; k < argc; ++k) ++k; + + #pragma omp target + #pragma omp teams distribute parallel for private (argv[1]) // expected-error {{expected variable name}} + for (int k = 0; k < argc; ++k) ++k; + + #pragma omp target + #pragma omp teams distribute parallel for private(ba) + for (int k = 0; k < argc; ++k) ++k; + + #pragma omp target + #pragma omp teams distribute parallel for private(ca) // expected-error {{shared variable cannot be private}} + for (int k = 0; k < argc; ++k) ++k; + + #pragma omp target + #pragma omp teams distribute parallel for private(da) // expected-error {{shared variable cannot be private}} + for (int k = 0; k < argc; ++k) ++k; + + #pragma omp target + #pragma omp teams distribute parallel for private(S2::S2s) // expected-error {{shared variable cannot be private}} + for (int k = 0; k < argc; ++k) ++k; + + #pragma omp target + #pragma omp teams distribute parallel for private(e, g) // expected-error {{calling a private constructor of class 'S4'}} expected-error {{calling a private constructor of class 'S5'}} + for (int k = 0; k < argc; ++k) ++k; + + #pragma omp target + #pragma omp teams distribute parallel for private(h) // expected-error {{threadprivate or thread local variable cannot be private}} + for (int k = 0; k < argc; ++k) ++k; + + #pragma omp target + #pragma omp teams distribute parallel for shared(i) + for (int k = 0; k < argc; ++k) ++k; + + #pragma omp target + #pragma omp teams distribute parallel for firstprivate(i), private(i) // expected-error {{firstprivate variable cannot be private}} expected-note {{defined as firstprivate}} + for (int k = 0; k < argc; ++k) ++k; + + #pragma omp target + #pragma omp teams distribute parallel for private(j) + for (int k = 0; k < argc; ++k) ++k; + + #pragma omp target + #pragma omp teams distribute parallel for reduction(+:i) + for (int k = 0; k < argc; ++k) ++k; + + #pragma omp distribute private(i) + for (int k = 0; k < 10; ++k) { + #pragma omp target + #pragma omp teams distribute parallel for private(i) + for (int x = 0; x < 10; ++x) foo(); + } + + #pragma omp target + #pragma omp teams distribute parallel for firstprivate(i) + for (int k = 0; k < 10; ++k) { + } + + return 0; +} diff --git a/test/OpenMP/teams_distribute_parallel_for_reduction_messages.cpp b/test/OpenMP/teams_distribute_parallel_for_reduction_messages.cpp new file mode 100644 index 0000000000..73661618d2 --- /dev/null +++ b/test/OpenMP/teams_distribute_parallel_for_reduction_messages.cpp @@ -0,0 +1,303 @@ +// RUN: %clang_cc1 -verify -fopenmp %s +// RUN: %clang_cc1 -verify -fopenmp -std=c++98 %s +// RUN: %clang_cc1 -verify -fopenmp -std=c++11 %s + +void foo() { +} + +bool foobool(int argc) { + return argc; +} + +struct S1; // expected-note {{declared here}} expected-note 4 {{forward declaration of 'S1'}} +extern S1 a; +class S2 { + mutable int a; + S2 &operator+(const S2 &arg) { return (*this); } // expected-note 3 {{implicitly declared private here}} + +public: + S2() : a(0) {} + S2(S2 &s2) : a(s2.a) {} + static float S2s; // expected-note 2 {{static data member is predetermined as shared}} + static const float S2sc; +}; +const float S2::S2sc = 0; // expected-note 2 {{'S2sc' defined here}} +S2 b; // expected-note 3 {{'b' defined here}} +const S2 ba[5]; // expected-note 2 {{'ba' defined here}} +class S3 { + int a; + +public: + int b; + S3() : a(0) {} + S3(const S3 &s3) : a(s3.a) {} + S3 operator+(const S3 &arg1) { return arg1; } +}; +int operator+(const S3 &arg1, const S3 &arg2) { return 5; } +S3 c; // expected-note 3 {{'c' defined here}} +const S3 ca[5]; // expected-note 2 {{'ca' defined here}} +extern const int f; // expected-note 4 {{'f' declared here}} +class S4 { + int a; + S4(); // expected-note {{implicitly declared private here}} + S4(const S4 &s4); + S4 &operator+(const S4 &arg) { return (*this); } + +public: + S4(int v) : a(v) {} +}; +S4 &operator&=(S4 &arg1, S4 &arg2) { return arg1; } +class S5 { + int a; + S5() : a(0) {} // expected-note {{implicitly declared private here}} + S5(const S5 &s5) : a(s5.a) {} + S5 &operator+(const S5 &arg); + +public: + S5(int v) : a(v) {} +}; +class S6 { // expected-note 3 {{candidate function (the implicit copy assignment operator) not viable: no known conversion from 'int' to 'const S6' for 1st argument}} +#if __cplusplus >= 201103L // C++11 or later +// expected-note@-2 3 {{candidate function (the implicit move assignment operator) not viable}} +#endif + int a; + +public: + S6() : a(6) {} + operator int() { return 6; } +} o; + +S3 h, k; +#pragma omp threadprivate(h) // expected-note 2 {{defined as threadprivate or thread local}} + +template <class T> // expected-note {{declared here}} +T tmain(T argc) { + const T d = T(); // expected-note 4 {{'d' defined here}} + const T da[5] = {T()}; // expected-note 2 {{'da' defined here}} + T qa[5] = {T()}; + T i; + T &j = i; // expected-note 4 {{'j' defined here}} + S3 &p = k; // expected-note 2 {{'p' defined here}} + const T &r = da[(int)i]; // expected-note 2 {{'r' defined here}} + T &q = qa[(int)i]; // expected-note 2 {{'q' defined here}} + T fl; +#pragma omp target +#pragma omp teams distribute parallel for reduction // expected-error {{expected '(' after 'reduction'}} + for (int j=0; j<100; j++) foo(); +#pragma omp target +#pragma omp teams distribute parallel for reduction + // expected-error {{expected '(' after 'reduction'}} expected-warning {{extra tokens at the end of '#pragma omp teams distribute parallel for' are ignored}} + for (int j=0; j<100; j++) foo(); +#pragma omp target +#pragma omp teams distribute parallel for reduction( // expected-error {{expected unqualified-id}} expected-warning {{missing ':' after reduction identifier - ignoring}} expected-error {{expected ')'}} expected-note {{to match this '('}} + for (int j=0; j<100; j++) foo(); +#pragma omp target +#pragma omp teams distribute parallel for reduction(- // expected-warning {{missing ':' after reduction identifier - ignoring}} expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}} + for (int j=0; j<100; j++) foo(); +#pragma omp target +#pragma omp teams distribute parallel for reduction() // expected-error {{expected unqualified-id}} expected-warning {{missing ':' after reduction identifier - ignoring}} + for (int j=0; j<100; j++) foo(); +#pragma omp target +#pragma omp teams distribute parallel for reduction(*) // expected-warning {{missing ':' after reduction identifier - ignoring}} expected-error {{expected expression}} + for (int j=0; j<100; j++) foo(); +#pragma omp target +#pragma omp teams distribute parallel for reduction(\) // expected-error {{expected unqualified-id}} expected-warning {{missing ':' after reduction identifier - ignoring}} + for (int j=0; j<100; j++) foo(); +#pragma omp target +#pragma omp teams distribute parallel for reduction(& : argc // expected-error {{expected ')'}} expected-note {{to match this '('}} expected-error {{invalid operands to binary expression ('float' and 'float')}} + for (int j=0; j<100; j++) foo(); +#pragma omp target +#pragma omp teams distribute parallel for reduction(| : argc, // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}} expected-error {{invalid operands to binary expression ('float' and 'float')}} + for (int j=0; j<100; j++) foo(); +#pragma omp target +#pragma omp teams distribute parallel for reduction(|| : argc ? i : argc) // expected-error 2 {{expected variable name, array element or array section}} + for (int j=0; j<100; j++) foo(); +#pragma omp target +#pragma omp teams distribute parallel for reduction(foo : argc) //expected-error {{incorrect reduction identifier, expected one of '+', '-', '*', '&', '|', '^', '&&', '||', 'min' or 'max' or declare reduction for type 'float'}} expected-error {{incorrect reduction identifier, expected one of '+', '-', '*', '&', '|', '^', '&&', '||', 'min' or 'max' or declare reduction for type 'int'}} + for (int j=0; j<100; j++) foo(); +#pragma omp target +#pragma omp teams distribute parallel for reduction(&& : argc) + for (int j=0; j<100; j++) foo(); +#pragma omp target +#pragma omp teams distribute parallel for reduction(^ : T) // expected-error {{'T' does not refer to a value}} + for (int j=0; j<100; j++) foo(); +#pragma omp target +#pragma omp teams distribute parallel for reduction(+ : a, b, c, d, f) // expected-error {{a reduction list item with incomplete type 'S1'}} expected-error 3 {{const-qualified list item cannot be reduction}} expected-error 2 {{'operator+' is a private member of 'S2'}} + for (int j=0; j<100; j++) foo(); +#pragma omp target +#pragma omp teams distribute parallel for reduction(min : a, b, c, d, f) // expected-error {{a reduction list item with incomplete type 'S1'}} expected-error 4 {{arguments of OpenMP clause 'reduction' for 'min' or 'max' must be of arithmetic type}} expected-error 3 {{const-qualified list item cannot be reduction}} + for (int j=0; j<100; j++) foo(); +#pragma omp target +#pragma omp teams distribute parallel for reduction(max : h.b) // expected-error {{expected variable name, array element or array section}} + for (int j=0; j<100; j++) foo(); +#pragma omp target +#pragma omp teams distribute parallel for reduction(+ : ba) // expected-error {{const-qualified list item cannot be reduction}} + for (int j=0; j<100; j++) foo(); +#pragma omp target +#pragma omp teams distribute parallel for reduction(* : ca) // expected-error {{const-qualified list item cannot be reduction}} + for (int j=0; j<100; j++) foo(); +#pragma omp target +#pragma omp teams distribute parallel for reduction(- : da) // expected-error {{const-qualified list item cannot be reduction}} expected-error {{const-qualified list item cannot be reduction}} + for (int j=0; j<100; j++) foo(); +#pragma omp target +#pragma omp teams distribute parallel for reduction(^ : fl) // expected-error {{invalid operands to binary expression ('float' and 'float')}} + for (int j=0; j<100; j++) foo(); +#pragma omp target +#pragma omp teams distribute parallel for reduction(&& : S2::S2s) // expected-error {{shared variable cannot be reduction}} + for (int j=0; j<100; j++) foo(); +#pragma omp target +#pragma omp teams distribute parallel for reduction(&& : S2::S2sc) // expected-error {{const-qualified list item cannot be reduction}} + for (int j=0; j<100; j++) foo(); +#pragma omp target +#pragma omp teams distribute parallel for reduction(+ : h, k) // expected-error {{threadprivate or thread local variable cannot be reduction}} + for (int j=0; j<100; j++) foo(); +#pragma omp target +#pragma omp teams distribute parallel for reduction(+ : o) // expected-error 2 {{no viable overloaded '='}} + for (int j=0; j<100; j++) foo(); +#pragma omp target +#pragma omp teams distribute parallel for private(i), reduction(+ : j), reduction(+ : q) // expected-error 4 {{argument of OpenMP clause 'reduction' must reference the same object in all threads}} + for (int j=0; j<100; j++) foo(); +#pragma omp parallel private(k) +#pragma omp target +#pragma omp teams distribute parallel for reduction(+ : p), reduction(+ : p) // expected-error 2 {{argument of OpenMP clause 'reduction' must reference the same object in all threads}} + for (int j=0; j<100; j++) foo(); +#pragma omp target +#pragma omp teams distribute parallel for reduction(+ : p), reduction(+ : p) // expected-error 2 {{variable can appear only once in OpenMP 'reduction' clause}} expected-note 2 {{previously referenced here}} + for (int j=0; j<100; j++) foo(); +#pragma omp target +#pragma omp teams distribute parallel for reduction(+ : r) // expected-error 2 {{const-qualified list item cannot be reduction}} + for (int j=0; j<100; j++) foo(); +#pragma omp parallel shared(i) +#pragma omp parallel reduction(min : i) +#pragma omp target +#pragma omp teams distribute parallel for reduction(max : j) // expected-error 2 {{argument of OpenMP clause 'reduction' must reference the same object in all threads}} + for (int j=0; j<100; j++) foo(); +#pragma omp target +#pragma omp teams distribute parallel for reduction(+ : fl) + for (int j=0; j<100; j++) foo(); + + return T(); +} + +namespace A { +double x; +#pragma omp threadprivate(x) // expected-note {{defined as threadprivate or thread local}} +} +namespace B { +using A::x; +} + +int main(int argc, char **argv) { + const int d = 5; // expected-note 2 {{'d' defined here}} + const int da[5] = {0}; // expected-note {{'da' defined here}} + int qa[5] = {0}; + S4 e(4); + S5 g(5); + int i; + int &j = i; // expected-note 2 {{'j' defined here}} + S3 &p = k; // expected-note 2 {{'p' defined here}} + const int &r = da[i]; // expected-note {{'r' defined here}} + int &q = qa[i]; // expected-note {{'q' defined here}} + float fl; +#pragma omp target +#pragma omp teams distribute parallel for reduction // expected-error {{expected '(' after 'reduction'}} + for (int j=0; j<100; j++) foo(); +#pragma omp target +#pragma omp teams distribute parallel for reduction + // expected-error {{expected '(' after 'reduction'}} expected-warning {{extra tokens at the end of '#pragma omp teams distribute parallel for' are ignored}} + for (int j=0; j<100; j++) foo(); +#pragma omp target +#pragma omp teams distribute parallel for reduction( // expected-error {{expected unqualified-id}} expected-warning {{missing ':' after reduction identifier - ignoring}} expected-error {{expected ')'}} expected-note {{to match this '('}} + for (int j=0; j<100; j++) foo(); +#pragma omp target +#pragma omp teams distribute parallel for reduction(- // expected-warning {{missing ':' after reduction identifier - ignoring}} expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}} + for (int j=0; j<100; j++) foo(); +#pragma omp target +#pragma omp teams distribute parallel for reduction() // expected-error {{expected unqualified-id}} expected-warning {{missing ':' after reduction identifier - ignoring}} + for (int j=0; j<100; j++) foo(); +#pragma omp target +#pragma omp teams distribute parallel for reduction(*) // expected-warning {{missing ':' after reduction identifier - ignoring}} expected-error {{expected expression}} + for (int j=0; j<100; j++) foo(); +#pragma omp target +#pragma omp teams distribute parallel for reduction(\) // expected-error {{expected unqualified-id}} expected-warning {{missing ':' after reduction identifier - ignoring}} + for (int j=0; j<100; j++) foo(); +#pragma omp target +#pragma omp teams distribute parallel for reduction(foo : argc // expected-error {{expected ')'}} expected-note {{to match this '('}} expected-error {{incorrect reduction identifier, expected one of '+', '-', '*', '&', '|', '^', '&&', '||', 'min' or 'max'}} + for (int j=0; j<100; j++) foo(); +#pragma omp target +#pragma omp teams distribute parallel for reduction(| : argc, // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}} + for (int j=0; j<100; j++) foo(); +#pragma omp target +#pragma omp teams distribute parallel for reduction(|| : argc > 0 ? argv[1] : argv[2]) // expected-error {{expected variable name, array element or array section}} + for (int j=0; j<100; j++) foo(); +#pragma omp target +#pragma omp teams distribute parallel for reduction(~ : argc) // expected-error {{expected unqualified-id}} + for (int j=0; j<100; j++) foo(); +#pragma omp target +#pragma omp teams distribute parallel for reduction(&& : argc) + for (int j=0; j<100; j++) foo(); +#pragma omp target +#pragma omp teams distribute parallel for reduction(^ : S1) // expected-error {{'S1' does not refer to a value}} + for (int j=0; j<100; j++) foo(); +#pragma omp target +#pragma omp teams distribute parallel for reduction(+ : a, b, c, d, f) // expected-error {{a reduction list item with incomplete type 'S1'}} expected-error 2 {{const-qualified list item cannot be reduction}} expected-error {{'operator+' is a private member of 'S2'}} + for (int j=0; j<100; j++) foo(); +#pragma omp target +#pragma omp teams distribute parallel for reduction(min : a, b, c, d, f) // expected-error {{a reduction list item with incomplete type 'S1'}} expected-error 2 {{arguments of OpenMP clause 'reduction' for 'min' or 'max' must be of arithmetic type}} expected-error 2 {{const-qualified list item cannot be reduction}} + for (int j=0; j<100; j++) foo(); +#pragma omp target +#pragma omp teams distribute parallel for reduction(max : h.b) // expected-error {{expected variable name, array element or array section}} + for (int j=0; j<100; j++) foo(); +#pragma omp target +#pragma omp teams distribute parallel for reduction(+ : ba) // expected-error {{const-qualified list item cannot be reduction}} + for (int j=0; j<100; j++) foo(); +#pragma omp target +#pragma omp teams distribute parallel for reduction(* : ca) // expected-error {{const-qualified list item cannot be reduction}} + for (int j=0; j<100; j++) foo(); +#pragma omp target +#pragma omp teams distribute parallel for reduction(- : da) // expected-error {{const-qualified list item cannot be reduction}} + for (int j=0; j<100; j++) foo(); +#pragma omp target +#pragma omp teams distribute parallel for reduction(^ : fl) // expected-error {{invalid operands to binary expression ('float' and 'float')}} + for (int j=0; j<100; j++) foo(); +#pragma omp target +#pragma omp teams distribute parallel for reduction(&& : S2::S2s) // expected-error {{shared variable cannot be reduction}} + for (int j=0; j<100; j++) foo(); +#pragma omp target +#pragma omp teams distribute parallel for reduction(&& : S2::S2sc) // expected-error {{const-qualified list item cannot be reduction}} + for (int j=0; j<100; j++) foo(); +#pragma omp target +#pragma omp teams distribute parallel for reduction(& : e, g) // expected-error {{calling a private constructor of class 'S4'}} expected-error {{invalid operands to binary expression ('S4' and 'S4')}} expected-error {{calling a private constructor of class 'S5'}} expected-error {{invalid operands to binary expression ('S5' and 'S5')}} + for (int j=0; j<100; j++) foo(); +#pragma omp target +#pragma omp teams distribute parallel for reduction(+ : h, k, B::x) // expected-error 2 {{threadprivate or thread local variable cannot be reduction}} + for (int j=0; j<100; j++) foo(); +#pragma omp target +#pragma omp teams distribute parallel for reduction(+ : o) // expected-error {{no viable overloaded '='}} + for (int j=0; j<100; j++) foo(); +#pragma omp target +#pragma omp teams distribute parallel for private(i), reduction(+ : j), reduction(+ : q) // expected-error 2 {{argument of OpenMP clause 'reduction' must reference the same object in all threads}} + for (int j=0; j<100; j++) foo(); +#pragma omp parallel private(k) +#pragma omp target +#pragma omp teams distribute parallel for reduction(+ : p), reduction(+ : p) // expected-error 2 {{argument of OpenMP clause 'reduction' must reference the same object in all threads}} + for (int j=0; j<100; j++) foo(); +#pragma omp target +#pragma omp teams distribute parallel for reduction(+ : p), reduction(+ : p) // expected-error {{variable can appear only once in OpenMP 'reduction' clause}} expected-note {{previously referenced here}} + for (int j=0; j<100; j++) foo(); +#pragma omp target +#pragma omp teams distribute parallel for reduction(+ : r) // expected-error {{const-qualified list item cannot be reduction}} + for (int j=0; j<100; j++) foo(); +#pragma omp parallel shared(i) +#pragma omp parallel reduction(min : i) +#pragma omp target +#pragma omp teams distribute parallel for reduction(max : j) // expected-error {{argument of OpenMP clause 'reduction' must reference the same object in all threads}} + for (int j=0; j<100; j++) foo(); +#pragma omp target +#pragma omp teams distribute parallel for reduction(+ : fl) + for (int j=0; j<100; j++) foo(); + static int m; +#pragma omp target +#pragma omp teams distribute parallel for reduction(+ : m) // OK + for (int j=0; j<100; j++) foo(); + + return tmain(argc) + tmain(fl); // expected-note {{in instantiation of function template specialization 'tmain<int>' requested here}} expected-note {{in instantiation of function template specialization 'tmain<float>' requested here}} +} diff --git a/test/OpenMP/teams_distribute_parallel_for_shared_messages.cpp b/test/OpenMP/teams_distribute_parallel_for_shared_messages.cpp new file mode 100644 index 0000000000..8edcd36643 --- /dev/null +++ b/test/OpenMP/teams_distribute_parallel_for_shared_messages.cpp @@ -0,0 +1,127 @@ +// RUN: %clang_cc1 -verify -fopenmp %s + +void foo() { +} + +bool foobool(int argc) { + return argc; +} + +struct S1; // expected-note {{declared here}} +extern S1 a; +class S2 { + mutable int a; +public: + S2():a(0) { } + S2(S2 &s2):a(s2.a) { } +}; +const S2 b; +const S2 ba[5]; +class S3 { + int a; +public: + S3():a(0) { } + S3(S3 &s3):a(s3.a) { } +}; +const S3 c; +const S3 ca[5]; +extern const int f; +class S4 { + int a; + S4(); + S4(const S4 &s4); +public: + S4(int v):a(v) { } +}; +class S5 { + int a; + S5():a(0) {} + S5(const S5 &s5):a(s5.a) { } +public: + S5(int v):a(v) { } +}; + +S3 h; +#pragma omp threadprivate(h) // expected-note {{defined as threadprivate or thread local}} + +namespace A { +double x; +#pragma omp threadprivate(x) // expected-note {{defined as threadprivate or thread local}} +} +namespace B { +using A::x; +} + +int main(int argc, char **argv) { + const int d = 5; + const int da[5] = { 0 }; + S4 e(4); + S5 g(5); + int i; + int &j = i; + #pragma omp target + #pragma omp teams distribute parallel for shared // expected-error {{expected '(' after 'shared'}} + for (int j=0; j<100; j++) foo(); + #pragma omp target + #pragma omp teams distribute parallel for shared ( // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}} + for (int j=0; j<100; j++) foo(); + #pragma omp target + #pragma omp teams distribute parallel for shared () // expected-error {{expected expression}} + for (int j=0; j<100; j++) foo(); + #pragma omp target + #pragma omp teams distribute parallel for shared (argc // expected-error {{expected ')'}} expected-note {{to match this '('}} + for (int j=0; j<100; j++) foo(); + #pragma omp target + #pragma omp teams distribute parallel for shared (argc, // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}} + for (int j=0; j<100; j++) foo(); + #pragma omp target + #pragma omp teams distribute parallel for shared (argc > 0 ? argv[1] : argv[2]) // expected-error {{expected variable name}} + for (int j=0; j<100; j++) foo(); + #pragma omp target + #pragma omp teams distribute parallel for shared (argc) + for (int j=0; j<100; j++) foo(); + #pragma omp target + #pragma omp teams distribute parallel for shared (S1) // expected-error {{'S1' does not refer to a value}} + for (int j=0; j<100; j++) foo(); + #pragma omp target + #pragma omp teams distribute parallel for shared (a, b, c, d, f) + for (int j=0; j<100; j++) foo(); + #pragma omp target + #pragma omp teams distribute parallel for shared (argv[1]) // expected-error {{expected variable name}} + for (int j=0; j<100; j++) foo(); + #pragma omp target + #pragma omp teams distribute parallel for shared(ba) + for (int j=0; j<100; j++) foo(); + #pragma omp target + #pragma omp teams distribute parallel for shared(ca) + for (int j=0; j<100; j++) foo(); + #pragma omp target + #pragma omp teams distribute parallel for shared(da) + for (int j=0; j<100; j++) foo(); + #pragma omp target + #pragma omp teams distribute parallel for shared(e, g) + for (int j=0; j<100; j++) foo(); + #pragma omp target + #pragma omp teams distribute parallel for shared(h, B::x) // expected-error 2 {{threadprivate or thread local variable cannot be shared}} + for (int j=0; j<100; j++) foo(); + #pragma omp target + #pragma omp teams distribute parallel for private(i), shared(i) // expected-error {{private variable cannot be shared}} expected-note {{defined as private}} + for (int j=0; j<100; j++) foo(); + #pragma omp target + #pragma omp teams distribute parallel for firstprivate(i), shared(i) // expected-error {{firstprivate variable cannot be shared}} expected-note {{defined as firstprivate}} + for (int j=0; j<100; j++) foo(); + #pragma omp target + #pragma omp teams distribute parallel for private(i) + for (int j=0; j<100; j++) foo(); + #pragma omp target + #pragma omp teams distribute parallel for shared(i) + for (int j=0; j<100; j++) foo(); + #pragma omp target + #pragma omp teams distribute parallel for shared(j) + for (int j=0; j<100; j++) foo(); + #pragma omp target + #pragma omp teams distribute parallel for firstprivate(i) + for (int j=0; j<100; j++) foo(); + + return 0; +} diff --git a/test/OpenMP/teams_distribute_parallel_for_thread_limit_messages.cpp b/test/OpenMP/teams_distribute_parallel_for_thread_limit_messages.cpp new file mode 100644 index 0000000000..4018f3f07d --- /dev/null +++ b/test/OpenMP/teams_distribute_parallel_for_thread_limit_messages.cpp @@ -0,0 +1,111 @@ +// RUN: %clang_cc1 -verify -fopenmp -std=c++11 %s + +void foo() { +} + +bool foobool(int argc) { + return argc; +} + +struct S1; // expected-note 2 {{declared here}} + +template <typename T, int C> // expected-note {{declared here}} +T tmain(T argc) { + char **a; +#pragma omp target +#pragma omp teams distribute parallel for thread_limit(C) + for (int j=0; j<100; j++) foo(); +#pragma omp target +#pragma omp teams distribute parallel for thread_limit(T) // expected-error {{'T' does not refer to a value}} + for (int j=0; j<100; j++) foo(); +#pragma omp target +#pragma omp teams distribute parallel for thread_limit // expected-error {{expected '(' after 'thread_limit'}} + for (int j=0; j<100; j++) foo(); +#pragma omp target +#pragma omp teams distribute parallel for thread_limit( // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}} + for (int j=0; j<100; j++) foo(); +#pragma omp target +#pragma omp teams distribute parallel for thread_limit() // expected-error {{expected expression}} + for (int j=0; j<100; j++) foo(); +#pragma omp target +#pragma omp teams distribute parallel for thread_limit(argc // expected-error {{expected ')'}} expected-note {{to match this '('}} + for (int j=0; j<100; j++) foo(); +#pragma omp target +#pragma omp teams distribute parallel for thread_limit(argc)) // expected-warning {{extra tokens at the end of '#pragma omp teams distribute parallel for' are ignored}} + for (int j=0; j<100; j++) foo(); +#pragma omp target +#pragma omp teams distribute parallel for thread_limit(argc > 0 ? a[1] : a[2]) // expected-error {{expression must have integral or unscoped enumeration type, not 'char *'}} + for (int j=0; j<100; j++) foo(); +#pragma omp target +#pragma omp teams distribute parallel for thread_limit(argc + argc) + for (int j=0; j<100; j++) foo(); +#pragma omp target +#pragma omp teams distribute parallel for thread_limit(argc), thread_limit (argc+1) // expected-error {{directive '#pragma omp teams distribute parallel for' cannot contain more than one 'thread_limit' clause}} + for (int j=0; j<100; j++) foo(); +#pragma omp target +#pragma omp teams distribute parallel for thread_limit(S1) // expected-error {{'S1' does not refer to a value}} + for (int j=0; j<100; j++) foo(); +#pragma omp target +#pragma omp teams distribute parallel for thread_limit(-2) // expected-error {{argument to 'thread_limit' clause must be a strictly positive integer value}} + for (int j=0; j<100; j++) foo(); +#pragma omp target +#pragma omp teams distribute parallel for thread_limit(-10u) + for (int j=0; j<100; j++) foo(); +#pragma omp target +#pragma omp teams distribute parallel for thread_limit(3.14) // expected-error 2 {{expression must have integral or unscoped enumeration type, not 'double'}} + for (int j=0; j<100; j++) foo(); + + return 0; +} + +int main(int argc, char **argv) { +#pragma omp target +#pragma omp teams distribute parallel for thread_limit // expected-error {{expected '(' after 'thread_limit'}} + for (int j=0; j<100; j++) foo(); + +#pragma omp target +#pragma omp teams distribute parallel for thread_limit ( // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}} + for (int j=0; j<100; j++) foo(); + +#pragma omp target +#pragma omp teams distribute parallel for thread_limit () // expected-error {{expected expression}} + for (int j=0; j<100; j++) foo(); + +#pragma omp target +#pragma omp teams distribute parallel for thread_limit (argc // expected-error {{expected ')'}} expected-note {{to match this '('}} + for (int j=0; j<100; j++) foo(); + +#pragma omp target +#pragma omp teams distribute parallel for thread_limit (argc)) // expected-warning {{extra tokens at the end of '#pragma omp teams distribute parallel for' are ignored}} + for (int j=0; j<100; j++) foo(); + +#pragma omp target +#pragma omp teams distribute parallel for thread_limit (argc > 0 ? argv[1] : argv[2]) // expected-error {{expression must have integral or unscoped enumeration type, not 'char *'}} + for (int j=0; j<100; j++) foo(); + +#pragma omp target +#pragma omp teams distribute parallel for thread_limit (argc + argc) + for (int j=0; j<100; j++) foo(); + +#pragma omp target +#pragma omp teams distribute parallel for thread_limit (argc), thread_limit (argc+1) // expected-error {{directive '#pragma omp teams distribute parallel for' cannot contain more than one 'thread_limit' clause}} + for (int j=0; j<100; j++) foo(); + +#pragma omp target +#pragma omp teams distribute parallel for thread_limit (S1) // expected-error {{'S1' does not refer to a value}} + for (int j=0; j<100; j++) foo(); + +#pragma omp target +#pragma omp teams distribute parallel for thread_limit (-2) // expected-error {{argument to 'thread_limit' clause must be a strictly positive integer value}} + for (int j=0; j<100; j++) foo(); + +#pragma omp target +#pragma omp teams distribute parallel for thread_limit (-10u) + for (int j=0; j<100; j++) foo(); + +#pragma omp target +#pragma omp teams distribute parallel for thread_limit (3.14) // expected-error {{expression must have integral or unscoped enumeration type, not 'double'}} + for (int j=0; j<100; j++) foo(); + + return tmain<int, 10>(argc); // expected-note {{in instantiation of function template specialization 'tmain<int, 10>' requested here}} +} |