https://github.com/Serosh-commits updated https://github.com/llvm/llvm-project/pull/190377
>From 631a59b792dee9c83736fd3d8d8ee013be34dabc Mon Sep 17 00:00:00 2001 From: Serosh-commits <[email protected]> Date: Thu, 11 Dec 2025 14:39:00 +0100 Subject: [PATCH] Fix block pointer NTTP crash --- clang/lib/Sema/SemaTemplate.cpp | 4 +++- clang/test/SemaCXX/gh189247.cpp | 5 +++++ llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp | 3 ++- 3 files changed, 10 insertions(+), 2 deletions(-) create mode 100644 clang/test/SemaCXX/gh189247.cpp diff --git a/clang/lib/Sema/SemaTemplate.cpp b/clang/lib/Sema/SemaTemplate.cpp index 3497ff7856eed..28648315df201 100644 --- a/clang/lib/Sema/SemaTemplate.cpp +++ b/clang/lib/Sema/SemaTemplate.cpp @@ -1470,6 +1470,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. @@ -7342,7 +7344,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; diff --git a/llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp b/llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp index 6c7bedaf2c933..a56b165bc1a5e 100644 --- a/llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp +++ b/llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp @@ -2503,7 +2503,8 @@ void VPVectorEndPointerRecipe::execute(VPTransformState &State) { // LastLane = Stride * (RunTimeVF - 1) Value *LastLane = Builder.CreateSub(RunTimeVF, ConstantInt::get(IndexTy, 1)); if (Stride != 1) - LastLane = Builder.CreateMul(ConstantInt::get(IndexTy, Stride), LastLane); + LastLane = + Builder.CreateMul(ConstantInt::getSigned(IndexTy, Stride), LastLane); Value *Ptr = State.get(getOperand(0), VPLane(0)); Value *ResultPtr = Builder.CreateGEP(IndexedTy, Ptr, NumElt, "", getGEPNoWrapFlags()); _______________________________________________ cfe-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
