[clang] [clang][SemaOpenACC] Avoid assertion on VLA reduction operand (PR #199178)

Erich Keane via cfe-commits cfe-commits at lists.llvm.org
Tue May 26 06:19:17 PDT 2026


================
@@ -648,9 +648,15 @@ ExprResult CheckVarType(SemaOpenACC &S, OpenACCClauseKind CK, Expr *VarExpr,
     InnerTy = RefTy->getPointeeType();
 
   if (auto *ArrTy = InnerTy->getAsArrayTypeUnsafe()) {
-    // Non constant arrays decay to 'pointer', so warn and return that we're
-    // successful.
     if (!ArrTy->isConstantArrayType()) {
+      // Variable length arrays cannot be used in a reduction clause.
+      // To fix llvm/llvm-project#199162
+      if (CK == OpenACCClauseKind::Reduction) {
+        S.Diag(InnerLoc, clang::diag::err_acc_reduction_non_const_array);
----------------
erichkeane wrote:

See the other places we do this, we should probably also emit the reduction 'note'.

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


More information about the cfe-commits mailing list