diff options
author | Krystian Stasiowski <sdkrystian@gmail.com> | 2024-08-06 11:33:50 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-08-06 11:33:50 -0400 |
commit | b9183d0d0e24d164d3b57bf81ae911a22094e897 (patch) | |
tree | fa25a17a2ac29afd1b719ad8e51812240192f30e /clang/lib/Sema/SemaDecl.cpp | |
parent | 6250313291c9541abe74142be86a9bb7c0d30974 (diff) | |
download | llvm-b9183d0d0e24d164d3b57bf81ae911a22094e897.zip llvm-b9183d0d0e24d164d3b57bf81ae911a22094e897.tar.gz llvm-b9183d0d0e24d164d3b57bf81ae911a22094e897.tar.bz2 |
[Clang][Sema] Ensure that the selected candidate for a member function explicit specialization is more constrained than all others (#101721)
The selection of the most constrained candidate for member function
explicit specializations introduced in #88963 does not check whether the
selected candidate is more constrained than all other candidates, which
can result in ambiguities being undiagnosed. This patch addresses the
issue.
Diffstat (limited to 'clang/lib/Sema/SemaDecl.cpp')
-rw-r--r-- | clang/lib/Sema/SemaDecl.cpp | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/clang/lib/Sema/SemaDecl.cpp b/clang/lib/Sema/SemaDecl.cpp index 1f4bfa2..bab32b9 100644 --- a/clang/lib/Sema/SemaDecl.cpp +++ b/clang/lib/Sema/SemaDecl.cpp @@ -7964,8 +7964,9 @@ NamedDecl *Sema::ActOnVariableDeclarator( D.setRedeclaration(CheckVariableDeclaration(NewVD, Previous)); } else { // If this is an explicit specialization of a static data member, check it. - if (IsMemberSpecialization && !IsVariableTemplateSpecialization && - !NewVD->isInvalidDecl() && CheckMemberSpecialization(NewVD, Previous)) + if (IsMemberSpecialization && !IsVariableTemplate && + !IsVariableTemplateSpecialization && !NewVD->isInvalidDecl() && + CheckMemberSpecialization(NewVD, Previous)) NewVD->setInvalidDecl(); // Merge the decl with the existing one if appropriate. @@ -10466,7 +10467,7 @@ Sema::ActOnFunctionDeclarator(Scope *S, Declarator &D, DeclContext *DC, Previous)) NewFD->setInvalidDecl(); } - } else if (isMemberSpecialization && isa<CXXMethodDecl>(NewFD)) { + } else if (isMemberSpecialization && !FunctionTemplate) { if (CheckMemberSpecialization(NewFD, Previous)) NewFD->setInvalidDecl(); } |