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/190377.diff 3 Files Affected: - (modified) clang/docs/ReleaseNotes.rst (+2) - (modified) clang/lib/Sema/SemaTemplate.cpp (+3-1) - (added) clang/test/SemaCXX/gh189247.cpp (+5) ``````````diff diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst index 442ec58adc25a..1f405982ca0fe 100644 --- a/clang/docs/ReleaseNotes.rst +++ b/clang/docs/ReleaseNotes.rst @@ -427,6 +427,8 @@ Bug Fixes to C++ Support - Fixed a crash when an immediate-invoked ``consteval`` lambda is used as an invalid initializer. (#GH185270) - Fixed an assertion failure when using a global destructor with a target with a non-default program address space. (#GH186484) +- Fixed a crash when passing ``nullptr`` as a template argument for a non-type template parameter of block pointer type. (#GH189247) + - Inherited constructors in ``dllexport`` classes are now exported for ABI-compatible cases, matching MSVC behavior. Constructors with variadic arguments or callee-cleanup parameters are not yet supported and produce a warning. (#GH162640) diff --git a/clang/lib/Sema/SemaTemplate.cpp b/clang/lib/Sema/SemaTemplate.cpp index aa72cb8fa2895..d03ca7ae7b071 100644 --- a/clang/lib/Sema/SemaTemplate.cpp +++ b/clang/lib/Sema/SemaTemplate.cpp @@ -1472,6 +1472,8 @@ QualType Sema::CheckNonTypeTemplateParameterType(QualType T, T->isLValueReferenceType() || // -- pointer to member, T->isMemberPointerType() || + // -- block pointer, + T->isBlockPointerType() || // -- std::nullptr_t, or T->isNullPtrType() || // -- a type that contains a placeholder type. @@ -7355,7 +7357,7 @@ ExprResult Sema::CheckTemplateArgument(NamedDecl *Param, QualType ParamType, // For a non-type template-parameter of pointer or reference type, // the value of the constant expression shall not refer to assert(ParamType->isPointerOrReferenceType() || - ParamType->isNullPtrType()); + ParamType->isNullPtrType() || ParamType->isBlockPointerType()); // -- a temporary object // -- a string literal // -- the result of a typeid expression, or diff --git a/clang/test/SemaCXX/gh189247.cpp b/clang/test/SemaCXX/gh189247.cpp new file mode 100644 index 0000000000000..79f7b312aee83 --- /dev/null +++ b/clang/test/SemaCXX/gh189247.cpp @@ -0,0 +1,5 @@ +// RUN: %clang_cc1 -fblocks -fsyntax-only -verify %s +// expected-no-diagnostics + +template<void (^)(void)> struct T; +T<nullptr> *t; `````````` </details> https://github.com/llvm/llvm-project/pull/190377 _______________________________________________ cfe-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
