Skip to content

[Clang] SFINAE on mismatching pack length during constraint satisfaction checking #101879

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 5, 2024
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
4 changes: 4 additions & 0 deletions clang/lib/Sema/SemaConcept.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -531,6 +531,10 @@ static ExprResult calculateConstraintSatisfaction(

std::optional<unsigned>
EvaluateFoldExpandedConstraintSize(const CXXFoldExpr *FE) const {

// We should ignore errors in the presence of packs of different size.
Sema::SFINAETrap Trap(S);

Expr *Pattern = FE->getPattern();

SmallVector<UnexpandedParameterPack, 2> Unexpanded;
Expand Down
30 changes: 30 additions & 0 deletions clang/test/SemaCXX/cxx2c-fold-exprs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -275,3 +275,33 @@ static_assert(S<int>::g<int>() == 2); // expected-error {{call to 'g' is ambiguo


}

namespace GH99430 {

template <class _Ty1, class _Ty2>
using _Synth_three_way_result = int;

template <class... _Types>
class tuple;

template <int _Index>
struct tuple_element;

template <class, int...>
struct _Three_way_comparison_result_with_tuple_like {
using type = int;
};

template <class... _TTypes, int... _Indices>
requires(requires {
typename _Synth_three_way_result<_TTypes, tuple_element<_Indices>>;
} && ...)

struct _Three_way_comparison_result_with_tuple_like<tuple<_TTypes...>, _Indices...>{
using type = long;
};

static_assert(__is_same_as(_Three_way_comparison_result_with_tuple_like<tuple<int>, 0, 1>::type, int));
static_assert(__is_same_as(_Three_way_comparison_result_with_tuple_like<tuple<int>, 0>::type, long));

}
Loading