https://github.com/Serosh-commits updated 
https://github.com/llvm/llvm-project/pull/190464

>From 3340a220e2309268568c2e2e43da37337fb607fc Mon Sep 17 00:00:00 2001
From: Serosh-commits <[email protected]>
Date: Thu, 11 Dec 2025 14:39:00 +0100
Subject: [PATCH 1/2] Fix block pointer NTTP crash

---
 clang/docs/ReleaseNotes.rst                        | 1 +
 clang/lib/Sema/SemaTemplate.cpp                    | 5 +++++
 clang/test/SemaTemplate/temp_class_spec_blocks.cpp | 7 ++++++-
 3 files changed, 12 insertions(+), 1 deletion(-)

diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 899a4ee0dee0e..0706d30ed75b2 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -549,6 +549,7 @@ Bug Fixes to Attribute Support
 
 Bug Fixes to C++ Support
 ^^^^^^^^^^^^^^^^^^^^^^^^
+- Clang now correctly diagnoses block pointer types as invalid for non-type 
template parameters. (#GH189247)
 - Diagnose binding a reference to ``*nullptr`` during constant evaluation. 
(#GH48665)
 - Suppress ``-Wdeprecated-declarations`` in implicitly generated functions. 
(#GH147293)
 - Fix a crash when deleting a pointer to an incomplete array (#GH150359).
diff --git a/clang/lib/Sema/SemaTemplate.cpp b/clang/lib/Sema/SemaTemplate.cpp
index 3497ff7856eed..6f6a354bc3992 100644
--- a/clang/lib/Sema/SemaTemplate.cpp
+++ b/clang/lib/Sema/SemaTemplate.cpp
@@ -1457,6 +1457,11 @@ QualType 
Sema::CheckNonTypeTemplateParameterType(QualType T,
     return QualType();
   }
 
+  if (T->isBlockPointerType()) {
+    Diag(Loc, diag::err_template_nontype_parm_bad_type) << T;
+    return QualType();
+  }
+
   // C++ [temp.param]p4:
   //
   // A non-type template-parameter shall have one of the following
diff --git a/clang/test/SemaTemplate/temp_class_spec_blocks.cpp 
b/clang/test/SemaTemplate/temp_class_spec_blocks.cpp
index 4b99716d582e4..ef511278bf337 100644
--- a/clang/test/SemaTemplate/temp_class_spec_blocks.cpp
+++ b/clang/test/SemaTemplate/temp_class_spec_blocks.cpp
@@ -1,5 +1,5 @@
 // RUN: %clang_cc1 -fsyntax-only -verify %s -fblocks
-// expected-no-diagnostics
+
 template<typename T>
 struct is_unary_block {
   static const bool value = false;
@@ -33,3 +33,8 @@ int 
is_unary_block8[is_unary_block_with_same_return_type_as_argument_type<int (^
 int is_unary_block9[is_unary_block_with_same_return_type_as_argument_type<int 
(^)(int)>::value ? 1 : -1];
 int is_unary_block10[is_unary_block_with_same_return_type_as_argument_type<int 
(^)(int, ...)>::value ? -1 : 1];
 int is_unary_block11[is_unary_block_with_same_return_type_as_argument_type<int 
(^ const)(int)>::value ? -1 : 1];
+
+namespace gh189247 {
+  template<void (^)(void)> struct A; // expected-error {{non-type template 
parameter cannot have block pointer type 'void (^)(void)'}}
+}
+

>From e32ed88873785f92860147ed3189051c0b0eef82 Mon Sep 17 00:00:00 2001
From: Serosh-commits <[email protected]>
Date: Sun, 5 Apr 2026 03:06:47 +0530
Subject: [PATCH 2/2] add a

---
 clang/docs/ReleaseNotes.rst                        | 2 +-
 clang/test/SemaCXX/blocks.cpp                      | 5 +++++
 clang/test/SemaTemplate/temp_class_spec_blocks.cpp | 5 +----
 3 files changed, 7 insertions(+), 5 deletions(-)

diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 0706d30ed75b2..16e0a3e306e34 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -549,7 +549,7 @@ Bug Fixes to Attribute Support
 
 Bug Fixes to C++ Support
 ^^^^^^^^^^^^^^^^^^^^^^^^
-- Clang now correctly diagnoses block pointer types as invalid for non-type 
template parameters. (#GH189247)
+- Clang now rejects constant template parameters with block pointer types, 
since these are not implemented anyway and would lead to crashes. (#GH189247)
 - Diagnose binding a reference to ``*nullptr`` during constant evaluation. 
(#GH48665)
 - Suppress ``-Wdeprecated-declarations`` in implicitly generated functions. 
(#GH147293)
 - Fix a crash when deleting a pointer to an incomplete array (#GH150359).
diff --git a/clang/test/SemaCXX/blocks.cpp b/clang/test/SemaCXX/blocks.cpp
index 997ac2b5721df..9c23a3a779ef5 100644
--- a/clang/test/SemaCXX/blocks.cpp
+++ b/clang/test/SemaCXX/blocks.cpp
@@ -163,3 +163,8 @@ void static_data_member() {
     };
   };
 }
+
+namespace gh189247 {
+  template<void (^)(void)> struct A; // expected-error {{a non-type template 
parameter cannot have type 'void (^)(void)'}}
+  A<nullptr> *a;
+}
diff --git a/clang/test/SemaTemplate/temp_class_spec_blocks.cpp 
b/clang/test/SemaTemplate/temp_class_spec_blocks.cpp
index ef511278bf337..c037dcec11975 100644
--- a/clang/test/SemaTemplate/temp_class_spec_blocks.cpp
+++ b/clang/test/SemaTemplate/temp_class_spec_blocks.cpp
@@ -1,4 +1,5 @@
 // RUN: %clang_cc1 -fsyntax-only -verify %s -fblocks
+// expected-no-diagnostics
 
 template<typename T>
 struct is_unary_block {
@@ -34,7 +35,3 @@ int 
is_unary_block9[is_unary_block_with_same_return_type_as_argument_type<int (^
 int is_unary_block10[is_unary_block_with_same_return_type_as_argument_type<int 
(^)(int, ...)>::value ? -1 : 1];
 int is_unary_block11[is_unary_block_with_same_return_type_as_argument_type<int 
(^ const)(int)>::value ? -1 : 1];
 
-namespace gh189247 {
-  template<void (^)(void)> struct A; // expected-error {{non-type template 
parameter cannot have block pointer type 'void (^)(void)'}}
-}
-

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

Reply via email to