xref: /minix3/external/bsd/llvm/dist/clang/test/OpenMP/threadprivate_ast_print.cpp (revision 0a6a1f1d05b60e214de2f05a7310ddd1f0e590e7)
1*0a6a1f1dSLionel Sambuc // RUN: %clang_cc1 -verify -fopenmp=libiomp5 -ast-print %s | FileCheck %s
2*0a6a1f1dSLionel Sambuc // RUN: %clang_cc1 -fopenmp=libiomp5 -x c++ -std=c++11 -emit-pch -o %t %s
3*0a6a1f1dSLionel Sambuc // RUN: %clang_cc1 -fopenmp=libiomp5 -std=c++11 -include-pch %t -fsyntax-only -verify %s -ast-print
4f4a2713aSLionel Sambuc // expected-no-diagnostics
5f4a2713aSLionel Sambuc 
6f4a2713aSLionel Sambuc #ifndef HEADER
7f4a2713aSLionel Sambuc #define HEADER
8f4a2713aSLionel Sambuc 
9f4a2713aSLionel Sambuc struct St{
10f4a2713aSLionel Sambuc  int a;
11f4a2713aSLionel Sambuc };
12f4a2713aSLionel Sambuc 
13f4a2713aSLionel Sambuc struct St1{
14f4a2713aSLionel Sambuc  int a;
15f4a2713aSLionel Sambuc  static int b;
16f4a2713aSLionel Sambuc // CHECK: static int b;
17f4a2713aSLionel Sambuc #pragma omp threadprivate(b)
18f4a2713aSLionel Sambuc // CHECK-NEXT: #pragma omp threadprivate(St1::b)
19f4a2713aSLionel Sambuc } d;
20f4a2713aSLionel Sambuc 
21f4a2713aSLionel Sambuc int a, b;
22f4a2713aSLionel Sambuc // CHECK: int a;
23f4a2713aSLionel Sambuc // CHECK: int b;
24f4a2713aSLionel Sambuc #pragma omp threadprivate(a)
25f4a2713aSLionel Sambuc // CHECK-NEXT: #pragma omp threadprivate(a)
26f4a2713aSLionel Sambuc #pragma omp threadprivate(d, b)
27f4a2713aSLionel Sambuc // CHECK-NEXT: #pragma omp threadprivate(d,b)
28f4a2713aSLionel Sambuc 
29*0a6a1f1dSLionel Sambuc template <class T>
30*0a6a1f1dSLionel Sambuc struct ST {
31*0a6a1f1dSLionel Sambuc   static T m;
32*0a6a1f1dSLionel Sambuc   #pragma omp threadprivate(m)
33*0a6a1f1dSLionel Sambuc };
34*0a6a1f1dSLionel Sambuc 
foo()35f4a2713aSLionel Sambuc template <class T> T foo() {
36f4a2713aSLionel Sambuc   static T v;
37f4a2713aSLionel Sambuc   #pragma omp threadprivate(v)
38*0a6a1f1dSLionel Sambuc   v = ST<T>::m;
39f4a2713aSLionel Sambuc   return v;
40f4a2713aSLionel Sambuc }
41f4a2713aSLionel Sambuc //CHECK: template <class T = int> int foo() {
42f4a2713aSLionel Sambuc //CHECK-NEXT: static int v;
43f4a2713aSLionel Sambuc //CHECK-NEXT: #pragma omp threadprivate(v)
44f4a2713aSLionel Sambuc //CHECK: template <class T> T foo() {
45f4a2713aSLionel Sambuc //CHECK-NEXT: static T v;
46f4a2713aSLionel Sambuc //CHECK-NEXT: #pragma omp threadprivate(v)
47f4a2713aSLionel Sambuc 
48f4a2713aSLionel Sambuc namespace ns{
49f4a2713aSLionel Sambuc   int a;
50f4a2713aSLionel Sambuc }
51f4a2713aSLionel Sambuc // CHECK: namespace ns {
52f4a2713aSLionel Sambuc // CHECK-NEXT: int a;
53f4a2713aSLionel Sambuc // CHECK-NEXT: }
54f4a2713aSLionel Sambuc #pragma omp threadprivate(ns::a)
55f4a2713aSLionel Sambuc // CHECK-NEXT: #pragma omp threadprivate(ns::a)
56f4a2713aSLionel Sambuc 
main()57f4a2713aSLionel Sambuc int main () {
58f4a2713aSLionel Sambuc   static int a;
59f4a2713aSLionel Sambuc // CHECK: static int a;
60f4a2713aSLionel Sambuc #pragma omp threadprivate(a)
61f4a2713aSLionel Sambuc // CHECK-NEXT: #pragma omp threadprivate(a)
62f4a2713aSLionel Sambuc   a=2;
63f4a2713aSLionel Sambuc   return (foo<int>());
64f4a2713aSLionel Sambuc }
65f4a2713aSLionel Sambuc 
66f4a2713aSLionel Sambuc #endif
67