1 // RUN: %clang_cc1 -verify -fopenmp -triple x86_64-apple-darwin10.6.0 -ast-print %s | FileCheck %s
2 // RUN: %clang_cc1 -fopenmp -triple x86_64-apple-darwin10.6.0 -x c++ -std=c++11 -emit-pch -o %t %s
3 // RUN: %clang_cc1 -fopenmp -triple x86_64-apple-darwin10.6.0 -std=c++11 -include-pch %t -fsyntax-only -verify %s -ast-print
4 // RUN: %clang_cc1 -verify -fopenmp -triple x86_64-unknown-linux-gnu -ast-print %s | FileCheck %s
5 // RUN: %clang_cc1 -fopenmp -fnoopenmp-use-tls -triple x86_64-unknown-linux-gnu -x c++ -std=c++11 -emit-pch -o %t %s
6 // RUN: %clang_cc1 -fopenmp -fnoopenmp-use-tls -triple x86_64-unknown-linux-gnu -std=c++11 -include-pch %t -fsyntax-only -verify %s -ast-print
7 // expected-no-diagnostics
8 
9 #ifndef HEADER
10 #define HEADER
11 
12 struct St{
13  int a;
14 };
15 
16 struct St1{
17  int a;
18  static int b;
19 // CHECK: static int b;
20 #pragma omp threadprivate(b)
21 // CHECK-NEXT: #pragma omp threadprivate(St1::b)
22 } d;
23 
24 int a, b;
25 // CHECK: int a;
26 // CHECK: int b;
27 #pragma omp threadprivate(a)
28 #pragma omp threadprivate(a)
29 // CHECK-NEXT: #pragma omp threadprivate(a)
30 // CHECK-NEXT: #pragma omp threadprivate(a)
31 #pragma omp threadprivate(d, b)
32 // CHECK-NEXT: #pragma omp threadprivate(d,b)
33 
34 template <class T>
35 struct ST {
36   static T m;
37   #pragma omp threadprivate(m)
38 };
39 
40 template <class T> T foo() {
41   static T v;
42   #pragma omp threadprivate(v)
43   v = ST<T>::m;
44   return v;
45 }
46 //CHECK: template <class T> T foo() {
47 //CHECK-NEXT: static T v;
48 //CHECK-NEXT: #pragma omp threadprivate(v)
49 //CHECK: template<> int foo<int>() {
50 //CHECK-NEXT: static int v;
51 //CHECK-NEXT: #pragma omp threadprivate(v)
52 
53 namespace ns{
54   int a;
55 }
56 // CHECK: namespace ns {
57 // CHECK-NEXT: int a;
58 // CHECK-NEXT: }
59 #pragma omp threadprivate(ns::a)
60 // CHECK-NEXT: #pragma omp threadprivate(ns::a)
61 
62 int main () {
63   static int a;
64 // CHECK: static int a;
65 #pragma omp threadprivate(a)
66 // CHECK-NEXT: #pragma omp threadprivate(a)
67   a=2;
68   return (foo<int>());
69 }
70 
71 extern template int ST<int>::m;
72 #endif
73