aboutsummaryrefslogtreecommitdiff
path: root/libjava/classpath/gnu/java/security/util
diff options
context:
space:
mode:
authorPatrick Palka <ppalka@redhat.com>2026-02-12 18:20:36 -0500
committerPatrick Palka <ppalka@redhat.com>2026-02-12 18:20:36 -0500
commit12f461009b0e833e4a0404ab348c0fe5b7bbfc75 (patch)
tree171155b911942de47bec1b6dd87fc6014015469d /libjava/classpath/gnu/java/security/util
parent9db703c556c02e51bc84d168170ae811ec87c011 (diff)
downloadgcc-12f461009b0e833e4a0404ab348c0fe5b7bbfc75.zip
gcc-12f461009b0e833e4a0404ab348c0fe5b7bbfc75.tar.gz
gcc-12f461009b0e833e4a0404ab348c0fe5b7bbfc75.tar.bz2
c++: constrained auto NTTP vs associated constraints
According to [temp.param], the constraint on an auto NTTP is an associated constraint and so should be checked as part of satisfaction of the overall associated constraints, but we currently don't include them in the template's associated constraints and instead check them separately during template argument coercion/deduction. Fixing this is mostly a matter of storing the NTTP's constraint inside TEMPLATE_PARM_CONSTRAINTS instead of PLACEHOLDER_TYPE_CONSTRAINTS and generalizing the relevant template parameter processing subroutines to also handle such NTTPs. While this is straightfoward for "simple" constrained autos, it was later noticed that for e.g. 'C auto* P' or 'D auto& Q' it's not clear how to express their constraint as an associated constraint. For P an option would be C<decltype(*P)>, but for Q it's not clear how to pass the referenced type to C. C<decltype(auto(Q))> would be wrong because we don't want to decay function/array types. So this patch sidesteps this question by preserving the existing behavior for such "non-simple" constrained auto (i.e. don't add them to the associated constraints, and continue ad-hoc checking them during do_auto_deduction). The simple case is by far the most common anyway. The main observeable difference with this change is that such constrained auto NTTPs are now involved in the "more constrained" determination during partial ordering. gcc/cp/ChangeLog: * constraint.cc (finish_shorthand_constraint): Add is_non_type parameter. Handle constrained auto NTTPs. * cp-tree.h (copy_template_args): Declare. (expand_template_argument_pack): Declare. (finish_shorthand_constraint): Adjust declaration. * mangle.cc (write_template_param_decl): Obtain constraints of an auto NTTP through TEMPLATE_PARM_CONSTRAINTS instead of PLACEHOLDER_TYPE_CONSTRAINTS. * parser.cc (cp_parser_constrained_type_template_parm): Inline into its only caller and remove. (cp_parser_constrained_non_type_template_parm): Likewise. (finish_constrained_parameter): Simplify after the above. Replace the type of an ordinary constrained auto NTTP with a non-constrained one and set TEMPLATE_PARM_CONSTRAINTS for it. (cp_parser_template_parameter): Dispatch to finish_constrained_parameter for a constrained auto NTTP. * pt.cc (process_template_parm): Pass is_non_type to finish_shorthand_constraint. Use TEMPLATE_PARM_CONSTRAINTS instead of TREE_TYPE for clarity. (expand_template_argument_pack): Remove forward declaration. (copy_template_args): Likewise. (make_constrained_placeholder_type): Return the type not the TYPE_NAME for consistency with make_auto_1 etc. (do_auto_deduction): Assert we no longer see simple constrained autos during coercion/deduction. gcc/testsuite/ChangeLog: * g++.dg/cpp26/pack-indexing15.C: Adjust expected error upon constrained auto NTTP satisfaction failure. * g++.dg/cpp2a/concepts-placeholder12.C: Likewise. * g++.dg/cpp2a/concepts-pr97093.C: Likewise. * g++.dg/cpp2a/concepts-template-parm2.C: Likewise. * g++.dg/cpp2a/concepts-template-parm6.C: Likewise. * g++.dg/cpp2a/concepts-template-parm12.C: New test. Reviewed-by: Jason Merrill <jason@redhat.com>
Diffstat (limited to 'libjava/classpath/gnu/java/security/util')
0 files changed, 0 insertions, 0 deletions