[clang] [clang][OpenMP] 6.0: detect privatization of array section/assumed-size array (PR #152786)

David Pagan via cfe-commits cfe-commits at lists.llvm.org
Wed Aug 27 13:45:27 PDT 2025


================
@@ -5177,6 +5190,17 @@ static std::pair<ValueDecl *, bool> getPrivateItem(Sema &S, Expr *&RefExpr,
       IsArrayExpr = ArraySubscript;
     } else if (auto *OASE = dyn_cast_or_null<ArraySectionExpr>(RefExpr)) {
       Expr *Base = OASE->getBase()->IgnoreParenImpCasts();
+      if (S.getLangOpts().OpenMP >= 60 && !AllowAssumedSizeArray &&
+          OASE->getColonLocFirst().isValid() && !OASE->getLength()) {
+        QualType BaseType = ArraySectionExpr::getBaseOriginalType(Base);
+        if (BaseType.isNull() || (!BaseType->isConstantArrayType() &&
+                                  !BaseType->isVariableArrayType())) {
----------------
ddpagan wrote:

Thanks, Alexey. This does work correctly in templates and is verified in the updated test cases that are part of this pull request.

https://github.com/llvm/llvm-project/pull/152786


More information about the cfe-commits mailing list