[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
Thu Aug 14 08:27:09 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:

Hi Alexey - I've tried various cases and I'm not seeing any issues. I'm concerned that I'm not coming up with a proper test case that addresses your question. Do you have a specific example I can use, or start with, that would create this possibility?

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


More information about the cfe-commits mailing list