Skip to content

Commit 9053565

Browse files
erichkeanenekoshirro
authored andcommitted
[OpenACC] Make sure 'link' gets the right node in the AST with ASE
Another miss when working through 'link', we didn't properly handle giving the whole array-section expression or array index expression, instead allowed it to only get the decl-ref-expr. This patch makes sure we don't add the wrong thing. Signed-off-by: Hafidz Muzakky <[email protected]>
1 parent e972bc2 commit 9053565

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

clang/lib/Sema/SemaOpenACCClause.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2249,6 +2249,8 @@ SemaOpenACC::CheckLinkClauseVarList(ArrayRef<Expr *> VarExprs) {
22492249
continue;
22502250
}
22512251

2252+
Expr *OrigExpr = VarExpr;
2253+
22522254
while (isa<ArraySectionExpr, ArraySubscriptExpr>(VarExpr)) {
22532255
if (auto *ASE = dyn_cast<ArraySectionExpr>(VarExpr))
22542256
VarExpr = ASE->getBase()->IgnoreParenImpCasts();
@@ -2263,7 +2265,7 @@ SemaOpenACC::CheckLinkClauseVarList(ArrayRef<Expr *> VarExprs) {
22632265
if (!Var || !Var->hasExternalStorage())
22642266
Diag(VarExpr->getBeginLoc(), diag::err_acc_link_not_extern);
22652267
else
2266-
NewVarList.push_back(VarExpr);
2268+
NewVarList.push_back(OrigExpr);
22672269
}
22682270

22692271
return NewVarList;

clang/test/SemaOpenACC/declare-construct-ast.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,12 @@ int GlobalArray3[5];
4949
// CHECK-NEXT: DeclRefExpr{{.*}}'Global3' 'int'
5050
// CHECK-NEXT: device_resident clause
5151
// CHECK-NEXT: DeclRefExpr{{.*}}'GlobalArray3' 'int[5]'
52+
int GlobalArray4[5];
53+
// CHECK-NEXT: VarDecl{{.*}}GlobalArray4 'int[5]'
54+
#pragma acc declare link(GlobalArray4[1:1])
55+
// CHECK-NEXT: OpenACCDeclareDecl
56+
// CHECK-NEXT: link clause
57+
// CHECK-NEXT: ArraySectionExpr
5258

5359
namespace NS {
5460
int NSVar;

0 commit comments

Comments
 (0)