Skip to content
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
1 change: 1 addition & 0 deletions clang/docs/ReleaseNotes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -455,6 +455,7 @@ Bug Fixes to C++ Support
- Fix a crash when attempting to deduce a deduction guide from a non deducible template template parameter. (#130604)
- Fix for clang incorrectly rejecting the default construction of a union with
nontrivial member when another member has an initializer. (#GH81774)
- Diagnose unresolved overload sets in non-dependent compound requirements. (#GH51246) (#GH97753)

Bug Fixes to AST Handling
^^^^^^^^^^^^^^^^^^^^^^^^^
Expand Down
4 changes: 4 additions & 0 deletions clang/lib/Parse/ParseExprCXX.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3200,6 +3200,8 @@ ExprResult Parser::ParseRequiresExpression() {
BalancedDelimiterTracker ExprBraces(*this, tok::l_brace);
ExprBraces.consumeOpen();
ExprResult Expression = ParseExpression();
if (Expression.isUsable())
Expression = Actions.CheckPlaceholderExpr(Expression.get());
if (!Expression.isUsable()) {
ExprBraces.skipToEnd();
SkipUntil(tok::semi, tok::r_brace, SkipUntilFlags::StopBeforeMatch);
Expand Down Expand Up @@ -3369,6 +3371,8 @@ ExprResult Parser::ParseRequiresExpression() {
// expression ';'
SourceLocation StartLoc = Tok.getLocation();
ExprResult Expression = ParseExpression();
if (Expression.isUsable())
Expression = Actions.CheckPlaceholderExpr(Expression.get());
if (!Expression.isUsable()) {
SkipUntil(tok::semi, tok::r_brace, SkipUntilFlags::StopBeforeMatch);
break;
Expand Down
2 changes: 1 addition & 1 deletion clang/test/AST/ByteCode/libcxx/deref-to-array.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,7 @@ template <class _Op, class _Yp>
void __is_derived_from_view_interface();
template <class _Tp>
bool enable_view = derived_from<_Tp, int> ||
requires { ranges::__is_derived_from_view_interface; };
requires { ranges::__is_derived_from_view_interface<_Tp, int>(); };
template <class>
concept range = requires { ranges::end; };
template <class _Tp>
Expand Down
42 changes: 37 additions & 5 deletions clang/test/SemaTemplate/concepts.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1037,7 +1037,7 @@ void test() {

namespace GH66612 {
template<typename C>
auto end(C c) ->int;
auto end(C c) ->int; // expected-note {{possible target for call}}

template <typename T>
concept Iterator = true;
Expand All @@ -1047,9 +1047,8 @@ namespace GH66612 {
{ end } -> Iterator; // #66612GH_END
};

static_assert(Container<int>);// expected-error{{static assertion failed}}
// expected-note@-1{{because 'int' does not satisfy 'Container'}}
// expected-note@#66612GH_END{{because 'end' would be invalid: reference to overloaded function could not be resolved; did you mean to call it?}}
static_assert(Container<int>);
// expected-error@#66612GH_END{{reference to overloaded function could not be resolved; did you mean to call it?}}
}

namespace GH66938 {
Expand Down Expand Up @@ -1407,7 +1406,6 @@ static_assert(!std::is_constructible_v<span<4>, array<int, 3>>);

}


namespace GH162125 {
template<typename, int size>
concept true_int = (size, true);
Expand Down Expand Up @@ -1444,3 +1442,37 @@ struct s {

void(*test)(int) = &s<bool>::f<int>;
}
namespace GH51246 {
void f(); // expected-note {{possible target for call}}
void f(int); // expected-note {{possible target for call}}
void g();
static_assert(requires { f; }); // expected-error {{reference to overloaded function could not be resolved}}
static_assert(requires { g; });
struct S {
void mf() {
static_assert(requires { mf(); });
static_assert(requires { mf; }); // expected-error {{reference to non-static member function must be called}}
static_assert(requires { S::mf; }); // expected-error {{reference to non-static member function must be called}}
}
void mf2(int); // expected-note 2{{possible target for call}}
void mf2() { // expected-note 2{{possible target for call}}
static_assert(requires { mf2; }); // expected-error {{reference to non-static member function must be called}}
static_assert(requires { S::mf2; }); // expected-error {{reference to non-static member function must be called}}
}
};

} // namespace GH51246


namespace GH97753 {

void f(); // expected-note {{possible target for call}}
void f(int); // expected-note {{possible target for call}}

template<typename T>
concept C = sizeof(T) == 42;

static_assert( requires {{ &f } -> C;} ); // expected-error {{reference to overloaded function could not be resolved;}}
// expected-error@-1 {{static assertion failed due to requirement 'requires { { &f() } -> C; }'}}

}