llvmorg-github-actions[bot] wrote:
<!--LLVM PR SUMMARY COMMENT--> @llvm/pr-subscribers-clang Author: Matheus Izvekov (mizvekov) <details> <summary>Changes</summary> Recover from invalid member specializations as if it wasn't declared. This undoes the change introduced in #<!-- -->201506 for a more robust approach which keeps the AST valid. There are no release notes since this fixes a regression which was never released. Fixes #<!-- -->201490 Fixes #<!-- -->205971 --- Full diff: https://github.com/llvm/llvm-project/pull/207068.diff 2 Files Affected: - (modified) clang/lib/Sema/SemaTemplate.cpp (+2-2) - (modified) clang/test/SemaTemplate/member-specialization.cpp (+14-1) ``````````diff diff --git a/clang/lib/Sema/SemaTemplate.cpp b/clang/lib/Sema/SemaTemplate.cpp index 556fa716d61e7..110e0918e4570 100644 --- a/clang/lib/Sema/SemaTemplate.cpp +++ b/clang/lib/Sema/SemaTemplate.cpp @@ -2201,7 +2201,7 @@ DeclResult Sema::CheckClassTemplate( ? diag::err_friend_decl_does_not_match : diag::err_member_decl_does_not_match) << Name << SemanticContext << /*IsDefinition*/ true << SS.getRange(); - Invalid = true; + return true; } } @@ -2246,7 +2246,7 @@ DeclResult Sema::CheckClassTemplate( if (ModulePrivateLoc.isValid()) NewTemplate->setModulePrivate(); - if (!Invalid && IsMemberSpecialization) { + if (IsMemberSpecialization) { assert(PrevClassTemplate && "Member specialization without a primary template?"); NewTemplate->setMemberSpecialization(); diff --git a/clang/test/SemaTemplate/member-specialization.cpp b/clang/test/SemaTemplate/member-specialization.cpp index ea30a7a0cd749..894b8c4e4bd04 100644 --- a/clang/test/SemaTemplate/member-specialization.cpp +++ b/clang/test/SemaTemplate/member-specialization.cpp @@ -1,5 +1,4 @@ // RUN: %clang_cc1 -std=c++17 -verify %s -// expected-no-diagnostics template<typename T, typename U> struct X { template<typename V> const V &as() { return V::error; } @@ -9,3 +8,17 @@ template<typename T, typename U> struct X { int f(X<int, int> x) { return x.as<int>(); } + +namespace GH205971 { + template<class> struct A {}; + + template<> + template<class> + struct A<int>::B; + // expected-error@-1 {{out-of-line definition of 'B' does not match any declaration}} + + template<> + template<class> + struct A<int>::B; + // expected-error@-1 {{out-of-line definition of 'B' does not match any declaration}} +} // namespace GH205971 `````````` </details> https://github.com/llvm/llvm-project/pull/207068 _______________________________________________ cfe-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
