[clang] [Clang] Added check for unexpanded pack in attribute [[assume]] (PR #91893)
via cfe-commits
cfe-commits at lists.llvm.org
Sun May 12 11:11:19 PDT 2024
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-clang
Author: Azmat Yusuf (azmat-y)
<details>
<summary>Changes</summary>
Added a check for unexpanded parameter pack in attribute [[assume]]. Tested it with expected-error statements from clang fronted. This fixes #<!-- -->91232. @<!-- -->Sirraide
---
Full diff: https://github.com/llvm/llvm-project/pull/91893.diff
2 Files Affected:
- (modified) clang/lib/Sema/SemaStmtAttr.cpp (+5)
- (modified) clang/test/SemaCXX/cxx23-assume.cpp (+5)
``````````diff
diff --git a/clang/lib/Sema/SemaStmtAttr.cpp b/clang/lib/Sema/SemaStmtAttr.cpp
index 1c84830b6ddd2..36f8ecadcfab7 100644
--- a/clang/lib/Sema/SemaStmtAttr.cpp
+++ b/clang/lib/Sema/SemaStmtAttr.cpp
@@ -670,6 +670,11 @@ ExprResult Sema::ActOnCXXAssumeAttr(Stmt *St, const ParsedAttr &A,
}
auto *Assumption = A.getArgAsExpr(0);
+
+ if (DiagnoseUnexpandedParameterPack(Assumption)) {
+ return ExprError();
+ }
+
if (Assumption->getDependence() == ExprDependence::None) {
ExprResult Res = BuildCXXAssumeExpr(Assumption, A.getAttrName(), Range);
if (Res.isInvalid())
diff --git a/clang/test/SemaCXX/cxx23-assume.cpp b/clang/test/SemaCXX/cxx23-assume.cpp
index 8676970de14f6..e67d72ae0a995 100644
--- a/clang/test/SemaCXX/cxx23-assume.cpp
+++ b/clang/test/SemaCXX/cxx23-assume.cpp
@@ -138,3 +138,8 @@ constexpr int foo() {
}
static_assert(foo() == 0);
+
+template <bool ...val>
+void f() {
+ [[assume(val)]]; // expected-error {{expression contains unexpanded parameter pack}}
+}
``````````
</details>
https://github.com/llvm/llvm-project/pull/91893
More information about the cfe-commits
mailing list