Skip to content
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
13 changes: 10 additions & 3 deletions clang/include/clang/Basic/DiagnosticSemaKinds.td
Original file line number Diff line number Diff line change
Expand Up @@ -8444,9 +8444,16 @@ let CategoryName = "Lambda Issue" in {
"C++ standards before C++20">, InGroup<CXXPre20Compat>, DefaultIgnore;

// C++20 class template argument deduction for alias templates.
def warn_cxx17_compat_ctad_for_alias_templates : Warning<
"class template argument deduction for alias templates is incompatible with "
"C++ standards before C++20">, InGroup<CXXPre20Compat>, DefaultIgnore;
def warn_cxx17_compat_ctad_for_alias_templates
: Warning<"class template argument deduction for alias templates is "
"incompatible with "
"C++ standards before C++20">,
InGroup<CXXPre20Compat>,
DefaultIgnore;
def ext_ctad_for_alias_templates_cxx20
: ExtWarn<"class template argument deduction for alias templates is a "
"C++20 extension">,
InGroup<CXX20>;
}

def err_return_in_captured_stmt : Error<
Expand Down
4 changes: 3 additions & 1 deletion clang/lib/Sema/SemaInit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9896,7 +9896,9 @@ QualType Sema::DeduceTemplateSpecializationFromInitializer(
if (auto *AliasTemplate = dyn_cast_or_null<TypeAliasTemplateDecl>(
TemplateName.getAsTemplateDecl())) {
Diag(Kind.getLocation(),
diag::warn_cxx17_compat_ctad_for_alias_templates);
getLangOpts().CPlusPlus20
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Sirraide : Didn't we have a function you were making to get the right diagnostic here? Should/could we use that here?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes we can use DiagCompat() here once #132348 is merged (which should happen in a few hours barring unforeseen circumstances). I’ll leave another comment once that has happened.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! I'd vastly prefer we hold off on this patch until that is merged and rebase it with that. I hadn't realized that 132348 hadn't been merged yet.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It has been merged since (I had to revert it once but I’ve already relanded it)

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah :) I was just blaming my bad memory. I just got back from a week off, so my brain isn't particularly caught up yet :D

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah :) I was just blaming my bad memory. I just got back from a week off, so my brain isn't particularly caught up yet :D

I merged it a few hours ago so you’re good ;Þ

? diag::warn_cxx17_compat_ctad_for_alias_templates
: diag::ext_ctad_for_alias_templates_cxx20);
LookupTemplateDecl = AliasTemplate;
auto UnderlyingType = AliasTemplate->getTemplatedDecl()
->getUnderlyingType()
Expand Down
2 changes: 1 addition & 1 deletion clang/test/SemaCXX/cxx17-compat.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ template<typename T> struct A { A(T); };
template<typename T> using B = A<T>;
B b = {1};
#if __cplusplus <= 201703L
// FIXME: diagnose as well
// expected-warning@-2 {{class template argument deduction for alias templates is a C++20 extension}}
#else
// expected-warning@-4 {{class template argument deduction for alias templates is incompatible with C++ standards before C++20}}
#endif
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,9 +113,9 @@ namespace dependent {
};
template<typename T> void f() {
typename T::X tx = 0;
typename T::Y ty = 0;
typename T::Y ty = 0; // expected-warning {{class template argument deduction for alias templates is a C++20 extension}}
}
template void f<B>();
template void f<B>(); // expected-note {{in instantiation of function template specialization 'dependent::f<dependent::B>' requested here}}

template<typename T> struct C { C(T); };
template<typename T> C(T) -> C<T>;
Expand Down
Loading