https://github.com/nataliakokoromyti updated 
https://github.com/llvm/llvm-project/pull/173866

>From 2f4aaf3c0082cb40a72750e1779492b5f07afdea Mon Sep 17 00:00:00 2001
From: Natalia Kokoromyti <[email protected]>
Date: Mon, 29 Dec 2025 04:26:15 -0800
Subject: [PATCH 1/3] add test for issue #173820

---
 clang/test/Sema/sentinel-attribute-block.c | 6 ++++++
 1 file changed, 6 insertions(+)
 create mode 100644 clang/test/Sema/sentinel-attribute-block.c

diff --git a/clang/test/Sema/sentinel-attribute-block.c 
b/clang/test/Sema/sentinel-attribute-block.c
new file mode 100644
index 0000000000000..65d3870f60e97
--- /dev/null
+++ b/clang/test/Sema/sentinel-attribute-block.c
@@ -0,0 +1,6 @@
+  // RUN: %clang_cc1 -fsyntax-only -fblocks -verify %s
+
+  // Test that sentinel attribute on block variables doesn't crash
+  void foo(void) {
+    void (^a)() __attribute__((__sentinel__)) = {}; // expected-warning 
{{'sentinel' attribute requires named arguments}}
+  }

>From 15ef1282c823d260bc5a3e46eeda31656ecdf7a7 Mon Sep 17 00:00:00 2001
From: Natalia Kokoromyti <[email protected]>
Date: Mon, 29 Dec 2025 04:40:03 -0800
Subject: [PATCH 2/3] fix issue #173820

---
 clang/lib/Sema/SemaDeclAttr.cpp | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/clang/lib/Sema/SemaDeclAttr.cpp b/clang/lib/Sema/SemaDeclAttr.cpp
index 263ce2118ba86..774d8f56443dc 100644
--- a/clang/lib/Sema/SemaDeclAttr.cpp
+++ b/clang/lib/Sema/SemaDeclAttr.cpp
@@ -2979,6 +2979,10 @@ static void handleSentinelAttr(Sema &S, Decl *D, const 
ParsedAttr &AL) {
                                    : Ty->castAs<BlockPointerType>()
                                          ->getPointeeType()
                                          ->castAs<FunctionType>();
+      if (isa<FunctionNoProtoType>(FT)) {
+        S.Diag(AL.getLoc(), diag::warn_attribute_sentinel_named_arguments);
+        return;
+      }
       if (!cast<FunctionProtoType>(FT)->isVariadic()) {
         int m = Ty->isFunctionPointerType() ? 0 : 1;
         S.Diag(AL.getLoc(), diag::warn_attribute_sentinel_not_variadic) << m;

>From 5cb04ae32c3f67f96e1f451604386b262bde723d Mon Sep 17 00:00:00 2001
From: Natalia Kokoromyti <[email protected]>
Date: Fri, 2 Jan 2026 06:07:42 -0800
Subject: [PATCH 3/3] add release note for #173820

---
 clang/docs/ReleaseNotes.rst | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 2319ff13f7864..36135b68ab7f9 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -640,6 +640,8 @@ Miscellaneous Bug Fixes
 Miscellaneous Clang Crashes Fixed
 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
 
+- Fixed a crash when applying the ``sentinel`` attribute to block variables. 
(#GH173820)
+
 OpenACC Specific Changes
 ------------------------
 

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

Reply via email to