[clang] d4f5cf2 - [Clang] Added check for unexpanded pack in attribute [[assume]] (#91893)
via cfe-commits
cfe-commits at lists.llvm.org
Mon May 13 01:31:14 PDT 2024
Author: Azmat Yusuf
Date: 2024-05-13T10:31:10+02:00
New Revision: d4f5cf267936a082196b0c22fe45c730b24b9fe0
URL: https://github.com/llvm/llvm-project/commit/d4f5cf267936a082196b0c22fe45c730b24b9fe0
DIFF: https://github.com/llvm/llvm-project/commit/d4f5cf267936a082196b0c22fe45c730b24b9fe0.diff
LOG: [Clang] Added check for unexpanded pack in attribute [[assume]] (#91893)
Added a check for unexpanded parameter pack in attribute [[assume]].
Tested it with expected-error statements from clang fronted.
This fixes #91232.
Added:
Modified:
clang/lib/Sema/SemaStmtAttr.cpp
clang/test/SemaCXX/cxx23-assume.cpp
Removed:
################################################################################
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}}
+}
More information about the cfe-commits
mailing list