Home | History | Annotate | Download | only in OpenMP
      1 // RUN: %clang_cc1 -triple x86_64-apple-macos10.7.0 -verify -fopenmp -ferror-limit 100 %s
      2 
      3 #pragma omp threadprivate // expected-error {{expected '(' after 'threadprivate'}}
      4 #pragma omp threadprivate( // expected-error {{expected identifier}} expected-error {{expected ')'}} expected-note {{to match this '('}}
      5 #pragma omp threadprivate() // expected-error {{expected identifier}}
      6 #pragma omp threadprivate(1) // expected-error {{expected unqualified-id}}
      7 struct CompleteSt{
      8  int a;
      9 };
     10 
     11 struct CompleteSt1{
     12 #pragma omp threadprivate(1) // expected-error {{expected unqualified-id}}
     13  int a;
     14 } d; // expected-note {{'d' defined here}}
     15 
     16 int a; // expected-note {{'a' defined here}}
     17 
     18 #pragma omp threadprivate(a)
     19 #pragma omp threadprivate(u) // expected-error {{use of undeclared identifier 'u'}}
     20 #pragma omp threadprivate(d, a) // expected-error {{'#pragma omp threadprivate' must precede all references to variable 'a'}}
     21 int foo() { // expected-note {{declared here}}
     22   static int l;
     23 #pragma omp threadprivate(l)) // expected-warning {{extra tokens at the end of '#pragma omp threadprivate' are ignored}}
     24   return (a);
     25 }
     26 
     27 #pragma omp threadprivate a // expected-error {{expected '(' after 'threadprivate'}}
     28 #pragma omp threadprivate(d // expected-error {{expected ')'}} expected-note {{to match this '('}} expected-error {{'#pragma omp threadprivate' must precede all references to variable 'd'}}
     29 #pragma omp threadprivate(d)) // expected-error {{'#pragma omp threadprivate' must precede all references to variable 'd'}} expected-warning {{extra tokens at the end of '#pragma omp threadprivate' are ignored}}
     30 int x, y;
     31 #pragma omp threadprivate(x)) // expected-warning {{extra tokens at the end of '#pragma omp threadprivate' are ignored}}
     32 #pragma omp threadprivate(y)), // expected-warning {{extra tokens at the end of '#pragma omp threadprivate' are ignored}}
     33 #pragma omp threadprivate(a,d)  // expected-error {{'#pragma omp threadprivate' must precede all references to variable 'a'}} expected-error {{'#pragma omp threadprivate' must precede all references to variable 'd'}}
     34 #pragma omp threadprivate(d.a) // expected-error {{expected identifier}}
     35 #pragma omp threadprivate((float)a) // expected-error {{expected unqualified-id}}
     36 int foa;
     37 #pragma omp threadprivate(faa) // expected-error {{use of undeclared identifier 'faa'; did you mean 'foa'?}}
     38 #pragma omp threadprivate(foo) // expected-error {{'foo' is not a global variable, static local variable or static data member}}
     39 #pragma omp threadprivate (int a=2) // expected-error {{expected unqualified-id}}
     40 
     41 struct IncompleteSt; // expected-note {{forward declaration of 'IncompleteSt'}}
     42 
     43 extern IncompleteSt e;
     44 #pragma omp threadprivate (e) // expected-error {{threadprivate variable with incomplete type 'IncompleteSt'}}
     45 
     46 int &f = a; // expected-note {{'f' defined here}}
     47 #pragma omp threadprivate (f) // expected-error {{arguments of '#pragma omp threadprivate' cannot be of reference type 'int &'}}
     48 
     49 class Class {
     50   private:
     51     int a; // expected-note {{declared here}}
     52     static int b; // expected-note {{'b' declared here}}
     53     Class() : a(0){}
     54   public:
     55     Class (int aaa) : a(aaa) {}
     56 #pragma omp threadprivate (b, a) // expected-error {{'a' is not a global variable, static local variable or static data member}}
     57 } g(10);
     58 #pragma omp threadprivate (b) // expected-error {{use of undeclared identifier 'b'}}
     59 #pragma omp threadprivate (Class::b) // expected-error {{'#pragma omp threadprivate' must appear in the scope of the 'Class::b' variable declaration}}
     60 #pragma omp threadprivate (g)
     61 
     62 namespace ns {
     63   int m; // expected-note 2 {{'m' defined here}}
     64 #pragma omp threadprivate (m)
     65 }
     66 #pragma omp threadprivate (m) // expected-error {{use of undeclared identifier 'm'}}
     67 #pragma omp threadprivate (ns::m) // expected-error {{'#pragma omp threadprivate' must appear in the scope of the 'ns::m' variable declaration}}
     68 #pragma omp threadprivate (ns:m) // expected-error {{unexpected ':' in nested name specifier; did you mean '::'?}} expected-error {{'#pragma omp threadprivate' must appear in the scope of the 'ns::m' variable declaration}}
     69 
     70 const int h = 12;
     71 const volatile int i = 10;
     72 #pragma omp threadprivate (h, i)
     73 
     74 
     75 template <class T>
     76 class TempClass {
     77   private:
     78     T a;
     79     TempClass() : a(){}
     80   public:
     81     TempClass (T aaa) : a(aaa) {}
     82     static T s;
     83 #pragma omp threadprivate (s)
     84 };
     85 #pragma omp threadprivate (s) // expected-error {{use of undeclared identifier 's'}}
     86 
     87 static __thread int t; // expected-note {{'t' defined here}}
     88 #pragma omp threadprivate (t) // expected-error {{variable 't' cannot be threadprivate because it is thread-local}}
     89 
     90 int o; // expected-note {{candidate found by name lookup is 'o'}}
     91 #pragma omp threadprivate (o)
     92 namespace {
     93 int o; // expected-note {{candidate found by name lookup is '<anonymous namespace>::o'}}
     94 #pragma omp threadprivate (o)
     95 #pragma omp threadprivate (o) // expected-error {{'#pragma omp threadprivate' must precede all references to variable '<anonymous namespace>::o'}}
     96 }
     97 #pragma omp threadprivate (o) // expected-error {{reference to 'o' is ambiguous}}
     98 #pragma omp threadprivate (::o) // expected-error {{'#pragma omp threadprivate' must precede all references to variable 'o'}}
     99 
    100 int main(int argc, char **argv) { // expected-note {{'argc' defined here}}
    101 
    102   int x, y = argc; // expected-note {{'y' defined here}}
    103   static double d1;
    104   static double d2;
    105   static double d3; // expected-note {{'d3' defined here}}
    106 
    107   d.a = a;
    108   d2++;
    109   ;
    110 #pragma omp threadprivate(argc+y) // expected-error {{expected identifier}}
    111 #pragma omp threadprivate(argc,y) // expected-error 2 {{arguments of '#pragma omp threadprivate' must have static storage duration}}
    112 #pragma omp threadprivate(d2) // expected-error {{'#pragma omp threadprivate' must precede all references to variable 'd2'}}
    113 #pragma omp threadprivate(d1)
    114   {
    115   ++a;d2=0;
    116 #pragma omp threadprivate(d3) // expected-error {{'#pragma omp threadprivate' must appear in the scope of the 'd3' variable declaration}}
    117   }
    118 #pragma omp threadprivate(d3)
    119 
    120 #pragma omp threadprivate(a) // expected-error {{'#pragma omp threadprivate' must appear in the scope of the 'a' variable declaration}}
    121   return (y);
    122 #pragma omp threadprivate(d) // expected-error {{'#pragma omp threadprivate' must appear in the scope of the 'd' variable declaration}}
    123 }
    124