Fznamznon created this revision. Herald added a project: All. Fznamznon requested review of this revision. Herald added a project: clang. Herald added a subscriber: cfe-commits.
Before checking that template partial specialization is "reachable", ensure it exists. Fixes https://github.com/llvm/llvm-project/issues/61356 Repository: rG LLVM Github Monorepo https://reviews.llvm.org/D148330 Files: clang/docs/ReleaseNotes.rst clang/lib/Sema/SemaCXXScopeSpec.cpp clang/test/SemaCXX/undefined-partial-specialization.cpp Index: clang/test/SemaCXX/undefined-partial-specialization.cpp =================================================================== --- /dev/null +++ clang/test/SemaCXX/undefined-partial-specialization.cpp @@ -0,0 +1,14 @@ +// RUN: %clang_cc1 -std=c++20 -verify %s + +namespace GH61356 { + +template <typename T, bool b> +class boo {void foo();}; + +template <typename T> +class boo<T, true>; + +template<typename T> +void boo<T, true>::foo(){} // expected-error{{nested name specifier 'boo<T, true>::' for declaration does not refer into a class, class template or class template partial specialization}} + +} Index: clang/lib/Sema/SemaCXXScopeSpec.cpp =================================================================== --- clang/lib/Sema/SemaCXXScopeSpec.cpp +++ clang/lib/Sema/SemaCXXScopeSpec.cpp @@ -125,7 +125,7 @@ PartialSpec = ClassTemplate->findPartialSpecialization(ContextType); } - if (PartialSpec) { + if (PartialSpec && PartialSpec->hasDefinition()) { // A declaration of the partial specialization must be visible. // We can always recover here, because this only happens when we're // entering the context, and that can't happen in a SFINAE context. Index: clang/docs/ReleaseNotes.rst =================================================================== --- clang/docs/ReleaseNotes.rst +++ clang/docs/ReleaseNotes.rst @@ -301,6 +301,8 @@ expressions/statements with invalid source locations in non-assert builds. Assert builds may still see assertions triggered from this. (`#62105 <https://github.com/llvm/llvm-project/issues/62105>`_) +- Fix crash when handling undefined template partial specialization + (`#61356 <https://github.com/llvm/llvm-project/issues/61356>`_) Bug Fixes to Compiler Builtins ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Index: clang/test/SemaCXX/undefined-partial-specialization.cpp =================================================================== --- /dev/null +++ clang/test/SemaCXX/undefined-partial-specialization.cpp @@ -0,0 +1,14 @@ +// RUN: %clang_cc1 -std=c++20 -verify %s + +namespace GH61356 { + +template <typename T, bool b> +class boo {void foo();}; + +template <typename T> +class boo<T, true>; + +template<typename T> +void boo<T, true>::foo(){} // expected-error{{nested name specifier 'boo<T, true>::' for declaration does not refer into a class, class template or class template partial specialization}} + +} Index: clang/lib/Sema/SemaCXXScopeSpec.cpp =================================================================== --- clang/lib/Sema/SemaCXXScopeSpec.cpp +++ clang/lib/Sema/SemaCXXScopeSpec.cpp @@ -125,7 +125,7 @@ PartialSpec = ClassTemplate->findPartialSpecialization(ContextType); } - if (PartialSpec) { + if (PartialSpec && PartialSpec->hasDefinition()) { // A declaration of the partial specialization must be visible. // We can always recover here, because this only happens when we're // entering the context, and that can't happen in a SFINAE context. Index: clang/docs/ReleaseNotes.rst =================================================================== --- clang/docs/ReleaseNotes.rst +++ clang/docs/ReleaseNotes.rst @@ -301,6 +301,8 @@ expressions/statements with invalid source locations in non-assert builds. Assert builds may still see assertions triggered from this. (`#62105 <https://github.com/llvm/llvm-project/issues/62105>`_) +- Fix crash when handling undefined template partial specialization + (`#61356 <https://github.com/llvm/llvm-project/issues/61356>`_) Bug Fixes to Compiler Builtins ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits