Skip to content

[clang] fix getTrivialTemplateArgumentLoc template template argument #153344

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
Aug 13, 2025
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
6 changes: 1 addition & 5 deletions clang/lib/Sema/SemaTemplateDeduction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2911,11 +2911,7 @@ Sema::getTrivialTemplateArgumentLoc(const TemplateArgument &Arg,
case TemplateArgument::TemplateExpansion: {
NestedNameSpecifierLocBuilder Builder;
TemplateName Template = Arg.getAsTemplateOrTemplatePattern();
if (DependentTemplateName *DTN = Template.getAsDependentTemplateName())
Builder.MakeTrivial(Context, DTN->getQualifier(), Loc);
else if (QualifiedTemplateName *QTN =
Template.getAsQualifiedTemplateName())
Builder.MakeTrivial(Context, QTN->getQualifier(), Loc);
Builder.MakeTrivial(Context, Template.getQualifier(), Loc);
return TemplateArgumentLoc(
Context, Arg, Loc, Builder.getWithLocInContext(Context), Loc,
/*EllipsisLoc=*/Arg.getKind() == TemplateArgument::TemplateExpansion
Expand Down
14 changes: 14 additions & 0 deletions clang/test/SemaTemplate/ctad.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -90,3 +90,17 @@ namespace AsValueParameter {
// cxx17-error@-1 {{value of type 'foo::A<int>' is not implicitly convertible to 'int'}}
// cxx20-error@-2 {{non-type template parameter has non-literal type 'foo::A<int>' (aka 'AsValueParameter::foo::A<int>')}}
} // namespace AsValueParameter

namespace ConvertDeducedTemplateArgument {
namespace A {
template <class> struct B {};
}

template <template <class> class TT1> struct C {
C(TT1<int>);
};

template <template <class> class TT2> using D = TT2<int>;

auto x = C(D<A::B>());
}