2015-07-14 06:54:53 +08:00
// RUN: %clang_cc1 -triple x86_64-apple-macos10.7.0 -verify -fopenmp -fnoopenmp-use-tls -ferror-limit 100 -emit-llvm -o - %s
2015-05-20 12:24:19 +08:00
// RUN: %clang_cc1 -triple x86_64-apple-macos10.7.0 -verify -fopenmp -ferror-limit 100 -emit-llvm -o - %s
2013-03-22 14:34:35 +08:00
2013-07-19 11:13:43 +08:00
# pragma omp threadprivate // expected-error {{expected '(' after 'threadprivate'}}
2013-05-13 12:18:18 +08:00
# pragma omp threadprivate( // expected-error {{expected identifier}} expected-error {{expected ')'}} expected-note {{to match this '('}}
# pragma omp threadprivate() // expected-error {{expected identifier}}
2013-03-22 14:34:35 +08:00
# pragma omp threadprivate(1) // expected-error {{expected unqualified-id}}
struct CompleteSt {
int a ;
} ;
struct CompleteSt1 {
# pragma omp threadprivate(1) // expected-error {{expected unqualified-id}}
int a ;
2013-05-13 12:18:18 +08:00
} d ; // expected-note {{'d' defined here}}
2013-03-22 14:34:35 +08:00
2013-05-13 12:18:18 +08:00
int a ; // expected-note {{'a' defined here}}
2013-03-22 14:34:35 +08:00
# pragma omp threadprivate(a)
# pragma omp threadprivate(u) // expected-error {{use of undeclared identifier 'u'}}
2015-04-08 20:45:41 +08:00
# pragma omp threadprivate(d, a)
2013-03-22 14:34:35 +08:00
int foo ( ) { // expected-note {{declared here}}
static int l ;
2013-05-13 12:18:18 +08:00
# pragma omp threadprivate(l)) // expected-warning {{extra tokens at the end of '#pragma omp threadprivate' are ignored}}
2013-03-22 14:34:35 +08:00
return ( a ) ;
}
2013-12-19 06:34:19 +08:00
# pragma omp threadprivate (a) (
2015-04-08 20:45:41 +08:00
// expected-warning@-1 {{extra tokens at the end of '#pragma omp threadprivate' are ignored}}
# pragma omp threadprivate (a) [ // expected-warning {{extra tokens at the end of '#pragma omp threadprivate' are ignored}}
# pragma omp threadprivate (a) { // expected-warning {{extra tokens at the end of '#pragma omp threadprivate' are ignored}}
# pragma omp threadprivate (a) ) // expected-warning {{extra tokens at the end of '#pragma omp threadprivate' are ignored}}
# pragma omp threadprivate (a) ] // expected-warning {{extra tokens at the end of '#pragma omp threadprivate' are ignored}}
# pragma omp threadprivate (a) } // expected-warning {{extra tokens at the end of '#pragma omp threadprivate' are ignored}}
2013-07-19 11:13:43 +08:00
# pragma omp threadprivate a // expected-error {{expected '(' after 'threadprivate'}}
2015-04-08 20:45:41 +08:00
# pragma omp threadprivate(d // expected-error {{expected ')'}} expected-note {{to match this '('}}
# pragma omp threadprivate(d)) // expected-warning {{extra tokens at the end of '#pragma omp threadprivate' are ignored}}
2013-03-22 14:34:35 +08:00
int x , y ;
2013-05-13 12:18:18 +08:00
# pragma omp threadprivate(x)) // expected-warning {{extra tokens at the end of '#pragma omp threadprivate' are ignored}}
2013-12-19 06:34:19 +08:00
# pragma omp threadprivate(y)),
// expected-warning@-1 {{extra tokens at the end of '#pragma omp threadprivate' are ignored}}
# pragma omp threadprivate(a,d)
2013-05-13 12:18:18 +08:00
# pragma omp threadprivate(d.a) // expected-error {{expected identifier}}
2013-03-22 14:34:35 +08:00
# pragma omp threadprivate((float)a) // expected-error {{expected unqualified-id}}
2013-08-17 08:46:16 +08:00
int foa ; // expected-note {{'foa' declared here}}
2013-03-22 14:34:35 +08:00
# pragma omp threadprivate(faa) // expected-error {{use of undeclared identifier 'faa'; did you mean 'foa'?}}
# pragma omp threadprivate(foo) // expected-error {{'foo' is not a global variable, static local variable or static data member}}
# pragma omp threadprivate (int a=2) // expected-error {{expected unqualified-id}}
struct IncompleteSt ; // expected-note {{forward declaration of 'IncompleteSt'}}
extern IncompleteSt e ;
2013-05-13 12:18:18 +08:00
# pragma omp threadprivate (e) // expected-error {{threadprivate variable with incomplete type 'IncompleteSt'}}
2013-03-22 14:34:35 +08:00
2013-05-13 12:18:18 +08:00
int & f = a ; // expected-note {{'f' defined here}}
2013-07-19 11:13:43 +08:00
# pragma omp threadprivate (f) // expected-error {{arguments of '#pragma omp threadprivate' cannot be of reference type 'int &'}}
2013-03-22 14:34:35 +08:00
2014-06-06 11:41:14 +08:00
class TestClass {
2013-03-22 14:34:35 +08:00
private :
int a ; // expected-note {{declared here}}
2013-05-13 12:18:18 +08:00
static int b ; // expected-note {{'b' declared here}}
2014-06-06 11:41:14 +08:00
TestClass ( ) : a ( 0 ) { }
2013-03-22 14:34:35 +08:00
public :
2014-06-06 11:41:14 +08:00
TestClass ( int aaa ) : a ( aaa ) { }
2013-03-22 14:34:35 +08:00
# pragma omp threadprivate (b, a) // expected-error {{'a' is not a global variable, static local variable or static data member}}
} g ( 10 ) ;
# pragma omp threadprivate (b) // expected-error {{use of undeclared identifier 'b'}}
2014-06-06 11:41:14 +08:00
# pragma omp threadprivate (TestClass::b) // expected-error {{'#pragma omp threadprivate' must appear in the scope of the 'TestClass::b' variable declaration}}
2013-03-22 14:34:35 +08:00
# pragma omp threadprivate (g)
namespace ns {
2013-09-26 11:24:06 +08:00
int m ;
2016-02-09 17:41:09 +08:00
# pragma omp threadprivate (m, m)
2013-03-22 14:34:35 +08:00
}
# pragma omp threadprivate (m) // expected-error {{use of undeclared identifier 'm'}}
2015-04-08 20:45:41 +08:00
# pragma omp threadprivate (ns::m)
# pragma omp threadprivate (ns:m) // expected-error {{unexpected ':' in nested name specifier; did you mean '::'?}}
2013-03-22 14:34:35 +08:00
const int h = 12 ;
const volatile int i = 10 ;
# pragma omp threadprivate (h, i)
template < class T >
class TempClass {
private :
T a ;
TempClass ( ) : a ( ) { }
public :
TempClass ( T aaa ) : a ( aaa ) { }
static T s ;
# pragma omp threadprivate (s)
} ;
# pragma omp threadprivate (s) // expected-error {{use of undeclared identifier 's'}}
2013-05-13 12:18:18 +08:00
static __thread int t ; // expected-note {{'t' defined here}}
2013-03-22 14:34:35 +08:00
# pragma omp threadprivate (t) // expected-error {{variable 't' cannot be threadprivate because it is thread-local}}
2015-11-18 08:15:28 +08:00
// Register "0" is currently an invalid register for global register variables.
// Use "esp" instead of "0".
// register int reg0 __asm__("0");
register int reg0 __asm__ ( " esp " ) ; // expected-note {{'reg0' defined here}}
2015-01-13 11:35:30 +08:00
# pragma omp threadprivate (reg0) // expected-error {{variable 'reg0' cannot be threadprivate because it is a global named register variable}}
2013-03-22 14:34:35 +08:00
int o ; // expected-note {{candidate found by name lookup is 'o'}}
2013-05-13 12:18:18 +08:00
# pragma omp threadprivate (o)
2013-03-22 14:34:35 +08:00
namespace {
2014-04-02 13:58:29 +08:00
int o ; // expected-note {{candidate found by name lookup is '(anonymous namespace)::o'}}
2013-05-13 12:18:18 +08:00
# pragma omp threadprivate (o)
2015-04-08 20:45:41 +08:00
# pragma omp threadprivate (o)
2013-03-22 14:34:35 +08:00
}
# pragma omp threadprivate (o) // expected-error {{reference to 'o' is ambiguous}}
2015-04-08 20:45:41 +08:00
# pragma omp threadprivate (::o)
2013-03-22 14:34:35 +08:00
2013-05-13 12:18:18 +08:00
int main ( int argc , char * * argv ) { // expected-note {{'argc' defined here}}
2013-03-22 14:34:35 +08:00
2014-05-28 15:40:25 +08:00
int x , y = argc ; // expected-note 2 {{'y' defined here}}
2013-03-22 14:34:35 +08:00
static double d1 ;
static double d2 ;
2013-05-13 12:18:18 +08:00
static double d3 ; // expected-note {{'d3' defined here}}
2016-01-13 19:18:54 +08:00
static double d4 ;
2014-06-06 11:41:14 +08:00
static TestClass LocalClass ( y ) ; // expected-error {{variable with local storage in initial value of threadprivate variable}}
2014-05-28 15:40:25 +08:00
# pragma omp threadprivate(LocalClass)
2013-03-22 14:34:35 +08:00
d . a = a ;
d2 + + ;
;
2013-05-13 12:18:18 +08:00
# pragma omp threadprivate(argc+y) // expected-error {{expected identifier}}
2013-03-22 14:34:35 +08:00
# pragma omp threadprivate(argc,y) // expected-error 2 {{arguments of '#pragma omp threadprivate' must have static storage duration}}
# pragma omp threadprivate(d2) // expected-error {{'#pragma omp threadprivate' must precede all references to variable 'd2'}}
# pragma omp threadprivate(d1)
{
+ + a ; d2 = 0 ;
# pragma omp threadprivate(d3) // expected-error {{'#pragma omp threadprivate' must appear in the scope of the 'd3' variable declaration}}
}
# pragma omp threadprivate(d3)
2016-01-13 19:18:54 +08:00
label :
# pragma omp threadprivate(d4) // expected-error {{'#pragma omp threadprivate' cannot be an immediate substatement}}
2013-03-22 14:34:35 +08:00
# pragma omp threadprivate(a) // expected-error {{'#pragma omp threadprivate' must appear in the scope of the 'a' variable declaration}}
return ( y ) ;
# pragma omp threadprivate(d) // expected-error {{'#pragma omp threadprivate' must appear in the scope of the 'd' variable declaration}}
}