@@ -68,14 +68,33 @@ mlir::Value CIRGenFunction::createOpenACCConstantInt(mlir::Location loc,
6868CIRGenFunction::OpenACCDataOperandInfo
6969CIRGenFunction::getOpenACCDataOperandInfo (const Expr *e) {
7070 const Expr *curVarExpr = e->IgnoreParenImpCasts ();
71+ QualType origType =
72+ curVarExpr->getType ().getNonReferenceType ().getUnqualifiedType ();
73+ // Array sections are special, and we have to treat them that way.
74+ if (const auto *section =
75+ dyn_cast<ArraySectionExpr>(curVarExpr->IgnoreParenImpCasts ()))
76+ origType = ArraySectionExpr::getBaseOriginalType (section);
7177
7278 mlir::Location exprLoc = cgm.getLoc (curVarExpr->getBeginLoc ());
7379 llvm::SmallVector<mlir::Value> bounds;
80+ llvm::SmallVector<QualType> boundTypes;
7481
7582 std::string exprString;
7683 llvm::raw_string_ostream os (exprString);
7784 e->printPretty (os, nullptr , getContext ().getPrintingPolicy ());
7885
86+ auto addBoundType = [&](const Expr *e) {
87+ if (const auto *section = dyn_cast<ArraySectionExpr>(curVarExpr)) {
88+ QualType baseTy = ArraySectionExpr::getBaseOriginalType (
89+ section->getBase ()->IgnoreParenImpCasts ());
90+ boundTypes.push_back (QualType (baseTy->getPointeeOrArrayElementType (), 0 ));
91+ } else {
92+ boundTypes.push_back (curVarExpr->getType ());
93+ }
94+ };
95+
96+ addBoundType (curVarExpr);
97+
7998 while (isa<ArraySectionExpr, ArraySubscriptExpr>(curVarExpr)) {
8099 mlir::Location boundLoc = cgm.getLoc (curVarExpr->getBeginLoc ());
81100 mlir::Value lowerBound;
@@ -115,19 +134,28 @@ CIRGenFunction::getOpenACCDataOperandInfo(const Expr *e) {
115134
116135 bounds.push_back (createBound (*this , this ->builder , boundLoc, lowerBound,
117136 upperBound, extent));
137+ addBoundType (curVarExpr);
118138 }
119139
120140 if (const auto *memExpr = dyn_cast<MemberExpr>(curVarExpr))
121- return {exprLoc, emitMemberExpr (memExpr).getPointer (), exprString,
141+ return {exprLoc,
142+ emitMemberExpr (memExpr).getPointer (),
143+ exprString,
144+ origType,
122145 curVarExpr->getType ().getNonReferenceType ().getUnqualifiedType (),
123- std::move (bounds)};
146+ std::move (bounds),
147+ std::move (boundTypes)};
124148
125149 // Sema has made sure that only 4 types of things can get here, array
126150 // subscript, array section, member expr, or DRE to a var decl (or the
127151 // former 3 wrapping a var-decl), so we should be able to assume this is
128152 // right.
129153 const auto *dre = cast<DeclRefExpr>(curVarExpr);
130- return {exprLoc, emitDeclRefLValue (dre).getPointer (), exprString,
154+ return {exprLoc,
155+ emitDeclRefLValue (dre).getPointer (),
156+ exprString,
157+ origType,
131158 curVarExpr->getType ().getNonReferenceType ().getUnqualifiedType (),
132- std::move (bounds)};
159+ std::move (bounds),
160+ std::move (boundTypes)};
133161}
0 commit comments