llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT--> @llvm/pr-subscribers-clang Author: Oleksandr T. (a-tarasyuk) <details> <summary>Changes</summary> Fixes #<!-- -->173347 --- This patch resolves an assertion failure that occurs when instantiation-dependent expressions are constant-evaluated during vector conversions. --- Full diff: https://github.com/llvm/llvm-project/pull/173498.diff 3 Files Affected: - (modified) clang/docs/ReleaseNotes.rst (+1) - (modified) clang/lib/Sema/SemaExpr.cpp (+2-1) - (modified) clang/test/SemaCXX/vector.cpp (+5) ``````````diff diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst index 8e2e45b8ef385..a39c98dd146c6 100644 --- a/clang/docs/ReleaseNotes.rst +++ b/clang/docs/ReleaseNotes.rst @@ -614,6 +614,7 @@ Bug Fixes to C++ Support - Fix the result of ``__is_pointer_interconvertible_base_of`` when arguments are qualified and passed via template parameters. (#GH135273) - Fixed a crash when evaluating nested requirements in requires-expressions that reference invented parameters. (#GH166325) - Fixed a crash when standard comparison categories (e.g. ``std::partial_ordering``) are defined with incorrect static member types. (#GH170015) (#GH56571) +- Fixed an assertion failure in vector conversions involving instantiation-dependent template expressions. (#GH173347) Bug Fixes to AST Handling ^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/clang/lib/Sema/SemaExpr.cpp b/clang/lib/Sema/SemaExpr.cpp index 5a31b42541d99..69e5c8028f2ed 100644 --- a/clang/lib/Sema/SemaExpr.cpp +++ b/clang/lib/Sema/SemaExpr.cpp @@ -10276,7 +10276,8 @@ static ExprResult convertVector(Expr *E, QualType ElementType, Sema &S) { /// IntTy without losing precision. static bool canConvertIntToOtherIntTy(Sema &S, ExprResult *Int, QualType OtherIntTy) { - if (Int->get()->containsErrors()) + Expr *E = Int->get(); + if (E->containsErrors() || E->isInstantiationDependent()) return false; QualType IntTy = Int->get()->getType().getUnqualifiedType(); diff --git a/clang/test/SemaCXX/vector.cpp b/clang/test/SemaCXX/vector.cpp index 06195f039cd92..744017304d121 100644 --- a/clang/test/SemaCXX/vector.cpp +++ b/clang/test/SemaCXX/vector.cpp @@ -799,3 +799,8 @@ template <int N> using templated_v_size = int __attribute__((vector_size(N))); templated_v_size<-8> templated_v_neg_size; //expected-note{{in instantiation of template type alias 'templated_v_size' requested here}} #endif + +namespace GH173347 { +typedef short __attribute__((__vector_size__(8))) V; +template <int N> V test(V x) { return (x % 5) * N; } +} `````````` </details> https://github.com/llvm/llvm-project/pull/173498 _______________________________________________ cfe-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
