c++: Unify REQUIRES_EXPR evaluation / diagnostic routines
authorPatrick Palka <ppalka@redhat.com>
Wed, 3 Mar 2021 17:03:09 +0000 (12:03 -0500)
committerPatrick Palka <ppalka@redhat.com>
Wed, 3 Mar 2021 17:03:09 +0000 (12:03 -0500)
commit5a559ace9b83cb9d7d4ba6f455ddae014f016dfb
tree1c70d2db0efd8149d43aed9b2ab13890384feb37
parent662ef5b54de8f77080a19e03f31b162c04ba273f
c++: Unify REQUIRES_EXPR evaluation / diagnostic routines

This folds the diagnose_requires_expr routines into the corresponding
tsubst_requires_expr ones.  This is achieved by making the latter
routines take a sat_info instead of a subst_info, and assigning the
appropriate meanings to the flags sat_info::noisy and
sat_info::diagnose_unsatisfaction_p during tsubst_requires_expr:
info.noisy() controls whether to diagnose invalid types and expressions
inside the requirements, and info.diagnose_unsatisfaction_p() controls
whether to additionally diagnose why the requires-expression evaluates
to false.

gcc/cp/ChangeLog:

* constraint.cc (struct sat_info): Document the different
meanings of noisy() and diagnose_unsatisfaction_p() during
satisfaction and requires-expression evaluation.
(tsubst_valid_expression_requirement): Take a sat_info instead
of a subst_info.  Perform the substitution quietly first.  Fold
in error-replaying code from diagnose_valid_expression.
(tsubst_simple_requirement): Take a sat_info instead of a
subst_info.
(tsubst_type_requirement_1): New.  Fold in error-replaying code
from diagnose_valid_type.
(tsubst_type_requirement): Use the above.  Take a sat_info
instead of a subst_info.
(tsubst_compound_requirement): Likewise.  Fold in
error-replaying code from diagnose_compound_requirement.
(tsubst_nested_requirement): Take a sat_info instead of a
subst_info.  Fold in error-replaying code from
diagnose_nested_requirement.
(tsubst_requirement): Take a sat_info instead of a subst_info.
(tsubst_requires_expr): Split into two versions, one that takes
a sat_info argument and another that takes a complain and
in_decl argument.  Remove outdated documentation.  Document the
effects of the sat_info argument.  Don't short-circuit
processing of requirements when diagnosing unsatisfaction,
mirroring diagnose_requires_expr.
(satisfy_nondeclaration_constraint) <case REQUIRES_EXPR>: Remove
assert, and se the three-parameter version of tsubst_requires_expr.
(diagnose_trait_expr): Make static.  Take a template argument
vector instead of a parameter mapping.
(diagnose_valid_expression): Remove.
(diagnose_valid_type): Remove.
(diagnose_simple_requirement): Remove.
(diagnose_compound_requirement): Remove.
(diagnose_type_requirement): Remove.
(diagnose_nested_requirement): Remove.
(diagnose_requirement): Remove.
(diagnose_requires_expr): Remove.
(diagnose_atomic_constraint): Take a sat_info instead of a
subst_info.  Adjust call to diagnose_trait_expr.  Call
tsubst_requires_expr instead of diagnose_requires_expr.
(diagnose_constraints): Remove special casing of REQUIRES_EXPR
and just always call constraint_satisfaction_value.
gcc/cp/constraint.cc