Skip to content

[clang] Distinguish NTTPs with deduced types in variable template partial specializations #152864

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion clang/lib/Sema/SemaTemplate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4126,7 +4126,11 @@ static bool isTemplateArgumentTemplateParameter(const TemplateArgument &Arg,
return false;
const NonTypeTemplateParmDecl *NTTP =
dyn_cast<NonTypeTemplateParmDecl>(DRE->getDecl());
return NTTP && NTTP->getDepth() == Depth && NTTP->getIndex() == Index;
if (!NTTP || NTTP->getDepth() != Depth || NTTP->getIndex() != Index)
return false;
QualType ParamType = cast<NonTypeTemplateParmDecl>(Param)->getType();
QualType NTTPType = NTTP->getType();
return ParamType.getCanonicalType() == NTTPType.getCanonicalType();
}

case TemplateArgument::Template:
Expand Down
5 changes: 5 additions & 0 deletions clang/test/SemaTemplate/temp_arg_nontype_cxx1z.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -621,3 +621,8 @@ namespace GH73460 {
int j;
template struct A<int&, j, j>;
} // namespace GH73460

namespace GH118190 {
template <auto> int x;
template <int i> int x<i>;
}
Loading