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// REQUIRES: x86-registered-target
9
10#ifndef HEADER
11#define HEADER
12
13struct St{
14 int a;
15};
16
17struct St1{
18 int a;
19 static int b;
20// CHECK: static int b;
21#pragma omp threadprivate(b)
22// CHECK-NEXT: #pragma omp threadprivate(St1::b)
23} d;
24
25int a, b;
26// CHECK: int a;
27// CHECK: int b;
28#pragma omp threadprivate(a)
29#pragma omp threadprivate(a)
30// CHECK-NEXT: #pragma omp threadprivate(a)
31// CHECK-NEXT: #pragma omp threadprivate(a)
32#pragma omp threadprivate(d, b)
33// CHECK-NEXT: #pragma omp threadprivate(d,b)
34
35template <class T>
36struct ST {
37  static T m;
38  #pragma omp threadprivate(m)
39};
40
41template <class T> T foo() {
42  static T v;
43  #pragma omp threadprivate(v)
44  v = ST<T>::m;
45  return v;
46}
47//CHECK: template <class T = int> int foo() {
48//CHECK-NEXT: static int v;
49//CHECK-NEXT: #pragma omp threadprivate(v)
50//CHECK: template <class T> T foo() {
51//CHECK-NEXT: static T v;
52//CHECK-NEXT: #pragma omp threadprivate(v)
53
54namespace ns{
55  int a;
56}
57// CHECK: namespace ns {
58// CHECK-NEXT: int a;
59// CHECK-NEXT: }
60#pragma omp threadprivate(ns::a)
61// CHECK-NEXT: #pragma omp threadprivate(ns::a)
62
63int main () {
64  static int a;
65// CHECK: static int a;
66#pragma omp threadprivate(a)
67// CHECK-NEXT: #pragma omp threadprivate(a)
68  a=2;
69  return (foo<int>());
70}
71
72extern template int ST<int>::m;
73#endif
74