Skip to content

Commit aef0bf4

Browse files
author
Sunil Kuravinakop
committed
Same changes as in fix for 165276 except for remove unnecessary include in test to restore Ubuntu build.
This is not needed as allocatable modifier is not applicable to the default clause in C/C++.
1 parent dd7a000 commit aef0bf4

File tree

2 files changed

+94
-3
lines changed

2 files changed

+94
-3
lines changed

clang/lib/Sema/SemaOpenMP.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1364,15 +1364,15 @@ DSAStackTy::DSAVarData DSAStackTy::getDSA(const_iterator &Iter,
13641364
DefaultDataSharingAttributes IterDA = Iter->DefaultAttr;
13651365
switch (Iter->DefaultVCAttr) {
13661366
case DSA_VC_aggregate:
1367-
if (!VD->getType()->isAggregateType())
1367+
if (!D->getType()->isAggregateType())
13681368
IterDA = DSA_none;
13691369
break;
13701370
case DSA_VC_pointer:
1371-
if (!VD->getType()->isPointerType())
1371+
if (!D->getType()->isPointerType())
13721372
IterDA = DSA_none;
13731373
break;
13741374
case DSA_VC_scalar:
1375-
if (!VD->getType()->isScalarType())
1375+
if (!D->getType()->isScalarType())
13761376
IterDA = DSA_none;
13771377
break;
13781378
case DSA_VC_all:
Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
// RUN: %clangxx -Xclang -verify -Wno-vla -fopenmp -fopenmp-version=60 -x c++ -S -emit-llvm %s -o - | FileCheck %s
2+
// expected-no-diagnostics
3+
#ifndef HEADER
4+
#define HEADER
5+
6+
int global;
7+
#define VECTOR_SIZE 4
8+
9+
int main (int argc, char **argv) {
10+
int i,n;
11+
int x;
12+
13+
n = VECTOR_SIZE;
14+
15+
#pragma omp parallel masked firstprivate(x) num_threads(2)
16+
{
17+
int *xPtr = nullptr;
18+
// scalar
19+
#pragma omp task default(shared:scalar)
20+
{
21+
xPtr = &x;
22+
}
23+
#pragma omp taskwait
24+
25+
// pointer
26+
#pragma omp task default(shared:pointer) shared(x)
27+
{
28+
xPtr = &x;
29+
}
30+
#pragma omp taskwait
31+
}
32+
33+
int *aggregate[VECTOR_SIZE] = {0,0,0,0};
34+
35+
#pragma omp parallel masked num_threads(2)
36+
{
37+
// aggregate
38+
#pragma omp task default(shared:aggregate)
39+
for(i=0;i<n;i++) {
40+
aggregate[i] = &x;
41+
}
42+
#pragma omp taskwait
43+
44+
#pragma omp task default(shared:aggregate) shared(x)
45+
for(i=0;i<n;i++) {
46+
aggregate[i] = &x;
47+
}
48+
#pragma omp taskwait
49+
50+
// all
51+
#pragma omp task default(shared:all)
52+
for(i=0;i<n;i++) {
53+
aggregate[i] = &x;
54+
}
55+
#pragma omp taskwait
56+
}
57+
}
58+
59+
#endif
60+
61+
// CHECK-LABEL: define {{.*}}main.omp_outlined{{.*}}
62+
// CHECK-NEXT: entry:
63+
// CHECK: %x.addr = alloca{{.*}}
64+
// CHECK: %xPtr = alloca{{.*}}
65+
// CHECK: store ptr null, ptr %xPtr{{.*}}
66+
// CHECK: store ptr %xPtr{{.*}}
67+
// CHECK: store ptr %x.addr{{.*}}
68+
// CHECK-NEXT: {{.*}}call{{.*}}__kmpc_omp_task_alloc{{.*}}
69+
// CHECK: ret void
70+
//
71+
// CHECK: define {{.*}}main.omp_outlined{{.*}}
72+
// CHECK-NEXT: entry:
73+
// CHECK-DAG: %i.addr = alloca{{.*}}
74+
// CHECK-DAG: %n.addr = alloca{{.*}}
75+
// CHECK-DAG: %aggregate.addr = alloca{{.*}}
76+
// CHECK-DAG: %x.addr = alloca{{.*}}
77+
// CHECK: [[TMP0:%.*]] = load{{.*}}%i.addr{{.*}}
78+
// CHECK-NEXT: [[TMP1:%.*]] = load{{.*}}%n.addr{{.*}}
79+
// CHECK-NEXT: [[TMP2:%.*]] = load{{.*}}%aggregate.addr{{.*}}
80+
// CHECK-NEXT: [[TMP3:%.*]] = load{{.*}}%x.addr{{.*}}
81+
// CHECK: store ptr [[TMP2]]{{.*}}
82+
// CHECK-NEXT: {{.*}}call{{.*}}__kmpc_omp_task_alloc{{.*}}
83+
// CHECK: store ptr [[TMP2]]{{.*}}
84+
// CHECK: store ptr [[TMP3]]{{.*}}
85+
// CHECK-NEXT: {{.*}}call{{.*}}__kmpc_omp_task_alloc{{.*}}
86+
// CHECK: store ptr [[TMP0]]{{.*}}
87+
// CHECK: store ptr [[TMP1]]{{.*}}
88+
// CHECK: store ptr [[TMP2]]{{.*}}
89+
// CHECK: store ptr [[TMP3]]{{.*}}
90+
// CHECK-NEXT: {{.*}}call{{.*}}__kmpc_omp_task_alloc{{.*}}
91+
// CHECK: ret void

0 commit comments

Comments
 (0)