Skip to content

[clang] Use canonical type for substitution which might be incomplete #109065

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
merged 1 commit into from
Sep 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
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
7 changes: 5 additions & 2 deletions clang/lib/Sema/SemaTemplateDeduction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5505,8 +5505,11 @@ static TemplateDeductionResult CheckDeductionConsistency(
Sema::ArgumentPackSubstitutionIndexRAII PackIndex(
S, ArgIdx != -1 ? ::getPackIndexForParam(S, FTD, MLTAL, ArgIdx) : -1);
bool IsIncompleteSubstitution = false;
QualType InstP = S.SubstType(P, MLTAL, FTD->getLocation(), FTD->getDeclName(),
&IsIncompleteSubstitution);
// FIXME: A substitution can be incomplete on a non-structural part of the
// type. Use the canonical type for now, until the TemplateInstantiator can
// deal with that.
QualType InstP = S.SubstType(P.getCanonicalType(), MLTAL, FTD->getLocation(),
FTD->getDeclName(), &IsIncompleteSubstitution);
if (InstP.isNull() && !IsIncompleteSubstitution)
return TemplateDeductionResult::SubstitutionFailure;
if (!CheckConsistency)
Expand Down
9 changes: 9 additions & 0 deletions clang/test/SemaTemplate/GH18291.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -112,3 +112,12 @@ namespace static_vs_nonstatic {
}
} // namespace explicit_obj_param
} // namespace static_vs_nonstatic

namespace incomplete_on_sugar {
template <unsigned P, class T> void f(T[P]) = delete;
template <unsigned P> void f(int[][P]);
void test() {
int array[1][8];
f<8>(array);
}
} // namespace incomplete_on_sugar
Loading