[PATCH] D17547: [OpenMP] Add support for multidimensional array sections in map clause SEMA.
Alexey Bataev via cfe-commits
cfe-commits at lists.llvm.org
Thu Feb 25 19:30:28 PST 2016
ABataev added inline comments.
================
Comment at: include/clang/Basic/DiagnosticSemaKinds.td:7767-7768
@@ -7766,4 +7766,4 @@
"bit fields cannot be used to specify storage in a map clause">;
-def err_omp_array_section_in_rightmost_expression : Error<
- "array section can only be associated with the rightmost variable in a map clause expression">;
+def err_omp_array_section_leads_to_non_contiguous_storage : Error<
+ "employed array section is or can be incompatible with contiguous storage requirements">;
def err_omp_union_type_not_allowed : Error<
----------------
If you say 'can be' incompatible, then this must be a warning, not an error
================
Comment at: lib/Sema/SemaOpenMP.cpp:8988-8995
@@ +8987,10 @@
+
+ // If this is an array subscript, it refers to the whole size if the size of
+ // the dimension is constant and equals 1. Also, an array section assumes the
+ // format of an array subscript if no colon is used.
+ if (isa<ArraySubscriptExpr>(E) || (OASE && OASE->getColonLoc().isInvalid())) {
+ if (auto *ATy = dyn_cast<ConstantArrayType>(BaseQTy.getTypePtr()))
+ return ATy->getSize().getSExtValue() == 1;
+ return false;
+ }
+
----------------
I can't agree with that. For example:
```
const int n = 0;
arr[n:]
```
It won't work with your solution, though we shall support it
================
Comment at: lib/Sema/SemaOpenMP.cpp:9208-9220
@@ -9113,6 +9207,15 @@
+ // Determine the dimension we care about. We need to skip all the nested
+ // array sections to determine that.
+ unsigned Dimension = 0;
+ auto *BaseE = E;
+ while (auto *SE = dyn_cast<OMPArraySectionExpr>(BaseE)) {
+ BaseE = SE->getBase()->IgnoreParenImpCasts();
+ ++Dimension;
+ }
+
// OpenMP 4.5 [2.15.5.1, map Clause, Restrictions, C++, p.1]
// If the type of a list item is a reference to a type T then the type
// will be considered to be T for all purposes of this clause.
- QualType CurType = E->getType();
+ QualType CurType = BaseE->getType();
if (CurType->isReferenceType())
----------------
OMPArraySectionExpr has static function getBaseOriginalType()
http://reviews.llvm.org/D17547
More information about the cfe-commits
mailing list