https://github.com/tadeuszjt updated https://github.com/llvm/llvm-project/pull/221502
>From 1bde0ea33e11f881c383d742d925ee13224ea412 Mon Sep 17 00:00:00 2001 From: Tadeusz Tomoszek <[email protected]> Date: Sun, 6 Sep 2026 01:13:38 +0200 Subject: [PATCH] [Clang][OpenACC] Fixed getExtValue Call on Invalid Gang Dim --- clang/docs/ReleaseNotes.md | 3 +++ clang/lib/Sema/SemaOpenACCClause.cpp | 2 +- clang/test/SemaOpenACC/routine-construct-clauses.cpp | 3 +++ 3 files changed, 7 insertions(+), 1 deletion(-) diff --git a/clang/docs/ReleaseNotes.md b/clang/docs/ReleaseNotes.md index edf74404c4925..480256f737e95 100644 --- a/clang/docs/ReleaseNotes.md +++ b/clang/docs/ReleaseNotes.md @@ -662,6 +662,9 @@ features cannot lower the translation-unit ABI level; declaration. (#GH217489) - Fixed an assertion failure when instantiating a block that captures `this` via a member access through a dependent base class. +- Fixed a crash when the `dim` argument to an OpenACC `gang` clause evaluated + to a value not representable by a signed integer, such as an unsigned + wrap around. (#GH221418) ### OpenACC Specific Changes diff --git a/clang/lib/Sema/SemaOpenACCClause.cpp b/clang/lib/Sema/SemaOpenACCClause.cpp index 0409e2456895d..b4686afb9b1dc 100644 --- a/clang/lib/Sema/SemaOpenACCClause.cpp +++ b/clang/lib/Sema/SemaOpenACCClause.cpp @@ -1159,7 +1159,7 @@ ExprResult CheckGangDimExpr(SemaOpenACC &S, Expr *E) { if (!ICE || *ICE <= 0 || ICE > 3) { S.Diag(Res.get()->getBeginLoc(), diag::err_acc_gang_dim_value) - << ICE.has_value() << ICE.value_or(llvm::APSInt{}).getExtValue(); + << ICE.has_value() << ICE.value_or(llvm::APSInt::get(0)); return ExprError(); } diff --git a/clang/test/SemaOpenACC/routine-construct-clauses.cpp b/clang/test/SemaOpenACC/routine-construct-clauses.cpp index 4c7152861afc1..254669bf37328 100644 --- a/clang/test/SemaOpenACC/routine-construct-clauses.cpp +++ b/clang/test/SemaOpenACC/routine-construct-clauses.cpp @@ -103,6 +103,7 @@ static constexpr int One() { return 1; } static constexpr int Two() { return 2; } static constexpr int Three() { return 3; } static constexpr int Four() { return 4; } +static constexpr unsigned long HugeUnsigned() { return -42; } }; // 'dim' must be 1, 2, or 3. // expected-error@+1{{argument to 'gang' clause dimension must be 1, 2, or 3: evaluated to -5}} @@ -114,6 +115,8 @@ static constexpr int Four() { return 4; } #pragma acc routine(Func) gang(dim:HasFuncs::Three()) // expected-error@+1{{argument to 'gang' clause dimension must be 1, 2, or 3: evaluated to 4}} #pragma acc routine(Func) gang(dim:HasFuncs::Four()) +// expected-error-re@+1{{argument to 'gang' clause dimension must be 1, 2, or 3: evaluated to {{.*}}}} +#pragma acc routine(Func) gang(dim:HasFuncs::HugeUnsigned()) template<typename T> struct DependentT { _______________________________________________ cfe-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
