From 71f61a886646fca18a9dbed747ff34b0faa0dc98 Mon Sep 17 00:00:00 2001 From: Alexey Bataev Date: Wed, 25 Jun 2014 11:44:49 +0000 Subject: [OPENMP] Initial support for 'sections' directive. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@211685 91177308-0d34-0410-b5e6-96231b3b80d8 --- test/OpenMP/nesting_of_regions.cpp | 84 +++++ test/OpenMP/sections_ast_print.cpp | 46 +++ test/OpenMP/sections_firstprivate_messages.cpp | 335 ++++++++++++++++++++ test/OpenMP/sections_lastprivate_messages.cpp | 309 ++++++++++++++++++ test/OpenMP/sections_misc_messages.c | 271 ++++++++++++++++ test/OpenMP/sections_private_messages.cpp | 204 ++++++++++++ test/OpenMP/sections_reduction_messages.cpp | 413 +++++++++++++++++++++++++ 7 files changed, 1662 insertions(+) create mode 100644 test/OpenMP/sections_ast_print.cpp create mode 100644 test/OpenMP/sections_firstprivate_messages.cpp create mode 100644 test/OpenMP/sections_lastprivate_messages.cpp create mode 100644 test/OpenMP/sections_misc_messages.c create mode 100644 test/OpenMP/sections_private_messages.cpp create mode 100644 test/OpenMP/sections_reduction_messages.cpp (limited to 'test') diff --git a/test/OpenMP/nesting_of_regions.cpp b/test/OpenMP/nesting_of_regions.cpp index a1f416f378..dc8a00257a 100644 --- a/test/OpenMP/nesting_of_regions.cpp +++ b/test/OpenMP/nesting_of_regions.cpp @@ -1,5 +1,7 @@ // RUN: %clang_cc1 -fsyntax-only -fopenmp=libiomp5 -verify %s +void bar(); + template void foo() { #pragma omp parallel @@ -8,6 +10,11 @@ void foo() { #pragma omp parallel #pragma omp simd for (int i = 0; i < 10; ++i); +#pragma omp parallel +#pragma omp sections + { + bar(); + } #pragma omp simd for (int i = 0; i < 10; ++i) { #pragma omp for // expected-error {{OpenMP constructs may not be nested inside a simd region}} @@ -23,6 +30,13 @@ void foo() { #pragma omp parallel // expected-error {{OpenMP constructs may not be nested inside a simd region}} for (int i = 0; i < 10; ++i); } +#pragma omp simd + for (int i = 0; i < 10; ++i) { +#pragma omp sections // expected-error {{OpenMP constructs may not be nested inside a simd region}} + { + bar(); + } + } #pragma omp for for (int i = 0; i < 10; ++i) { #pragma omp for // expected-error {{region cannot be closely nested inside 'for' region; perhaps you forget to enclose 'omp for' directive into a parallel region?}} @@ -38,6 +52,35 @@ void foo() { #pragma omp parallel for (int i = 0; i < 10; ++i); } +#pragma omp for + for (int i = 0; i < 10; ++i) { +#pragma omp sections // expected-error {{region cannot be closely nested inside 'for' region; perhaps you forget to enclose 'omp sections' directive into a parallel region?}} + { + bar(); + } + } +#pragma omp sections + { +#pragma omp for // expected-error {{region cannot be closely nested inside 'sections' region; perhaps you forget to enclose 'omp for' directive into a parallel region?}} + for (int i = 0; i < 10; ++i); + } +#pragma omp sections + { +#pragma omp simd + for (int i = 0; i < 10; ++i); + } +#pragma omp sections + { +#pragma omp parallel + for (int i = 0; i < 10; ++i); + } +#pragma omp sections + { +#pragma omp sections // expected-error {{region cannot be closely nested inside 'sections' region; perhaps you forget to enclose 'omp sections' directive into a parallel region?}} + { + bar(); + } + } } void foo() { @@ -47,6 +90,11 @@ void foo() { #pragma omp parallel #pragma omp simd for (int i = 0; i < 10; ++i); +#pragma omp parallel +#pragma omp sections + { + bar(); + } #pragma omp simd for (int i = 0; i < 10; ++i) { #pragma omp for // expected-error {{OpenMP constructs may not be nested inside a simd region}} @@ -62,6 +110,13 @@ void foo() { #pragma omp parallel // expected-error {{OpenMP constructs may not be nested inside a simd region}} for (int i = 0; i < 10; ++i); } +#pragma omp simd + for (int i = 0; i < 10; ++i) { +#pragma omp sections // expected-error {{OpenMP constructs may not be nested inside a simd region}} + { + bar(); + } + } #pragma omp for for (int i = 0; i < 10; ++i) { #pragma omp for // expected-error {{region cannot be closely nested inside 'for' region; perhaps you forget to enclose 'omp for' directive into a parallel region?}} @@ -77,6 +132,35 @@ void foo() { #pragma omp parallel for (int i = 0; i < 10; ++i); } +#pragma omp for + for (int i = 0; i < 10; ++i) { +#pragma omp sections // expected-error {{region cannot be closely nested inside 'for' region; perhaps you forget to enclose 'omp sections' directive into a parallel region?}} + { + bar(); + } + } +#pragma omp sections + { +#pragma omp for // expected-error {{region cannot be closely nested inside 'sections' region; perhaps you forget to enclose 'omp for' directive into a parallel region?}} + for (int i = 0; i < 10; ++i); + } +#pragma omp sections + { +#pragma omp simd + for (int i = 0; i < 10; ++i); + } +#pragma omp sections + { +#pragma omp parallel + for (int i = 0; i < 10; ++i); + } +#pragma omp sections + { +#pragma omp sections // expected-error {{region cannot be closely nested inside 'sections' region; perhaps you forget to enclose 'omp sections' directive into a parallel region?}} + { + bar(); + } + } return foo(); } diff --git a/test/OpenMP/sections_ast_print.cpp b/test/OpenMP/sections_ast_print.cpp new file mode 100644 index 0000000000..56c1c3c988 --- /dev/null +++ b/test/OpenMP/sections_ast_print.cpp @@ -0,0 +1,46 @@ +// RUN: %clang_cc1 -verify -fopenmp=libiomp5 -ast-print %s | FileCheck %s +// RUN: %clang_cc1 -fopenmp=libiomp5 -x c++ -std=c++11 -emit-pch -o %t %s +// RUN: %clang_cc1 -fopenmp=libiomp5 -std=c++11 -include-pch %t -fsyntax-only -verify %s -ast-print | FileCheck %s +// expected-no-diagnostics + +#ifndef HEADER +#define HEADER + +void foo() {} + +template +T tmain(T argc) { + T b = argc, c, d, e, f, g; + static T a; +// CHECK: static T a; +#pragma omp parallel +#pragma omp sections private(argc, b), firstprivate(c, d), lastprivate(d, f) reduction (-: g) nowait + { + foo(); + } + // CHECK-NEXT: #pragma omp parallel + // CHECK-NEXT: #pragma omp sections private(argc,b) firstprivate(c,d) lastprivate(d,f) reduction(-: g) nowait + // CHECK-NEXT: { + // CHECK-NEXT: foo(); + // CHECK-NEXT: } + return T(); +} + +int main(int argc, char **argv) { + int b = argc, c, d, e, f, g; + static int a; +// CHECK: static int a; +#pragma omp parallel +#pragma omp sections private(argc, b), firstprivate(argv, c), lastprivate(d, f) reduction(+:g) nowait + { + foo(); + } + // CHECK-NEXT: #pragma omp parallel + // CHECK-NEXT: #pragma omp sections private(argc,b) firstprivate(argv,c) lastprivate(d,f) reduction(+: g) nowait + // CHECK-NEXT: { + // CHECK-NEXT: foo(); + // CHECK-NEXT: } + return (tmain(argc) + tmain(argv[0][0])); +} + +#endif diff --git a/test/OpenMP/sections_firstprivate_messages.cpp b/test/OpenMP/sections_firstprivate_messages.cpp new file mode 100644 index 0000000000..b030ce549d --- /dev/null +++ b/test/OpenMP/sections_firstprivate_messages.cpp @@ -0,0 +1,335 @@ +// RUN: %clang_cc1 -verify -fopenmp=libiomp5 %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) {} + 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) {} + S3(S3 &s3) : a(s3.a) {} +}; +const S3 c; +const S3 ca[5]; +extern const int f; +class S4 { // expected-note 2 {{'S4' declared here}} + int a; + S4(); + S4(const S4 &s4); + +public: + S4(int v) : a(v) {} +}; +class S5 { // expected-note 4 {{'S5' declared here}} + int a; + S5(const S5 &s5) : a(s5.a) {} + +public: + S5() : a(0) {} + 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 +int foomain(int argc, char **argv) { + I e(4); // expected-note {{'e' defined here}} + C g(5); // expected-note 2 {{'g' defined here}} + int i; + int &j = i; // expected-note {{'j' defined here}} +#pragma omp parallel +#pragma omp sections firstprivate // expected-error {{expected '(' after 'firstprivate'}} + { + foo(); + } +#pragma omp parallel +#pragma omp sections firstprivate( // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}} + { + foo(); + } +#pragma omp parallel +#pragma omp sections firstprivate() // expected-error {{expected expression}} + { + foo(); + } +#pragma omp parallel +#pragma omp sections firstprivate(argc // expected-error {{expected ')'}} expected-note {{to match this '('}} + { + foo(); + } +#pragma omp parallel +#pragma omp sections firstprivate(argc, // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}} + { + foo(); + } +#pragma omp parallel +#pragma omp sections firstprivate(argc > 0 ? argv[1] : argv[2]) // expected-error {{expected variable name}} + { + foo(); + } +#pragma omp parallel +#pragma omp sections firstprivate(argc) + { + foo(); + } +#pragma omp parallel +#pragma omp sections firstprivate(S1) // expected-error {{'S1' does not refer to a value}} + { + foo(); + } +#pragma omp parallel +#pragma omp sections firstprivate(a, b) // expected-error {{firstprivate variable with incomplete type 'S1'}} + { + foo(); + } +#pragma omp parallel +#pragma omp sections firstprivate(argv[1]) // expected-error {{expected variable name}} + { + foo(); + } +#pragma omp parallel +#pragma omp sections firstprivate(e, g) // expected-error 2 {{firstprivate variable must have an accessible, unambiguous copy constructor}} + { + foo(); + } +#pragma omp parallel +#pragma omp sections firstprivate(h) // expected-error {{threadprivate or thread local variable cannot be firstprivate}} + { + foo(); + } +#pragma omp parallel +#pragma omp sections linear(i) // expected-error {{unexpected OpenMP clause 'linear' in directive '#pragma omp sections'}} + { + foo(); + } +#pragma omp parallel + { + int v = 0; + int i; // expected-note {{variable with automatic storage duration is predetermined as private; perhaps you forget to enclose 'omp sections' directive into a parallel or another task region?}} +#pragma omp sections firstprivate(i) // expected-error {{private variable cannot be firstprivate}} + { + foo(); + } + v += i; + } +#pragma omp parallel shared(i) +#pragma omp parallel private(i) +#pragma omp sections firstprivate(j) // expected-error {{arguments of OpenMP clause 'firstprivate' cannot be of reference type}} + { + foo(); + } +#pragma omp parallel +#pragma omp sections firstprivate(i) + { + foo(); + } +#pragma omp parallel +#pragma omp sections lastprivate(g) firstprivate(g) // expected-error {{firstprivate variable must have an accessible, unambiguous copy constructor}} + { + foo(); + } +#pragma omp parallel private(i) // expected-note {{defined as private}} +#pragma omp sections firstprivate(i) // expected-error {{firstprivate variable must be shared}} + { + foo(); + } +#pragma omp parallel reduction(+ : i) // expected-note {{defined as reduction}} +#pragma omp sections firstprivate(i) // expected-error {{firstprivate variable must be shared}} + { + foo(); + } + return 0; +} + +int main(int argc, char **argv) { + const int d = 5; + const int da[5] = {0}; + S4 e(4); // expected-note {{'e' defined here}} + S5 g(5); // expected-note 2 {{'g' defined here}} + S3 m; + S6 n(2); + int i; + int &j = i; // expected-note {{'j' defined here}} +#pragma omp parallel +#pragma omp sections firstprivate // expected-error {{expected '(' after 'firstprivate'}} + { + foo(); + } +#pragma omp parallel +#pragma omp sections firstprivate( // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}} + { + foo(); + } +#pragma omp parallel +#pragma omp sections firstprivate() // expected-error {{expected expression}} + { + foo(); + } +#pragma omp parallel +#pragma omp sections firstprivate(argc // expected-error {{expected ')'}} expected-note {{to match this '('}} + { + foo(); + } +#pragma omp parallel +#pragma omp sections firstprivate(argc, // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}} + { + foo(); + } +#pragma omp parallel +#pragma omp sections firstprivate(argc > 0 ? argv[1] : argv[2]) // expected-error {{expected variable name}} + { + foo(); + } +#pragma omp parallel +#pragma omp sections firstprivate(argc) + { + foo(); + } +#pragma omp parallel +#pragma omp sections firstprivate(S1) // expected-error {{'S1' does not refer to a value}} + { + foo(); + } +#pragma omp parallel +#pragma omp sections firstprivate(a, b, c, d, f) // expected-error {{firstprivate variable with incomplete type 'S1'}} + { + foo(); + } +#pragma omp parallel +#pragma omp sections firstprivate(argv[1]) // expected-error {{expected variable name}} + { + foo(); + } +#pragma omp parallel +#pragma omp sections firstprivate(2 * 2) // expected-error {{expected variable name}} + { + foo(); + } +#pragma omp parallel +#pragma omp sections firstprivate(ba) // OK + { + foo(); + } +#pragma omp parallel +#pragma omp sections firstprivate(ca) // OK + { + foo(); + } +#pragma omp parallel +#pragma omp sections firstprivate(da) // OK + { + foo(); + } + int xa; +#pragma omp parallel +#pragma omp sections firstprivate(xa) // OK + { + foo(); + } +#pragma omp parallel +#pragma omp sections firstprivate(S2::S2s) // OK + { + foo(); + } +#pragma omp parallel +#pragma omp sections firstprivate(S2::S2sc) // OK + { + foo(); + } +#pragma omp parallel +#pragma omp sections safelen(5) // expected-error {{unexpected OpenMP clause 'safelen' in directive '#pragma omp sections'}} + { + foo(); + } +#pragma omp parallel +#pragma omp sections firstprivate(e, g) // expected-error 2 {{firstprivate variable must have an accessible, unambiguous copy constructor}} + { + foo(); + } +#pragma omp parallel +#pragma omp sections firstprivate(m) // OK + { + foo(); + } +#pragma omp parallel +#pragma omp sections firstprivate(h) // expected-error {{threadprivate or thread local variable cannot be firstprivate}} + { + foo(); + } +#pragma omp parallel +#pragma omp sections private(xa), firstprivate(xa) // expected-error {{private variable cannot be firstprivate}} expected-note {{defined as private}} + { + foo(); + } +#pragma omp parallel shared(xa) +#pragma omp sections firstprivate(xa) // OK: may be firstprivate + { + foo(); + } +#pragma omp parallel +#pragma omp sections firstprivate(j) // expected-error {{arguments of OpenMP clause 'firstprivate' cannot be of reference type}} + { + foo(); + } +#pragma omp parallel +#pragma omp sections lastprivate(g) firstprivate(g) // expected-error {{firstprivate variable must have an accessible, unambiguous copy constructor}} + { + foo(); + } +#pragma omp parallel +#pragma omp sections lastprivate(n) firstprivate(n) // OK + { + foo(); + } +#pragma omp parallel + { + int v = 0; + int i; // expected-note {{variable with automatic storage duration is predetermined as private; perhaps you forget to enclose 'omp sections' directive into a parallel or another task region?}} +#pragma omp sections firstprivate(i) // expected-error {{private variable cannot be firstprivate}} + { + foo(); + } + v += i; + } +#pragma omp parallel private(i) // expected-note {{defined as private}} +#pragma omp sections firstprivate(i) // expected-error {{firstprivate variable must be shared}} + { + foo(); + } +#pragma omp parallel reduction(+ : i) // expected-note {{defined as reduction}} +#pragma omp sections firstprivate(i) // expected-error {{firstprivate variable must be shared}} + { + foo(); + } + + return foomain(argc, argv); // expected-note {{in instantiation of function template specialization 'foomain' requested here}} +} diff --git a/test/OpenMP/sections_lastprivate_messages.cpp b/test/OpenMP/sections_lastprivate_messages.cpp new file mode 100644 index 0000000000..54c6005dce --- /dev/null +++ b/test/OpenMP/sections_lastprivate_messages.cpp @@ -0,0 +1,309 @@ +// RUN: %clang_cc1 -verify -fopenmp=libiomp5 %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) {} + 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 { // expected-note 2 {{'S3' declared here}} + int a; + S3 &operator=(const S3 &s3); + +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 { // expected-note 3 {{'S4' declared here}} + int a; + S4(); + S4(const S4 &s4); + +public: + S4(int v) : a(v) {} +}; +class S5 { // expected-note {{'S5' declared here}} + int a; + S5() : a(0) {} + +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 +int foomain(int argc, char **argv) { + I e(4); // expected-note {{'e' defined here}} + I g(5); // expected-note {{'g' defined here}} + int i; + int &j = i; // expected-note {{'j' defined here}} +#pragma omp parallel +#pragma omp sections lastprivate // expected-error {{expected '(' after 'lastprivate'}} + { + foo(); + } +#pragma omp parallel +#pragma omp sections lastprivate( // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}} + { + foo(); + } +#pragma omp parallel +#pragma omp sections lastprivate() // expected-error {{expected expression}} + { + foo(); + } +#pragma omp parallel +#pragma omp sections lastprivate(argc // expected-error {{expected ')'}} expected-note {{to match this '('}} + { + foo(); + } +#pragma omp parallel +#pragma omp sections lastprivate(argc, // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}} + { + foo(); + } +#pragma omp parallel +#pragma omp sections lastprivate(argc > 0 ? argv[1] : argv[2]) // expected-error {{expected variable name}} + { + foo(); + } +#pragma omp parallel +#pragma omp sections lastprivate(argc) + { + foo(); + } +#pragma omp parallel +#pragma omp sections lastprivate(S1) // expected-error {{'S1' does not refer to a value}} + { + foo(); + } +#pragma omp parallel +#pragma omp sections lastprivate(a, b) // expected-error {{lastprivate variable with incomplete type 'S1'}} + { + foo(); + } +#pragma omp parallel +#pragma omp sections lastprivate(argv[1]) // expected-error {{expected variable name}} + { + foo(); + } +#pragma omp parallel +#pragma omp sections lastprivate(e, g) // expected-error 2 {{lastprivate variable must have an accessible, unambiguous default constructor}} + { + foo(); + } +#pragma omp parallel +#pragma omp sections lastprivate(h) // expected-error {{threadprivate or thread local variable cannot be lastprivate}} + { + foo(); + } +#pragma omp parallel +#pragma omp sections linear(i) // expected-error {{unexpected OpenMP clause 'linear' in directive '#pragma omp sections'}} + { + foo(); + } +#pragma omp parallel + { + int v = 0; + int i; // expected-note {{variable with automatic storage duration is predetermined as private; perhaps you forget to enclose 'omp sections' directive into a parallel or another task region?}} +#pragma omp sections lastprivate(i) // expected-error {{lastprivate variable must be shared}} + { + foo(); + } + v += i; + } +#pragma omp parallel shared(i) +#pragma omp parallel private(i) +#pragma omp sections lastprivate(j) // expected-error {{arguments of OpenMP clause 'lastprivate' cannot be of reference type}} + { + foo(); + } +#pragma omp parallel +#pragma omp sections lastprivate(i) + { + foo(); + } + return 0; +} + +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); // expected-note {{'e' defined here}} + S5 g(5); // expected-note {{'g' defined here}} + S3 m; // expected-note 2 {{'m' defined here}} + S6 n(2); + int i; + int &j = i; // expected-note {{'j' defined here}} +#pragma omp parallel +#pragma omp sections lastprivate // expected-error {{expected '(' after 'lastprivate'}} + { + foo(); + } +#pragma omp parallel +#pragma omp sections lastprivate( // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}} + { + foo(); + } +#pragma omp parallel +#pragma omp sections lastprivate() // expected-error {{expected expression}} + { + foo(); + } +#pragma omp parallel +#pragma omp sections lastprivate(argc // expected-error {{expected ')'}} expected-note {{to match this '('}} + { + foo(); + } +#pragma omp parallel +#pragma omp sections lastprivate(argc, // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}} + { + foo(); + } +#pragma omp parallel +#pragma omp sections lastprivate(argc > 0 ? argv[1] : argv[2]) // expected-error {{expected variable name}} + { + foo(); + } +#pragma omp parallel +#pragma omp sections lastprivate(argc) + { + foo(); + } +#pragma omp parallel +#pragma omp sections lastprivate(S1) // expected-error {{'S1' does not refer to a value}} + { + foo(); + } +#pragma omp parallel +#pragma omp sections lastprivate(a, b, c, d, f) // expected-error {{lastprivate variable with incomplete type 'S1'}} expected-error 3 {{shared variable cannot be lastprivate}} + { + foo(); + } +#pragma omp parallel +#pragma omp sections lastprivate(argv[1]) // expected-error {{expected variable name}} + { + foo(); + } +#pragma omp parallel +#pragma omp sections lastprivate(2 * 2) // expected-error {{expected variable name}} + { + foo(); + } +#pragma omp parallel +#pragma omp sections lastprivate(ba) + { + foo(); + } +#pragma omp parallel +#pragma omp sections lastprivate(ca) // expected-error {{shared variable cannot be lastprivate}} + { + foo(); + } +#pragma omp parallel +#pragma omp sections lastprivate(da) // expected-error {{shared variable cannot be lastprivate}} + { + foo(); + } + int xa; +#pragma omp parallel +#pragma omp sections lastprivate(xa) // OK + { + foo(); + } +#pragma omp parallel +#pragma omp sections lastprivate(S2::S2s) // expected-error {{shared variable cannot be lastprivate}} + { + foo(); + } +#pragma omp parallel +#pragma omp sections lastprivate(S2::S2sc) // expected-error {{shared variable cannot be lastprivate}} + { + foo(); + } +#pragma omp parallel +#pragma omp sections safelen(5) // expected-error {{unexpected OpenMP clause 'safelen' in directive '#pragma omp sections'}} + { + foo(); + } +#pragma omp parallel +#pragma omp sections lastprivate(e, g) // expected-error 2 {{lastprivate variable must have an accessible, unambiguous default constructor}} + { + foo(); + } +#pragma omp parallel +#pragma omp sections lastprivate(m) // expected-error {{lastprivate variable must have an accessible, unambiguous copy assignment operator}} + { + foo(); + } +#pragma omp parallel +#pragma omp sections lastprivate(h) // expected-error {{threadprivate or thread local variable cannot be lastprivate}} + { + foo(); + } +#pragma omp parallel +#pragma omp sections private(xa), lastprivate(xa) // expected-error {{private variable cannot be lastprivate}} expected-note {{defined as private}} + { + foo(); + } +#pragma omp parallel +#pragma omp sections lastprivate(i) + { + foo(); + } +#pragma omp parallel private(xa) // expected-note {{defined as private}} +#pragma omp sections lastprivate(xa) // expected-error {{lastprivate variable must be shared}} + { + foo(); + } +#pragma omp parallel reduction(+ : xa) // expected-note {{defined as reduction}} +#pragma omp sections lastprivate(xa) // expected-error {{lastprivate variable must be shared}} + { + foo(); + } +#pragma omp parallel +#pragma omp sections lastprivate(j) // expected-error {{arguments of OpenMP clause 'lastprivate' cannot be of reference type}} + { + foo(); + } +#pragma omp parallel +#pragma omp sections firstprivate(m) lastprivate(m) // expected-error {{lastprivate variable must have an accessible, unambiguous copy assignment operator}} + { + foo(); + } +#pragma omp parallel +#pragma omp sections lastprivate(n) firstprivate(n) // OK + { + foo(); + } + return foomain(argc, argv); // expected-note {{in instantiation of function template specialization 'foomain' requested here}} +} diff --git a/test/OpenMP/sections_misc_messages.c b/test/OpenMP/sections_misc_messages.c new file mode 100644 index 0000000000..e8aa5e28c0 --- /dev/null +++ b/test/OpenMP/sections_misc_messages.c @@ -0,0 +1,271 @@ +// RUN: %clang_cc1 -fsyntax-only -fopenmp=libiomp5 -verify %s + +void foo(); + +// expected-error@+1 {{unexpected OpenMP directive '#pragma omp sections'}} +#pragma omp sections + +// expected-error@+1 {{unexpected OpenMP directive '#pragma omp sections'}} +#pragma omp sections foo + +void test_no_clause() { + int i; +#pragma omp sections + { + foo(); + } + +// expected-error@+2 {{the statement for '#pragma omp sections' must be a compound statement}} +#pragma omp sections + ++i; +} + +void test_branch_protected_scope() { + int i = 0; +L1: + ++i; + + int x[24]; + +#pragma omp parallel +#pragma omp sections + { + if (i == 5) + goto L1; // expected-error {{use of undeclared label 'L1'}} + else if (i == 6) + return; // expected-error {{cannot return from OpenMP region}} + else if (i == 7) + goto L2; + else if (i == 8) { + L2: + x[i]++; + } + } + + if (x[0] == 0) + goto L2; // expected-error {{use of undeclared label 'L2'}} + else if (x[1] == 1) + goto L1; +} + +void test_invalid_clause() { + int i; +#pragma omp parallel +// expected-warning@+1 {{extra tokens at the end of '#pragma omp sections' are ignored}} +#pragma omp sections foo bar + { + foo(); + } +} + +void test_non_identifiers() { + int i, x; + +#pragma omp parallel +// expected-warning@+1 {{extra tokens at the end of '#pragma omp sections' are ignored}} +#pragma omp sections; + { + foo(); + } +#pragma omp parallel +// expected-error@+2 {{unexpected OpenMP clause 'linear' in directive '#pragma omp sections'}} +// expected-warning@+1 {{extra tokens at the end of '#pragma omp sections' are ignored}} +#pragma omp sections linear(x); + { + foo(); + } + +#pragma omp parallel +// expected-warning@+1 {{extra tokens at the end of '#pragma omp sections' are ignored}} +#pragma omp sections private(x); + { + foo(); + } + +#pragma omp parallel +// expected-warning@+1 {{extra tokens at the end of '#pragma omp sections' are ignored}} +#pragma omp sections, private(x); + { + foo(); + } +} + +void test_private() { + int i; +#pragma omp parallel +// expected-error@+2 {{expected expression}} +// expected-error@+1 {{expected ')'}} expected-note@+1 {{to match this '('}} +#pragma omp sections private( + { + foo(); + } +#pragma omp parallel +// expected-error@+2 {{expected ')'}} expected-note@+2 {{to match this '('}} +// expected-error@+1 2 {{expected expression}} +#pragma omp sections private(, + { + foo(); + } +#pragma omp parallel +// expected-error@+1 2 {{expected expression}} +#pragma omp sections private(, ) + { + foo(); + } +#pragma omp parallel +// expected-error@+1 {{expected expression}} +#pragma omp sections private() + { + foo(); + } +#pragma omp parallel +// expected-error@+1 {{expected expression}} +#pragma omp sections private(int) + { + foo(); + } +#pragma omp parallel +// expected-error@+1 {{expected variable name}} +#pragma omp sections private(0) + { + foo(); + } + + int x, y, z; +#pragma omp parallel +#pragma omp sections private(x) + { + foo(); + } +#pragma omp parallel +#pragma omp sections private(x, y) + { + foo(); + } +#pragma omp parallel +#pragma omp sections private(x, y, z) + { + foo(); + } +} + +void test_lastprivate() { + int i; +#pragma omp parallel +// expected-error@+2 {{expected ')'}} expected-note@+2 {{to match this '('}} +// expected-error@+1 {{expected expression}} +#pragma omp sections lastprivate( + { + foo(); + } + +#pragma omp parallel +// expected-error@+2 {{expected ')'}} expected-note@+2 {{to match this '('}} +// expected-error@+1 2 {{expected expression}} +#pragma omp sections lastprivate(, + { + foo(); + } +#pragma omp parallel +// expected-error@+1 2 {{expected expression}} +#pragma omp sections lastprivate(, ) + { + foo(); + } +#pragma omp parallel +// expected-error@+1 {{expected expression}} +#pragma omp sections lastprivate() + { + foo(); + } +#pragma omp parallel +// expected-error@+1 {{expected expression}} +#pragma omp sections lastprivate(int) + { + foo(); + } +#pragma omp parallel +// expected-error@+1 {{expected variable name}} +#pragma omp sections lastprivate(0) + { + foo(); + } + + int x, y, z; +#pragma omp parallel +#pragma omp sections lastprivate(x) + { + foo(); + } +#pragma omp parallel +#pragma omp sections lastprivate(x, y) + { + foo(); + } +#pragma omp parallel +#pragma omp sections lastprivate(x, y, z) + { + foo(); + } +} + +void test_firstprivate() { + int i; +#pragma omp parallel +// expected-error@+2 {{expected ')'}} expected-note@+2 {{to match this '('}} +// expected-error@+1 {{expected expression}} +#pragma omp sections firstprivate( + { + foo(); + } + +#pragma omp parallel +// expected-error@+2 {{expected ')'}} expected-note@+2 {{to match this '('}} +// expected-error@+1 2 {{expected expression}} +#pragma omp sections firstprivate(, + { + foo(); + } +#pragma omp parallel +// expected-error@+1 2 {{expected expression}} +#pragma omp sections firstprivate(, ) + { + foo(); + } +#pragma omp parallel +// expected-error@+1 {{expected expression}} +#pragma omp sections firstprivate() + { + foo(); + } +#pragma omp parallel +// expected-error@+1 {{expected expression}} +#pragma omp sections firstprivate(int) + { + foo(); + } +#pragma omp parallel +// expected-error@+1 {{expected variable name}} +#pragma omp sections firstprivate(0) + { + foo(); + } + + int x, y, z; +#pragma omp parallel +#pragma omp sections lastprivate(x) firstprivate(x) + { + foo(); + } +#pragma omp parallel +#pragma omp sections lastprivate(x, y) firstprivate(x, y) + { + foo(); + } +#pragma omp parallel +#pragma omp sections lastprivate(x, y, z) firstprivate(x, y, z) + { + foo(); + } +} + diff --git a/test/OpenMP/sections_private_messages.cpp b/test/OpenMP/sections_private_messages.cpp new file mode 100644 index 0000000000..7f5aa84968 --- /dev/null +++ b/test/OpenMP/sections_private_messages.cpp @@ -0,0 +1,204 @@ +// RUN: %clang_cc1 -verify -fopenmp=libiomp5 %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) {} +}; +const S2 b; +const S2 ba[5]; +class S3 { + int a; + +public: + S3() : a(0) {} +}; +const S3 ca[5]; +class S4 { // expected-note {{'S4' declared here}} + int a; + S4(); + +public: + S4(int v) : a(v) {} +}; +class S5 { // expected-note {{'S5' declared here}} + 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 +int foomain(I argc, C **argv) { + I e(4); + I g(5); + int i; + int &j = i; // expected-note {{'j' defined here}} +#pragma omp sections private // expected-error {{expected '(' after 'private'}} + { + foo(); + } +#pragma omp sections private( // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}} + { + foo(); + } +#pragma omp sections private() // expected-error {{expected expression}} + { + foo(); + } +#pragma omp sections private(argc // expected-error {{expected ')'}} expected-note {{to match this '('}} + { + foo(); + } +#pragma omp sections private(argc, // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}} + { + foo(); + } +#pragma omp sections private(argc > 0 ? argv[1] : argv[2]) // expected-error {{expected variable name}} + { + foo(); + } +#pragma omp sections private(argc) + { + foo(); + } +#pragma omp sections private(S1) // expected-error {{'S1' does not refer to a value}} + { + foo(); + } +#pragma omp sections private(a, b) // expected-error {{private variable with incomplete type 'S1'}} + { + foo(); + } +#pragma omp sections private(argv[1]) // expected-error {{expected variable name}} + { + foo(); + } +#pragma omp sections private(e, g) + { + foo(); + } +#pragma omp sections private(h) // expected-error {{threadprivate or thread local variable cannot be private}} + { + foo(); + } +#pragma omp sections shared(i) // expected-error {{unexpected OpenMP clause 'shared' in directive '#pragma omp sections'}} + { + foo(); + } +#pragma omp parallel + { + int v = 0; + int i; +#pragma omp sections private(i) + { + foo(); + } + v += i; + } +#pragma omp parallel shared(i) +#pragma omp parallel private(i) +#pragma omp sections private(j) // expected-error {{arguments of OpenMP clause 'private' cannot be of reference type}} + { + foo(); + } +#pragma omp sections private(i) + { + foo(); + } + return 0; +} + +int main(int argc, char **argv) { + S4 e(4); // expected-note {{'e' defined here}} + S5 g(5); // expected-note {{'g' defined here}} + int i; + int &j = i; // expected-note {{'j' defined here}} +#pragma omp sections private // expected-error {{expected '(' after 'private'}} + { + foo(); + } +#pragma omp sections private( // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}} + { + foo(); + } +#pragma omp sections private() // expected-error {{expected expression}} + { + foo(); + } +#pragma omp sections private(argc // expected-error {{expected ')'}} expected-note {{to match this '('}} + { + foo(); + } +#pragma omp sections private(argc, // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}} + { + foo(); + } +#pragma omp sections private(argc > 0 ? argv[1] : argv[2]) // expected-error {{expected variable name}} + { + foo(); + } +#pragma omp sections private(argc) + { + foo(); + } +#pragma omp sections private(S1) // expected-error {{'S1' does not refer to a value}} + { + foo(); + } +#pragma omp sections private(a, b) // expected-error {{private variable with incomplete type 'S1'}} + { + foo(); + } +#pragma omp sections private(argv[1]) // expected-error {{expected variable name}} + { + foo(); + } +#pragma omp sections private(e, g) // expected-error 2 {{private variable must have an accessible, unambiguous default constructor}} + { + foo(); + } +#pragma omp sections private(h) // expected-error {{threadprivate or thread local variable cannot be private}} + { + foo(); + } +#pragma omp sections shared(i) // expected-error {{unexpected OpenMP clause 'shared' in directive '#pragma omp sections'}} + { + foo(); + } +#pragma omp parallel + { + int i; +#pragma omp sections private(i) + { + foo(); + } + } +#pragma omp parallel shared(i) +#pragma omp parallel private(i) +#pragma omp sections private(j) // expected-error {{arguments of OpenMP clause 'private' cannot be of reference type}} + { + foo(); + } +#pragma omp sections private(i) + { + foo(); + } + + return 0; +} + diff --git a/test/OpenMP/sections_reduction_messages.cpp b/test/OpenMP/sections_reduction_messages.cpp new file mode 100644 index 0000000000..8c4bdcc2e8 --- /dev/null +++ b/test/OpenMP/sections_reduction_messages.cpp @@ -0,0 +1,413 @@ +// RUN: %clang_cc1 -verify -fopenmp=libiomp5 -ferror-limit 100 -o - %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); } + +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 2 {{'b' defined here}} +const S2 ba[5]; // expected-note 2 {{'ba' defined here}} +class S3 { + int a; + +public: + 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 2 {{'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 { // expected-note {{'S4' declared here}} + int a; + S4(); + 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) {} + S5(const S5 &s5) : a(s5.a) {} + S5 &operator+=(const S5 &arg); + +public: + S5(int v) : a(v) {} +}; +class S6 { + int a; + +public: + S6() : a(6) {} + operator int() { return 6; } +} o; // expected-note 2 {{'o' defined here}} + +S3 h, k; +#pragma omp threadprivate(h) // expected-note 2 {{defined as threadprivate or thread local}} + +template // expected-note {{declared here}} +T tmain(T argc) { // expected-note 2 {{'argc' defined here}} + 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; // expected-note {{'fl' defined here}} +#pragma omp parallel +#pragma omp sections reduction // expected-error {{expected '(' after 'reduction'}} + { + foo(); + } +#pragma omp parallel +#pragma omp sections reduction + // expected-error {{expected '(' after 'reduction'}} expected-warning {{extra tokens at the end of '#pragma omp sections' are ignored}} + { + foo(); + } +#pragma omp parallel +#pragma omp sections reduction( // expected-error {{expected unqualified-id}} expected-warning {{missing ':' after reduction identifier - ignoring}} expected-error {{expected ')'}} expected-note {{to match this '('}} + { + foo(); + } +#pragma omp parallel +#pragma omp sections reduction(- // expected-warning {{missing ':' after reduction identifier - ignoring}} expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}} + { + foo(); + } +#pragma omp parallel +#pragma omp sections reduction() // expected-error {{expected unqualified-id}} expected-warning {{missing ':' after reduction identifier - ignoring}} + { + foo(); + } +#pragma omp parallel +#pragma omp sections reduction(*) // expected-warning {{missing ':' after reduction identifier - ignoring}} expected-error {{expected expression}} + { + foo(); + } +#pragma omp parallel +#pragma omp sections reduction(\) // expected-error {{expected unqualified-id}} expected-warning {{missing ':' after reduction identifier - ignoring}} + { + foo(); + } +#pragma omp parallel +#pragma omp sections reduction(& : argc // expected-error {{expected ')'}} expected-note {{to match this '('}} expected-error {{variable of type 'float' is not valid for specified reduction operation}} + { + foo(); + } +#pragma omp parallel +#pragma omp sections reduction(| : argc, // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}} expected-error {{variable of type 'float' is not valid for specified reduction operation}} + { + foo(); + } +#pragma omp parallel +#pragma omp sections reduction(|| : argc ? i : argc) // expected-error 2 {{expected variable name}} + { + foo(); + } +#pragma omp parallel +#pragma omp sections reduction(foo : argc) //expected-error {{incorrect reduction identifier, expected one of '+', '-', '*', '&', '|', '^', '&&', '||', 'min' or 'max'}} + { + foo(); + } +#pragma omp parallel +#pragma omp sections reduction(&& : argc) + { + foo(); + } +#pragma omp parallel +#pragma omp sections reduction(^ : T) // expected-error {{'T' does not refer to a value}} + { + foo(); + } +#pragma omp parallel +#pragma omp sections reduction(+ : a, b, c, d, f) // expected-error {{reduction variable with incomplete type 'S1'}} expected-error 3 {{const-qualified variable cannot be reduction}} + { + foo(); + } +#pragma omp parallel +#pragma omp sections reduction(min : a, b, c, d, f) // expected-error {{reduction variable with incomplete type 'S1'}} expected-error 2 {{arguments of OpenMP clause 'reduction' for 'min' or 'max' must be of arithmetic type}} expected-error 3 {{const-qualified variable cannot be reduction}} + { + foo(); + } +#pragma omp parallel +#pragma omp sections reduction(max : qa[1]) // expected-error 2 {{expected variable name}} + { + foo(); + } +#pragma omp parallel +#pragma omp sections reduction(+ : ba) // expected-error {{a reduction variable with array type 'const S2 [5]'}} + { + foo(); + } +#pragma omp parallel +#pragma omp sections reduction(* : ca) // expected-error {{a reduction variable with array type 'const S3 [5]'}} + { + foo(); + } +#pragma omp parallel +#pragma omp sections reduction(- : da) // expected-error {{a reduction variable with array type 'const int [5]'}} expected-error {{a reduction variable with array type 'const float [5]'}} + { + foo(); + } +#pragma omp parallel +#pragma omp sections reduction(^ : fl) // expected-error {{variable of type 'float' is not valid for specified reduction operation}} + { + foo(); + } +#pragma omp parallel +#pragma omp sections reduction(&& : S2::S2s) // expected-error {{shared variable cannot be reduction}} + { + foo(); + } +#pragma omp parallel +#pragma omp sections reduction(&& : S2::S2sc) // expected-error {{const-qualified variable cannot be reduction}} + { + foo(); + } +#pragma omp parallel +#pragma omp sections reduction(+ : h, k) // expected-error {{threadprivate or thread local variable cannot be reduction}} + { + foo(); + } +#pragma omp parallel +#pragma omp sections reduction(+ : o) // expected-error {{variable of type 'class S6' is not valid for specified reduction operation}} + { + foo(); + } +#pragma omp parallel +#pragma omp sections private(i), reduction(+ : j), reduction(+ : q) // expected-error 4 {{argument of OpenMP clause 'reduction' must reference the same object in all threads}} + { + foo(); + } +#pragma omp parallel private(k) +#pragma omp sections reduction(+ : p), reduction(+ : p) // expected-error 2 {{argument of OpenMP clause 'reduction' must reference the same object in all threads}} + { + foo(); + } +#pragma omp parallel +#pragma omp sections reduction(+ : p), reduction(+ : p) // expected-error 3 {{variable can appear only once in OpenMP 'reduction' clause}} expected-note 3 {{previously referenced here}} + { + foo(); + } +#pragma omp parallel +#pragma omp sections reduction(+ : r) // expected-error 2 {{const-qualified variable cannot be reduction}} + { + foo(); + } +#pragma omp parallel shared(i) +#pragma omp parallel reduction(min : i) +#pragma omp sections reduction(max : j) // expected-error 2 {{argument of OpenMP clause 'reduction' must reference the same object in all threads}} + { + foo(); + } +#pragma omp parallel private(fl) // expected-note 2 {{defined as private}} +#pragma omp sections reduction(+ : fl) // expected-error 2 {{reduction variable must be shared}} + { + foo(); + } +#pragma omp parallel reduction(* : fl) // expected-note 2 {{defined as reduction}} +#pragma omp sections reduction(+ : fl) // expected-error 2 {{reduction variable must be shared}} + { + foo(); + } + + return T(); +} + +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); // expected-note {{'e' defined here}} + S5 g(5); // expected-note {{'g' defined here}} + 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; // expected-note {{'fl' defined here}} +#pragma omp parallel +#pragma omp sections reduction // expected-error {{expected '(' after 'reduction'}} + { + foo(); + } +#pragma omp parallel +#pragma omp sections reduction + // expected-error {{expected '(' after 'reduction'}} expected-warning {{extra tokens at the end of '#pragma omp sections' are ignored}} + { + foo(); + } +#pragma omp parallel +#pragma omp sections reduction( // expected-error {{expected unqualified-id}} expected-warning {{missing ':' after reduction identifier - ignoring}} expected-error {{expected ')'}} expected-note {{to match this '('}} + { + foo(); + } +#pragma omp parallel +#pragma omp sections reduction(- // expected-warning {{missing ':' after reduction identifier - ignoring}} expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}} + { + foo(); + } +#pragma omp parallel +#pragma omp sections reduction() // expected-error {{expected unqualified-id}} expected-warning {{missing ':' after reduction identifier - ignoring}} + { + foo(); + } +#pragma omp parallel +#pragma omp sections reduction(*) // expected-warning {{missing ':' after reduction identifier - ignoring}} expected-error {{expected expression}} + { + foo(); + } +#pragma omp parallel +#pragma omp sections reduction(\) // expected-error {{expected unqualified-id}} expected-warning {{missing ':' after reduction identifier - ignoring}} + { + foo(); + } +#pragma omp parallel +#pragma omp sections reduction(foo : argc // expected-error {{expected ')'}} expected-note {{to match this '('}} expected-error {{incorrect reduction identifier, expected one of '+', '-', '*', '&', '|', '^', '&&', '||', 'min' or 'max'}} + { + foo(); + } +#pragma omp parallel +#pragma omp sections reduction(| : argc, // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}} + { + foo(); + } +#pragma omp parallel +#pragma omp sections reduction(|| : argc > 0 ? argv[1] : argv[2]) // expected-error {{expected variable name}} + { + foo(); + } +#pragma omp parallel +#pragma omp sections reduction(~ : argc) // expected-error {{expected unqualified-id}} + { + foo(); + } +#pragma omp parallel +#pragma omp sections reduction(&& : argc) + { + foo(); + } +#pragma omp parallel +#pragma omp sections reduction(^ : S1) // expected-error {{'S1' does not refer to a value}} + { + foo(); + } +#pragma omp parallel +#pragma omp sections reduction(+ : a, b, c, d, f) // expected-error {{reduction variable with incomplete type 'S1'}} expected-error 2 {{const-qualified variable cannot be reduction}} + { + foo(); + } +#pragma omp parallel +#pragma omp sections reduction(min : a, b, c, d, f) // expected-error {{reduction variable 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 variable cannot be reduction}} + { + foo(); + } +#pragma omp parallel +#pragma omp sections reduction(max : argv[1]) // expected-error {{expected variable name}} + { + foo(); + } +#pragma omp parallel +#pragma omp sections reduction(+ : ba) // expected-error {{a reduction variable with array type 'const S2 [5]'}} + { + foo(); + } +#pragma omp parallel +#pragma omp sections reduction(* : ca) // expected-error {{a reduction variable with array type 'const S3 [5]'}} + { + foo(); + } +#pragma omp parallel +#pragma omp sections reduction(- : da) // expected-error {{a reduction variable with array type 'const int [5]'}} + { + foo(); + } +#pragma omp parallel +#pragma omp sections reduction(^ : fl) // expected-error {{variable of type 'float' is not valid for specified reduction operation}} + { + foo(); + } +#pragma omp parallel +#pragma omp sections reduction(&& : S2::S2s) // expected-error {{shared variable cannot be reduction}} + { + foo(); + } +#pragma omp parallel +#pragma omp sections reduction(&& : S2::S2sc) // expected-error {{const-qualified variable cannot be reduction}} + { + foo(); + } +#pragma omp parallel +#pragma omp sections reduction(& : e, g) // expected-error {{reduction variable must have an accessible, unambiguous default constructor}} expected-error {{variable of type 'S5' is not valid for specified reduction operation}} + { + foo(); + } +#pragma omp parallel +#pragma omp sections reduction(+ : h, k) // expected-error {{threadprivate or thread local variable cannot be reduction}} + { + foo(); + } +#pragma omp parallel +#pragma omp sections reduction(+ : o) // expected-error {{variable of type 'class S6' is not valid for specified reduction operation}} + { + foo(); + } +#pragma omp parallel +#pragma omp sections private(i), reduction(+ : j), reduction(+ : q) // expected-error 2 {{argument of OpenMP clause 'reduction' must reference the same object in all threads}} + { + foo(); + } +#pragma omp parallel private(k) +#pragma omp sections reduction(+ : p), reduction(+ : p) // expected-error 2 {{argument of OpenMP clause 'reduction' must reference the same object in all threads}} + { + foo(); + } +#pragma omp parallel +#pragma omp sections reduction(+ : p), reduction(+ : p) // expected-error {{variable can appear only once in OpenMP 'reduction' clause}} expected-note {{previously referenced here}} + { + foo(); + } +#pragma omp parallel +#pragma omp sections reduction(+ : r) // expected-error {{const-qualified variable cannot be reduction}} + { + foo(); + } +#pragma omp parallel shared(i) +#pragma omp parallel reduction(min : i) +#pragma omp sections reduction(max : j) // expected-error {{argument of OpenMP clause 'reduction' must reference the same object in all threads}} + { + foo(); + } +#pragma omp parallel private(fl) // expected-note {{defined as private}} +#pragma omp sections reduction(+ : fl) // expected-error {{reduction variable must be shared}} + { + foo(); + } +#pragma omp parallel reduction(* : fl) // expected-note {{defined as reduction}} +#pragma omp sections reduction(+ : fl) // expected-error {{reduction variable must be shared}} + { + foo(); + } + + return tmain(argc) + tmain(fl); // expected-note {{in instantiation of function template specialization 'tmain' requested here}} expected-note {{in instantiation of function template specialization 'tmain' requested here}} +} -- cgit v1.2.3