2020-03-18 00:10:51 +08:00
// RUN: %clang_cc1 -verify=expected,omp45 -fopenmp-version=45 -fopenmp -ferror-limit 200 -std=c++11 -o - %s -Wuninitialized
// RUN: %clang_cc1 -verify=expected,omp50 -fopenmp-version=50 -fopenmp -ferror-limit 200 -std=c++11 -o - %s -Wuninitialized
2014-07-11 19:25:16 +08:00
2020-03-18 00:10:51 +08:00
// RUN: %clang_cc1 -verify=expected,omp45 -fopenmp-version=45 -fopenmp-simd -ferror-limit 200 -std=c++11 -o - %s -Wuninitialized
// RUN: %clang_cc1 -verify=expected,omp50 -fopenmp-version=50 -fopenmp-simd -ferror-limit 200 -std=c++11 -o - %s -Wuninitialized
2017-12-30 02:07:07 +08:00
2020-07-13 11:19:40 +08:00
// RUN: %clang_cc1 -verify=expected,omp50 -fopenmp-version=51 -DOMP51 -fopenmp -ferror-limit 100 -std=c++11 -o - %s -Wuninitialized
// RUN: %clang_cc1 -verify=expected,omp50 -fopenmp-version=51 -DOMP51 -fopenmp-simd -ferror-limit 100 -std=c++11 -o - %s -Wuninitialized
[OPENMP]Initial fix PR42392: Improve -Wuninitialized warnings for OpenMP programs.
Summary:
Some OpenMP clauses rely on the values of the variables. If the variable
is not initialized and used in OpenMP clauses that depend on the
variables values, it should be reported that the uninitialized variable
is used in the OpenMP clause expression.
This patch adds initial processing for uninitialized variables in OpenMP
constructs. Currently, it checks for use of the uninitialized variables
in the structured blocks.
Reviewers: NoQ, Szelethus, dcoughlin, xazax.hun, a.sidorin, george.karpenkov, szepet
Subscribers: rnkovacs, guansong, jfb, jdoerfert, cfe-commits
Tags: #clang
Differential Revision: https://reviews.llvm.org/D64356
llvm-svn: 365786
2019-07-11 22:54:17 +08:00
void xxx ( int argc ) {
int x ; // expected-note {{initialize the variable 'x' to silence this warning}}
# pragma omp task
argc = x ; // expected-warning {{variable 'x' is uninitialized when used here}}
}
2014-07-11 19:25:16 +08:00
void foo ( ) {
2020-03-17 21:17:42 +08:00
# pragma omp task detach(0) // omp45-error {{unexpected OpenMP clause 'detach' in directive '#pragma omp task'}} omp50-error {{'omp_event_handle_t' type not found; include <omp.h>}}
;
2014-07-11 19:25:16 +08:00
}
2020-03-17 21:17:42 +08:00
typedef unsigned long omp_event_handle_t ;
2020-07-13 11:19:40 +08:00
namespace {
static int y = 0 ;
}
static int x = 0 ;
2020-03-17 21:17:42 +08:00
2014-07-11 19:25:16 +08:00
# pragma omp task // expected-error {{unexpected OpenMP directive '#pragma omp task'}}
2014-10-08 22:01:46 +08:00
class S {
2019-01-09 23:58:05 +08:00
S ( const S & s ) { a = s . a + 12 ; } // expected-note 16 {{implicitly declared private here}}
2014-07-11 19:25:16 +08:00
int a ;
public :
S ( ) : a ( 0 ) { }
S ( int a ) : a ( a ) { }
operator int ( ) { return a ; }
S & operator + + ( ) { return * this ; }
S operator + ( const S & ) { return * this ; }
} ;
2014-10-08 22:01:46 +08:00
class S1 {
int a ;
public :
S1 ( ) : a ( 0 ) { }
S1 & operator + + ( ) { return * this ; }
S1 ( const S1 & ) = delete ; // expected-note 2 {{'S1' has been explicitly marked deleted here}}
} ;
2014-07-11 19:25:16 +08:00
template < class T >
int foo ( ) {
2014-10-08 22:01:46 +08:00
T a ;
2015-08-18 14:47:21 +08:00
T & b = a ;
2014-07-11 19:25:16 +08:00
int r ;
2014-10-08 22:01:46 +08:00
S1 s1 ;
// expected-error@+1 2 {{call to deleted constructor of 'S1'}}
# pragma omp task
+ + s1 ;
2019-05-10 02:14:57 +08:00
# pragma omp task default(none) // expected-note 2 {{explicit data sharing attribute requested here}}
2014-07-11 19:25:16 +08:00
# pragma omp task default(shared)
2018-10-30 04:17:42 +08:00
+ + a ; // expected-error 2 {{variable 'a' must have explicitly specified data sharing attributes}}
2020-07-13 11:19:40 +08:00
# ifdef OMP51
# pragma omp task default(firstprivate) // expected-note 4 {{explicit data sharing attribute requested here}}
# pragma omp task
{
+ + x ; // expected-error 2 {{variable 'x' must have explicitly specified data sharing attributes}}
+ + y ; // expected-error 2 {{variable 'y' must have explicitly specified data sharing attributes}}
}
# endif
2019-05-10 02:14:57 +08:00
# pragma omp task default(none) // expected-note 2 {{explicit data sharing attribute requested here}}
2014-07-11 19:25:16 +08:00
# pragma omp task
2014-10-08 22:01:46 +08:00
// expected-error@+1 {{calling a private constructor of class 'S'}}
2018-10-30 04:17:42 +08:00
+ + a ; // expected-error 2 {{variable 'a' must have explicitly specified data sharing attributes}}
2014-07-11 19:25:16 +08:00
# pragma omp task
# pragma omp task
2014-10-08 22:01:46 +08:00
// expected-error@+1 {{calling a private constructor of class 'S'}}
2018-10-30 04:17:42 +08:00
+ + a ; // expected-error {{calling a private constructor of class 'S'}}
2014-07-11 19:25:16 +08:00
# pragma omp task default(shared)
2019-01-09 23:58:05 +08:00
# pragma omp task
// expected-error@+1 {{calling a private constructor of class 'S'}}
+ + a ;
# pragma omp parallel shared(a)
# pragma omp task
# pragma omp task
+ + a ;
# pragma omp parallel shared(a)
# pragma omp task default(shared)
2014-07-11 19:25:16 +08:00
# pragma omp task
+ + a ;
# pragma omp task
# pragma omp parallel
2018-10-30 04:17:42 +08:00
+ + a ; // expected-error {{calling a private constructor of class 'S'}}
2015-08-18 14:47:21 +08:00
// expected-error@+2 {{calling a private constructor of class 'S'}}
2014-07-11 19:25:16 +08:00
# pragma omp task
+ + b ;
# pragma omp task
2015-08-18 14:47:21 +08:00
// expected-error@+1 2 {{calling a private constructor of class 'S'}}
2014-07-11 19:25:16 +08:00
# pragma omp parallel shared(a, b)
+ + a , + + b ;
2016-03-17 18:19:46 +08:00
// expected-note@+1 2 {{defined as reduction}}
2014-07-11 19:25:16 +08:00
# pragma omp parallel reduction(+ : r)
2016-03-17 18:19:46 +08:00
// expected-error@+1 2 {{argument of a reduction clause of a parallel construct must not appear in a firstprivate clause on a task construct}}
2014-07-11 19:25:16 +08:00
# pragma omp task firstprivate(r)
+ + r ;
// expected-note@+1 2 {{defined as reduction}}
# pragma omp parallel reduction(+ : r)
# pragma omp task default(shared)
// expected-error@+1 2 {{reduction variables may not be accessed in an explicit task}}
+ + r ;
// expected-note@+1 2 {{defined as reduction}}
# pragma omp parallel reduction(+ : r)
# pragma omp task
// expected-error@+1 2 {{reduction variables may not be accessed in an explicit task}}
+ + r ;
# pragma omp parallel
2016-03-17 18:19:46 +08:00
// expected-note@+1 2 {{defined as reduction}}
2014-07-11 19:25:16 +08:00
# pragma omp for reduction(+ : r)
for ( int i = 0 ; i < 10 ; + + i )
2016-03-17 18:19:46 +08:00
// expected-error@+1 2 {{argument of a reduction clause of a for construct must not appear in a firstprivate clause on a task construct}}
2014-07-11 19:25:16 +08:00
# pragma omp task firstprivate(r)
+ + r ;
# pragma omp parallel
// expected-note@+1 2 {{defined as reduction}}
# pragma omp for reduction(+ : r)
for ( int i = 0 ; i < 10 ; + + i )
# pragma omp task default(shared)
// expected-error@+1 2 {{reduction variables may not be accessed in an explicit task}}
+ + r ;
# pragma omp parallel
// expected-note@+1 2 {{defined as reduction}}
# pragma omp for reduction(+ : r)
for ( int i = 0 ; i < 10 ; + + i )
# pragma omp task
// expected-error@+1 2 {{reduction variables may not be accessed in an explicit task}}
+ + r ;
// expected-note@+1 {{non-shared variable in a task construct is predetermined as firstprivate}}
# pragma omp task
// expected-error@+2 {{reduction variable must be shared}}
// expected-error@+1 {{region cannot be closely nested inside 'task' region; perhaps you forget to enclose 'omp for' directive into a parallel region?}}
# pragma omp for reduction(+ : r)
+ + r ;
2014-07-17 20:19:31 +08:00
// expected-error@+1 {{directive '#pragma omp task' cannot contain more than one 'untied' clause}}
# pragma omp task untied untied
+ + r ;
2014-07-17 20:47:03 +08:00
// expected-error@+1 {{directive '#pragma omp task' cannot contain more than one 'mergeable' clause}}
# pragma omp task mergeable mergeable
+ + r ;
2020-03-17 21:17:42 +08:00
volatile omp_event_handle_t evt ;
const omp_event_handle_t cevt = 0 ;
omp_event_handle_t sevt ;
omp_event_handle_t & revt = sevt ;
# pragma omp task detach // omp45-error {{unexpected OpenMP clause 'detach' in directive '#pragma omp task'}} expected-error {{expected '(' after 'detach'}}
# pragma omp task detach( // omp45-error {{unexpected OpenMP clause 'detach' in directive '#pragma omp task'}} expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
# pragma omp task detach() // omp45-error {{unexpected OpenMP clause 'detach' in directive '#pragma omp task'}} expected-error {{expected expression}}
# pragma omp task detach(a) // omp45-error {{unexpected OpenMP clause 'detach' in directive '#pragma omp task'}} omp50-error {{expected variable of the 'omp_event_handle_t' type, not 'int'}} omp50-error {{expected variable of the 'omp_event_handle_t' type, not 'S'}}
;
# pragma omp task detach(evt) detach(evt) // omp45-error 2 {{unexpected OpenMP clause 'detach' in directive '#pragma omp task'}} expected-error {{directive '#pragma omp task' cannot contain more than one 'detach' clause}}
Revert "Following up on PR48517, fix handling of template arguments that refer"
Combined with 'da98651 - Revert "DR2064:
decltype(E) is only a dependent', this change (5a391d3) caused verifier
errors when building Chromium. See https://crbug.com/1168494#c1 for a
reproducer.
Additionally it reverts changes that were dependent on this one, see
below.
> Following up on PR48517, fix handling of template arguments that refer
> to dependent declarations.
>
> Treat an id-expression that names a local variable in a templated
> function as being instantiation-dependent.
>
> This addresses a language defect whereby a reference to a dependent
> declaration can be formed without any construct being value-dependent.
> Fixing that through value-dependence turns out to be problematic, so
> instead this patch takes the approach (proposed on the core reflector)
> of allowing the use of pointers or references to (but not values of)
> dependent declarations inside value-dependent expressions, and instead
> treating template arguments as dependent if they evaluate to a constant
> involving such dependent declarations.
>
> This ends up affecting a bunch of OpenMP tests, due to OpenMP
> imprecisely handling instantiation-dependent constructs, bailing out
> early instead of processing dependent constructs to the extent possible
> when handling the template.
>
> Previously committed as 8c1f2d15b826591cdf6bd6b468b8a7d23377b29e, and
> reverted because a dependency commit was reverted.
This reverts commit 5a391d38ac6c561ba908334d427f26124ed9132e.
It also restores clang/test/SemaCXX/coroutines.cpp to its state before
da986511fb9da1a46a0ca4dba2e49e2426036303.
Revert "[c++20] P1907R1: Support for generalized non-type template arguments of scalar type."
> Previously committed as 9e08e51a20d0d2b1c5724bb17e969d036fced4cd, and
> reverted because a dependency commit was reverted. This incorporates the
> following follow-on commits that were also reverted:
>
> 7e84aa1b81e72d44bcc58ffe1731bfc7abb73ce0 by Simon Pilgrim
> ed13d8c66781b50ff007cb089c5905f9bb9e8af2 by me
> 95c7b6cadbc9a3d4376ef44edbeb3c8bb5b8d7fc by Sam McCall
> 430d5d8429473c2b10b109991d7577a3cea41140 by Dave Zarzycki
This reverts commit 4b574008aef5a7235c1f894ab065fe300d26e786.
Revert "[msabi] Mangle a template argument referring to array-to-pointer decay"
> [msabi] Mangle a template argument referring to array-to-pointer decay
> applied to an array the same as the array itself.
>
> This follows MS ABI, and corrects a regression from the implementation
> of generalized non-type template parameters, where we "forgot" how to
> mangle this case.
This reverts commit 18e093faf726d15f210ab4917142beec51848258.
2021-01-20 22:25:33 +08:00
# pragma omp task detach(cevt) detach(revt) // omp45-error 2 {{unexpected OpenMP clause 'detach' in directive '#pragma omp task'}} expected-error {{directive '#pragma omp task' cannot contain more than one 'detach' clause}} omp50-error {{expected variable of the 'omp_event_handle_t' type, not 'const omp_event_handle_t' (aka 'const unsigned long')}} omp50-error {{expected variable of the 'omp_event_handle_t' type, not 'omp_event_handle_t &' (aka 'unsigned long &')}}
2020-03-17 21:17:42 +08:00
# pragma omp task detach(evt) mergeable // omp45-error {{unexpected OpenMP clause 'detach' in directive '#pragma omp task'}} omp50-error {{'mergeable' and 'detach' clause are mutually exclusive and may not appear on the same directive}} omp50-note {{'detach' clause is specified here}}
;
# pragma omp task mergeable detach(evt) // omp45-error {{unexpected OpenMP clause 'detach' in directive '#pragma omp task'}} omp50-error {{'detach' and 'mergeable' clause are mutually exclusive and may not appear on the same directive}} omp50-note {{'mergeable' clause is specified here}}
Revert "Following up on PR48517, fix handling of template arguments that refer"
Combined with 'da98651 - Revert "DR2064:
decltype(E) is only a dependent', this change (5a391d3) caused verifier
errors when building Chromium. See https://crbug.com/1168494#c1 for a
reproducer.
Additionally it reverts changes that were dependent on this one, see
below.
> Following up on PR48517, fix handling of template arguments that refer
> to dependent declarations.
>
> Treat an id-expression that names a local variable in a templated
> function as being instantiation-dependent.
>
> This addresses a language defect whereby a reference to a dependent
> declaration can be formed without any construct being value-dependent.
> Fixing that through value-dependence turns out to be problematic, so
> instead this patch takes the approach (proposed on the core reflector)
> of allowing the use of pointers or references to (but not values of)
> dependent declarations inside value-dependent expressions, and instead
> treating template arguments as dependent if they evaluate to a constant
> involving such dependent declarations.
>
> This ends up affecting a bunch of OpenMP tests, due to OpenMP
> imprecisely handling instantiation-dependent constructs, bailing out
> early instead of processing dependent constructs to the extent possible
> when handling the template.
>
> Previously committed as 8c1f2d15b826591cdf6bd6b468b8a7d23377b29e, and
> reverted because a dependency commit was reverted.
This reverts commit 5a391d38ac6c561ba908334d427f26124ed9132e.
It also restores clang/test/SemaCXX/coroutines.cpp to its state before
da986511fb9da1a46a0ca4dba2e49e2426036303.
Revert "[c++20] P1907R1: Support for generalized non-type template arguments of scalar type."
> Previously committed as 9e08e51a20d0d2b1c5724bb17e969d036fced4cd, and
> reverted because a dependency commit was reverted. This incorporates the
> following follow-on commits that were also reverted:
>
> 7e84aa1b81e72d44bcc58ffe1731bfc7abb73ce0 by Simon Pilgrim
> ed13d8c66781b50ff007cb089c5905f9bb9e8af2 by me
> 95c7b6cadbc9a3d4376ef44edbeb3c8bb5b8d7fc by Sam McCall
> 430d5d8429473c2b10b109991d7577a3cea41140 by Dave Zarzycki
This reverts commit 4b574008aef5a7235c1f894ab065fe300d26e786.
Revert "[msabi] Mangle a template argument referring to array-to-pointer decay"
> [msabi] Mangle a template argument referring to array-to-pointer decay
> applied to an array the same as the array itself.
>
> This follows MS ABI, and corrects a regression from the implementation
> of generalized non-type template parameters, where we "forgot" how to
> mangle this case.
This reverts commit 18e093faf726d15f210ab4917142beec51848258.
2021-01-20 22:25:33 +08:00
# pragma omp task detach(-evt) // omp45-error {{unexpected OpenMP clause 'detach' in directive '#pragma omp task'}} omp50-error {{expected variable of the 'omp_event_handle_t' type}}
2020-03-17 21:17:42 +08:00
;
2020-03-18 00:10:51 +08:00
# pragma omp task detach(evt) shared(evt) // omp45-error {{unexpected OpenMP clause 'detach' in directive '#pragma omp task'}}
# pragma omp task detach(evt) firstprivate(evt) // omp45-error {{unexpected OpenMP clause 'detach' in directive '#pragma omp task'}}
;
2014-07-11 19:25:16 +08:00
return a + b ;
}
int main ( int argc , char * * argv ) {
int a ;
2015-08-18 14:47:21 +08:00
int & b = a ;
2014-10-08 22:01:46 +08:00
S sa ;
2015-08-18 14:47:21 +08:00
S & sb = sa ;
2021-03-27 03:43:25 +08:00
int r ; // expected-note {{declared here}}
2014-07-11 19:25:16 +08:00
# pragma omp task { // expected-warning {{extra tokens at the end of '#pragma omp task' are ignored}}
foo ( ) ;
# pragma omp task( // expected-warning {{extra tokens at the end of '#pragma omp task' are ignored}}
foo ( ) ;
# pragma omp task[ // expected-warning {{extra tokens at the end of '#pragma omp task' are ignored}}
foo ( ) ;
# pragma omp task] // expected-warning {{extra tokens at the end of '#pragma omp task' are ignored}}
foo ( ) ;
# pragma omp task) // expected-warning {{extra tokens at the end of '#pragma omp task' are ignored}}
foo ( ) ;
# pragma omp task } // expected-warning {{extra tokens at the end of '#pragma omp task' are ignored}}
foo ( ) ;
# pragma omp task
// expected-warning@+1 {{extra tokens at the end of '#pragma omp task' are ignored}}
# pragma omp task unknown()
foo ( ) ;
L1 :
foo ( ) ;
# pragma omp task
;
# pragma omp task
{
goto L1 ; // expected-error {{use of undeclared label 'L1'}}
argc + + ;
}
for ( int i = 0 ; i < 10 ; + + i ) {
switch ( argc ) {
case ( 0 ) :
# pragma omp task
{
foo ( ) ;
break ; // expected-error {{'break' statement not in loop or switch statement}}
continue ; // expected-error {{'continue' statement not in loop statement}}
}
default :
break ;
}
}
2019-05-10 02:14:57 +08:00
# pragma omp task default(none) // expected-note {{explicit data sharing attribute requested here}}
2014-07-11 19:25:16 +08:00
+ + argc ; // expected-error {{variable 'argc' must have explicitly specified data sharing attributes}}
goto L2 ; // expected-error {{use of undeclared label 'L2'}}
# pragma omp task
L2 :
foo ( ) ;
# pragma omp task
{
return 1 ; // expected-error {{cannot return from OpenMP region}}
}
[ [ ] ] // expected-error {{an attribute list cannot appear here}}
# pragma omp task
for ( int n = 0 ; n < 100 ; + + n ) {
}
2019-05-10 02:14:57 +08:00
# pragma omp task default(none) // expected-note {{explicit data sharing attribute requested here}}
2014-07-11 19:25:16 +08:00
# pragma omp task default(shared)
2018-10-30 04:17:42 +08:00
+ + a ; // expected-error {{variable 'a' must have explicitly specified data sharing attributes}}
2019-05-10 02:14:57 +08:00
# pragma omp task default(none) // expected-note {{explicit data sharing attribute requested here}}
2014-07-11 19:25:16 +08:00
# pragma omp task
2018-10-30 04:17:42 +08:00
+ + a ; // expected-error {{variable 'a' must have explicitly specified data sharing attributes}}
2014-07-11 19:25:16 +08:00
# pragma omp task default(shared)
# pragma omp task
+ + a ;
# pragma omp task
# pragma omp parallel
+ + a ;
# pragma omp task
+ + b ;
# pragma omp task
# pragma omp parallel shared(a, b)
+ + a , + + b ;
2019-05-10 02:14:57 +08:00
# pragma omp task default(none) // expected-note {{explicit data sharing attribute requested here}}
2014-07-11 19:25:16 +08:00
# pragma omp task default(shared)
2018-10-30 04:17:42 +08:00
+ + sa ; // expected-error {{variable 'sa' must have explicitly specified data sharing attributes}}
2019-05-10 02:14:57 +08:00
# pragma omp task default(none) // expected-note {{explicit data sharing attribute requested here}}
2014-07-11 19:25:16 +08:00
# pragma omp task
2014-10-08 22:01:46 +08:00
// expected-error@+1 {{calling a private constructor of class 'S'}}
2018-10-30 04:17:42 +08:00
+ + sa ; // expected-error {{variable 'sa' must have explicitly specified data sharing attributes}}
2014-07-11 19:25:16 +08:00
# pragma omp task
# pragma omp task
2014-10-08 22:01:46 +08:00
// expected-error@+1 {{calling a private constructor of class 'S'}}
2018-10-30 04:17:42 +08:00
+ + sa ; // expected-error {{calling a private constructor of class 'S'}}
2014-07-11 19:25:16 +08:00
# pragma omp task default(shared)
2019-01-09 23:58:05 +08:00
# pragma omp task
// expected-error@+1 {{calling a private constructor of class 'S'}}
+ + sa ;
# pragma omp parallel shared(sa)
# pragma omp task
# pragma omp task
+ + sa ;
# pragma omp parallel shared(sa)
# pragma omp task default(shared)
2014-07-11 19:25:16 +08:00
# pragma omp task
+ + sa ;
# pragma omp task
# pragma omp parallel
2018-10-30 04:17:42 +08:00
+ + sa ; // expected-error {{calling a private constructor of class 'S'}}
2015-08-18 14:47:21 +08:00
// expected-error@+2 {{calling a private constructor of class 'S'}}
2014-07-11 19:25:16 +08:00
# pragma omp task
+ + sb ;
2015-08-18 14:47:21 +08:00
// expected-error@+2 2 {{calling a private constructor of class 'S'}}
2014-07-11 19:25:16 +08:00
# pragma omp task
# pragma omp parallel shared(sa, sb)
+ + sa , + + sb ;
// expected-note@+1 2 {{defined as reduction}}
# pragma omp parallel reduction(+ : r)
// expected-error@+1 {{argument of a reduction clause of a parallel construct must not appear in a firstprivate clause on a task construct}}
# pragma omp task firstprivate(r)
// expected-error@+1 {{reduction variables may not be accessed in an explicit task}}
+ + r ;
// expected-note@+1 {{defined as reduction}}
# pragma omp parallel reduction(+ : r)
# pragma omp task default(shared)
// expected-error@+1 {{reduction variables may not be accessed in an explicit task}}
+ + r ;
// expected-note@+1 {{defined as reduction}}
# pragma omp parallel reduction(+ : r)
# pragma omp task
// expected-error@+1 {{reduction variables may not be accessed in an explicit task}}
+ + r ;
# pragma omp parallel
// expected-note@+1 2 {{defined as reduction}}
# pragma omp for reduction(+ : r)
for ( int i = 0 ; i < 10 ; + + i )
// expected-error@+1 {{argument of a reduction clause of a for construct must not appear in a firstprivate clause on a task construct}}
# pragma omp task firstprivate(r)
// expected-error@+1 {{reduction variables may not be accessed in an explicit task}}
+ + r ;
# pragma omp parallel
// expected-note@+1 {{defined as reduction}}
# pragma omp for reduction(+ : r)
for ( int i = 0 ; i < 10 ; + + i )
# pragma omp task default(shared)
// expected-error@+1 {{reduction variables may not be accessed in an explicit task}}
+ + r ;
# pragma omp parallel
// expected-note@+1 {{defined as reduction}}
# pragma omp for reduction(+ : r)
for ( int i = 0 ; i < 10 ; + + i )
# pragma omp task
// expected-error@+1 {{reduction variables may not be accessed in an explicit task}}
+ + r ;
// expected-note@+1 {{non-shared variable in a task construct is predetermined as firstprivate}}
# pragma omp task
// expected-error@+2 {{reduction variable must be shared}}
// expected-error@+1 {{region cannot be closely nested inside 'task' region; perhaps you forget to enclose 'omp for' directive into a parallel region?}}
# pragma omp for reduction(+ : r)
+ + r ;
2014-07-17 20:19:31 +08:00
// expected-error@+1 {{directive '#pragma omp task' cannot contain more than one 'untied' clause}}
# pragma omp task untied untied
+ + r ;
2014-07-17 20:47:03 +08:00
// expected-error@+1 {{directive '#pragma omp task' cannot contain more than one 'mergeable' clause}}
# pragma omp task mergeable mergeable
+ + r ;
2021-03-27 03:43:25 +08:00
// expected-error@+4 {{variable length arrays are not supported in OpenMP tasking regions with 'untied' clause}}
// expected-note@+3 {{read of non-const variable 'r' is not allowed in a constant expression}}
# pragma omp task untied
{
int array [ r ] ;
}
2020-03-17 21:17:42 +08:00
volatile omp_event_handle_t evt ;
omp_event_handle_t sevt ;
const omp_event_handle_t cevt = evt ;
omp_event_handle_t & revt = sevt ;
# pragma omp task detach // omp45-error {{unexpected OpenMP clause 'detach' in directive '#pragma omp task'}} expected-error {{expected '(' after 'detach'}}
# pragma omp task detach( // omp45-error {{unexpected OpenMP clause 'detach' in directive '#pragma omp task'}} expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
# pragma omp task detach() // omp45-error {{unexpected OpenMP clause 'detach' in directive '#pragma omp task'}} expected-error {{expected expression}}
# pragma omp task detach(a) // omp45-error {{unexpected OpenMP clause 'detach' in directive '#pragma omp task'}} omp50-error {{expected variable of the 'omp_event_handle_t' type, not 'int'}}
# pragma omp task detach(evt) detach(evt) // omp45-error 2 {{unexpected OpenMP clause 'detach' in directive '#pragma omp task'}} expected-error {{directive '#pragma omp task' cannot contain more than one 'detach' clause}}
# pragma omp task detach(cevt) detach(revt) // omp45-error 2 {{unexpected OpenMP clause 'detach' in directive '#pragma omp task'}} expected-error {{directive '#pragma omp task' cannot contain more than one 'detach' clause}} omp50-error {{expected variable of the 'omp_event_handle_t' type, not 'const omp_event_handle_t' (aka 'const unsigned long')}} omp50-error {{expected variable of the 'omp_event_handle_t' type, not 'omp_event_handle_t &' (aka 'unsigned long &')}}
# pragma omp task detach(evt) mergeable // omp45-error {{unexpected OpenMP clause 'detach' in directive '#pragma omp task'}} omp50-error {{'mergeable' and 'detach' clause are mutually exclusive and may not appear on the same directive}} omp50-note {{'detach' clause is specified here}}
;
# pragma omp task mergeable detach(evt) // omp45-error {{unexpected OpenMP clause 'detach' in directive '#pragma omp task'}} omp50-error {{'detach' and 'mergeable' clause are mutually exclusive and may not appear on the same directive}} omp50-note {{'mergeable' clause is specified here}}
# pragma omp task detach(-evt) // omp45-error {{unexpected OpenMP clause 'detach' in directive '#pragma omp task'}} omp50-error {{expected variable of the 'omp_event_handle_t' type}}
;
2020-03-18 00:10:51 +08:00
# pragma omp task detach(evt) shared(evt) // omp45-error {{unexpected OpenMP clause 'detach' in directive '#pragma omp task'}}
# pragma omp task detach(evt) firstprivate(evt) // omp45-error {{unexpected OpenMP clause 'detach' in directive '#pragma omp task'}}
;
2014-07-11 19:25:16 +08:00
// expected-note@+2 {{in instantiation of function template specialization 'foo<int>' requested here}}
// expected-note@+1 {{in instantiation of function template specialization 'foo<S>' requested here}}
return foo < int > ( ) + foo < S > ( ) ;
}