Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 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
1 change: 1 addition & 0 deletions clang/docs/ReleaseNotes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -886,6 +886,7 @@ Bug Fixes to C++ Support
out of a module (which is the case e.g. in MSVC's implementation of ``std`` module). (#GH118218)
- Fixed a pack expansion issue in checking unexpanded parameter sizes. (#GH17042)
- Fixed a bug where captured structured bindings were modifiable inside non-mutable lambda (#GH95081)
- Clang now identifies unexpanded parameter packs within the type constraint on a non-type template parameter. (#GH88866)

Bug Fixes to AST Handling
^^^^^^^^^^^^^^^^^^^^^^^^^
Expand Down
12 changes: 10 additions & 2 deletions clang/lib/Sema/SemaTemplate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1530,9 +1530,17 @@ NamedDecl *Sema::ActOnNonTypeTemplateParameter(Scope *S, Declarator &D,
Param->setAccess(AS_public);

if (AutoTypeLoc TL = TInfo->getTypeLoc().getContainedAutoTypeLoc())
if (TL.isConstrained())
if (AttachTypeConstraint(TL, Param, Param, D.getEllipsisLoc()))
if (TL.isConstrained()) {
if (const ASTTemplateArgumentListInfo *ArgumentList =
TL.getConceptReference()->getTemplateArgsAsWritten())
for (const TemplateArgumentLoc &Loc : ArgumentList->arguments()) {
Invalid |= DiagnoseUnexpandedParameterPack(
Loc, UnexpandedParameterPackContext::UPPC_TypeConstraint);
}
if (!Invalid &&
AttachTypeConstraint(TL, Param, Param, D.getEllipsisLoc()))
Invalid = true;
}

if (Invalid)
Param->setInvalidDecl();
Expand Down
42 changes: 42 additions & 0 deletions clang/test/SemaCXX/cxx2c-fold-exprs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -305,3 +305,45 @@ static_assert(__is_same_as(_Three_way_comparison_result_with_tuple_like<tuple<in
static_assert(__is_same_as(_Three_way_comparison_result_with_tuple_like<tuple<int>, 0>::type, long));

}

namespace GH88866 {

template <typename...Ts> struct index_by;

template <typename T, typename Indices>
concept InitFunc = true;

namespace Invalid {

template <typename Indices, InitFunc<Indices> auto... init>
struct LazyLitMatrix;

template <
typename...Indices,
InitFunc<index_by<Indices>> auto... init
// expected-error@-1 {{type constraint contains unexpanded parameter pack 'Indices'}}
>
struct LazyLitMatrix<index_by<Indices...>, init...> {
};

using T = LazyLitMatrix<index_by<int, char>, 42, 43>;

}

namespace Valid {

template <typename Indices, InitFunc<Indices> auto... init>
struct LazyLitMatrix;

template <
typename...Indices,
InitFunc<index_by<Indices...>> auto... init
>
struct LazyLitMatrix<index_by<Indices...>, init...> {
};

using T = LazyLitMatrix<index_by<int, char>, 42, 43>;

}

}
Loading