llvmorg-github-actions[bot] wrote:

<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-clang

Author: Tadeusz (tadeuszjt)

<details>
<summary>Changes</summary>

**Problem**
When an invalid 'gang dim' value is used in `CheckGangDimExpr`, the function 
prints the value into the diagnostic message by calling `getExtValue`. This 
function asserts on values that can't fit into a signed integer. 

**Solution**
`APSInt` has a `&lt;&lt;` operator anyway so just use that.

Fixes #<!-- -->221418

---
Full diff: https://github.com/llvm/llvm-project/pull/221502.diff


2 Files Affected:

- (modified) clang/lib/Sema/SemaOpenACCClause.cpp (+1-1) 
- (modified) clang/test/SemaOpenACC/routine-construct-clauses.cpp (+3) 


``````````diff
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..16f49299e9264 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@+1{{argument to 'gang' clause dimension must be 1, 2, or 3: 
evaluated to 18'446'744'073'709'551'574}}
+#pragma acc routine(Func) gang(dim:HasFuncs::HugeUnsigned())
 
 template<typename T>
 struct DependentT {

``````````

</details>


https://github.com/llvm/llvm-project/pull/221502
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to