llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT--> @llvm/pr-subscribers-clang Author: Serosh (Serosh-commits) <details> <summary>Changes</summary> allow void (^)() block pointers to be used as non-type template parameters,especially with nullptr fixes #<!-- -->189247 --- Full diff: https://github.com/llvm/llvm-project/pull/190464.diff 3 Files Affected: - (modified) clang/docs/ReleaseNotes.rst (+1) - (modified) clang/lib/Sema/SemaTemplate.cpp (+5) - (added) clang/test/SemaCXX/gh189247.cpp (+4) ``````````diff diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst index 899a4ee0dee0e..a8baf62771ded 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 ^^^^^^^^^^^^^^^^^^^^^^^^ +- Fixed a crash when passing ``nullptr`` as a template argument for a non-type template parameter of block pointer type. (#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/SemaCXX/gh189247.cpp b/clang/test/SemaCXX/gh189247.cpp new file mode 100644 index 0000000000000..a35cfad1d0473 --- /dev/null +++ b/clang/test/SemaCXX/gh189247.cpp @@ -0,0 +1,4 @@ +// RUN: %clang_cc1 -fblocks -fsyntax-only -verify %s + +template<void (^)(void)> struct T; // expected-error{{a non-type template parameter cannot have type 'void (^)(void)'}} +T<nullptr> *t; `````````` </details> https://github.com/llvm/llvm-project/pull/190464 _______________________________________________ cfe-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
