Commit 85409531 by Jason Merrill

c++: Fix error-recovery with concepts.

Here, push_tinst_level refused to push into the scope of Foo::Foo
because it was triggered from the ill-formed function fun.  But we didn't
check the return value and tried to pop the un-pushed level.

	PR c++/93551
	* constraint.cc (satisfy_declaration_constraints): Check return
	value of push_tinst_level.
parent 0712ea63
2020-02-04 Jason Merrill <jason@redhat.com> 2020-02-04 Jason Merrill <jason@redhat.com>
PR c++/93551
* constraint.cc (satisfy_declaration_constraints): Check return
value of push_tinst_level.
PR c++/90951 PR c++/90951
* constexpr.c (cxx_eval_array_reference): {}-initialize missing * constexpr.c (cxx_eval_array_reference): {}-initialize missing
elements instead of value-initializing them. elements instead of value-initializing them.
......
...@@ -2692,7 +2692,8 @@ satisfy_declaration_constraints (tree t, subst_info info) ...@@ -2692,7 +2692,8 @@ satisfy_declaration_constraints (tree t, subst_info info)
tree result = boolean_true_node; tree result = boolean_true_node;
if (norm) if (norm)
{ {
push_tinst_level (t); if (!push_tinst_level (t))
return result;
push_access_scope (t); push_access_scope (t);
result = satisfy_associated_constraints (norm, args, info); result = satisfy_associated_constraints (norm, args, info);
pop_access_scope (t); pop_access_scope (t);
......
// PR c++/93551
// { dg-do compile { target concepts } }
namespace std {
template<typename _Tp, _Tp __v>
struct integral_constant
{
static constexpr _Tp value = __v;
typedef _Tp value_type;
typedef integral_constant<_Tp, __v> type;
constexpr operator value_type() const noexcept { return value; }
};
template<typename _Base, typename _Derived>
struct is_base_of
: public integral_constant<bool, __is_base_of(_Base, _Derived)>
{ };
template <typename _Base, typename _Derived>
inline constexpr bool is_base_of_v = is_base_of<_Base, _Derived>::value;
}
class Bar { };
struct Foo {
template <typename P> requires std::is_base_of_v<Bar, P>
Foo(P const&);
};
template <typename P>
Foo fun(P const& arg) {
(bool)arg; // { dg-error "" }
return Foo {arg};
}
int main() {
fun(Bar{});
return 0;
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment