blob: 3227822d975bc874585487e7f1dff76db4ee6fd6 [file] [log] [blame]
Stephen Hines651f13c2014-04-23 16:59:28 -07001// RUN: %clang_cc1 -verify -fopenmp=libiomp5 -ast-print %s | FileCheck %s
2// RUN: %clang_cc1 -fopenmp=libiomp5 -x c++ -std=c++11 -emit-pch -o %t %s
3// RUN: %clang_cc1 -fopenmp=libiomp5 -std=c++11 -include-pch %t -fsyntax-only -verify %s -ast-print
Alexey Bataevc6400582013-03-22 06:34:35 +00004// expected-no-diagnostics
5
Alexey Bataev4fa7eab2013-07-19 03:13:43 +00006#ifndef HEADER
7#define HEADER
8
Alexey Bataevc6400582013-03-22 06:34:35 +00009struct St{
10 int a;
11};
12
13struct St1{
14 int a;
15 static int b;
16// CHECK: static int b;
17#pragma omp threadprivate(b)
Alexey Bataevd0dbb7e2013-09-26 03:24:06 +000018// CHECK-NEXT: #pragma omp threadprivate(St1::b)
Alexey Bataevc6400582013-03-22 06:34:35 +000019} d;
20
21int a, b;
22// CHECK: int a;
23// CHECK: int b;
24#pragma omp threadprivate(a)
Pirama Arumuga Nainar33337ca2015-05-06 11:48:57 -070025#pragma omp threadprivate(a)
26// CHECK-NEXT: #pragma omp threadprivate(a)
Alexey Bataevc6400582013-03-22 06:34:35 +000027// CHECK-NEXT: #pragma omp threadprivate(a)
28#pragma omp threadprivate(d, b)
29// CHECK-NEXT: #pragma omp threadprivate(d,b)
30
Stephen Hines651f13c2014-04-23 16:59:28 -070031template <class T>
32struct ST {
33 static T m;
34 #pragma omp threadprivate(m)
35};
36
Alexey Bataevc6400582013-03-22 06:34:35 +000037template <class T> T foo() {
38 static T v;
39 #pragma omp threadprivate(v)
Stephen Hines651f13c2014-04-23 16:59:28 -070040 v = ST<T>::m;
Alexey Bataevc6400582013-03-22 06:34:35 +000041 return v;
42}
43//CHECK: template <class T = int> int foo() {
44//CHECK-NEXT: static int v;
45//CHECK-NEXT: #pragma omp threadprivate(v)
46//CHECK: template <class T> T foo() {
47//CHECK-NEXT: static T v;
48//CHECK-NEXT: #pragma omp threadprivate(v)
49
Alexey Bataevd0dbb7e2013-09-26 03:24:06 +000050namespace ns{
51 int a;
52}
53// CHECK: namespace ns {
54// CHECK-NEXT: int a;
55// CHECK-NEXT: }
56#pragma omp threadprivate(ns::a)
57// CHECK-NEXT: #pragma omp threadprivate(ns::a)
58
Alexey Bataevc6400582013-03-22 06:34:35 +000059int main () {
60 static int a;
61// CHECK: static int a;
62#pragma omp threadprivate(a)
63// CHECK-NEXT: #pragma omp threadprivate(a)
64 a=2;
65 return (foo<int>());
66}
Alexey Bataev4fa7eab2013-07-19 03:13:43 +000067
68#endif