[clang] diagnose block pointer types as invalid for constant template parameters (#190464)

Fixes a crash by making it ill-formed to have a constant template
parameter with a block pointer type.

Fixes #189247
This commit is contained in:
Serosh 2026-04-05 06:54:19 +05:30 committed by GitHub
parent 7fd02b32f9
commit 17ed1e6c4b
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 10 additions and 0 deletions

View File

@ -412,6 +412,7 @@ Bug Fixes to Attribute Support
Bug Fixes to C++ Support
^^^^^^^^^^^^^^^^^^^^^^^^
- Clang now rejects constant template parameters with block pointer types, since these are not implemented anyway and would lead to crashes. (#GH189247)
- Fixed a crash on error recovery when dealing with invalid templates. (#GH183075)
- Fixed a crash when instantiating ``requires`` expressions involving substitution failures in C++ concepts. (#GH176402)
- Fixed an incorrect template argument deduction when matching packs of template

View File

@ -1459,6 +1459,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

View File

@ -163,3 +163,7 @@ void static_data_member() {
};
};
}
namespace gh189247 {
template<void (^)()> struct A; // expected-error {{a non-type template parameter cannot have type 'void (^)()'}}
}