Skip to content
Closed
4 changes: 4 additions & 0 deletions clang/docs/ReleaseNotes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -623,6 +623,10 @@ Bug Fixes to C++ Support
- Fix the result of ``__is_pointer_interconvertible_base_of`` when arguments are qualified and passed via template parameters. (#GH135273)
- Fixed a crash when evaluating nested requirements in requires-expressions that reference invented parameters. (#GH166325)
- Fixed a crash when standard comparison categories (e.g. ``std::partial_ordering``) are defined with incorrect static member types. (#GH170015) (#GH56571)
- Fixed a crash where Clang would attempt to generate code for a static data
member declared with an alias template without template arguments.
Clang now correctly diagnoses this as an undeduced type and rejects
the declaration. (#GH173349)

Bug Fixes to AST Handling
^^^^^^^^^^^^^^^^^^^^^^^^^
Expand Down
2 changes: 1 addition & 1 deletion clang/lib/Sema/SemaDecl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14333,7 +14333,7 @@ void Sema::ActOnUninitializedDecl(Decl *RealDecl) {
return;
}

if (Type->isUndeducedType() &&
if (Type->getContainedDeducedType() &&
DeduceVariableDeclarationType(Var, false, nullptr))
return;

Expand Down
17 changes: 17 additions & 0 deletions clang/test/SemaCXX/alias-template.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
// RUN: %clang_cc1 -verify -std=c++14 -fcxx-exceptions %s
// RUN: %clang_cc1 -fsyntax-only -verify -std=c++20 %s

#if __cplusplus < 202002L
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Can we remove this #if?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

How then can I make some of the file be tested only with c++ 14, and my tests only run with c++ 20 ?

namespace RedeclAliasTypedef {
template<typename U> using T = int;
template<typename U> using T = int;
Expand Down Expand Up @@ -198,3 +200,18 @@ int g = sfinae_me<int>(); // expected-error{{no matching function for call to 's
namespace NullExceptionDecl {
template<int... I> auto get = []() { try { } catch(...) {}; return I; }; // expected-error{{initializer contains unexpanded parameter pack 'I'}}
}
#endif

#if __cplusplus >= 202002L
namespace PR174281 {
template <class T>
struct A {
template <class U>
using E = U; // expected-note {{template is declared here}}
static E u2 = 0; // expected-error {{alias template 'E' requires template arguments; argument deduction only allowed for class templates or alias templates}}
static E u; // expected-error {{declaration of variable 'u' with deduced type 'E' requires an initializer}}
};

decltype(A<int>::u) a; // expected-note {{in instantiation of template class 'PR174281::A<int>' requested here}}
}
#endif