Skip to content

Commit 83d3a7c

Browse files
committed
merge main into amd-staging
2 parents a7976c0 + 73feab5 commit 83d3a7c

File tree

2 files changed

+31
-10
lines changed

2 files changed

+31
-10
lines changed

clang/lib/Sema/SemaTemplateDeduction.cpp

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2925,16 +2925,7 @@ Sema::getTrivialTemplateArgumentLoc(const TemplateArgument &Arg,
29252925
case TemplateArgument::TemplateExpansion: {
29262926
NestedNameSpecifierLocBuilder Builder;
29272927
TemplateName Template = Arg.getAsTemplateOrTemplatePattern();
2928-
if (DependentTemplateName *DTN = Template.getAsDependentTemplateName())
2929-
Builder.MakeTrivial(Context, DTN->getQualifier(), Loc);
2930-
else if (QualifiedTemplateName *QTN =
2931-
Template.getAsQualifiedTemplateName())
2932-
Builder.MakeTrivial(Context, QTN->getQualifier(), Loc);
2933-
2934-
if (Arg.getKind() == TemplateArgument::Template)
2935-
return TemplateArgumentLoc(Context, Arg,
2936-
Builder.getWithLocInContext(Context), Loc);
2937-
2928+
Builder.MakeTrivial(Context, Template.getQualifier(), Loc);
29382929
return TemplateArgumentLoc(
29392930
Context, Arg, Builder.getWithLocInContext(Context), Loc, Loc);
29402931
}

clang/test/SemaTemplate/ctad.cpp

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,3 +73,33 @@ class D : C { // expected-note {{candidate function template not viable: require
7373
};
7474
D abc; // expected-error {{no viable constructor or deduction guide}}
7575
}
76+
77+
namespace AsValueParameter {
78+
namespace foo {
79+
// cxx17-note@+2 {{template is declared here}}
80+
// cxx20-note@+1 {{'A<int>' is not literal because it is not an aggregate and has no constexpr constructors other than copy or move constructors}}
81+
template <class> struct A {
82+
A();
83+
};
84+
}
85+
template <foo::A> struct B {}; // expected-note {{template parameter is declared here}}
86+
// cxx17-error@-1 {{use of class template 'foo::A' requires template arguments; argument deduction not allowed in template parameter}}
87+
88+
template struct B<foo::A<int>{}>;
89+
// cxx17-error@-1 {{value of type 'foo::A<int>' is not implicitly convertible to 'int'}}
90+
// cxx20-error@-2 {{non-type template parameter has non-literal type 'foo::A<int>' (aka 'AsValueParameter::foo::A<int>')}}
91+
} // namespace AsValueParameter
92+
93+
namespace ConvertDeducedTemplateArgument {
94+
namespace A {
95+
template <class> struct B {};
96+
}
97+
98+
template <template <class> class TT1> struct C {
99+
C(TT1<int>);
100+
};
101+
102+
template <template <class> class TT2> using D = TT2<int>;
103+
104+
auto x = C(D<A::B>());
105+
}

0 commit comments

Comments
 (0)