From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id AB2713858429; Tue, 14 Dec 2021 13:16:29 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org AB2713858429 From: "cvs-commit at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/103408] ICE when requires auto(x) in C++23 Date: Tue, 14 Dec 2021 13:16:29 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: c++ X-Bugzilla-Version: 12.0 X-Bugzilla-Keywords: ice-on-invalid-code, ice-on-valid-code X-Bugzilla-Severity: normal X-Bugzilla-Who: cvs-commit at gcc dot gnu.org X-Bugzilla-Status: ASSIGNED X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: mpolacek at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: Message-ID: In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-BeenThere: gcc-bugs@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-bugs mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 14 Dec 2021 13:16:29 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D103408 --- Comment #7 from CVS Commits --- The master branch has been updated by Patrick Palka : https://gcc.gnu.org/g:561414cdf8ef0d3c1e2da80b3c8aae56de745b1e commit r12-5952-g561414cdf8ef0d3c1e2da80b3c8aae56de745b1e Author: Patrick Palka Date: Tue Dec 14 08:15:52 2021 -0500 c++: processing_template_decl vs template depth [PR103408] We use processing_template_decl in two slightly different ways: as a flag to signal that we're dealing with templated trees, and as a measure of the current syntactic template nesting depth. This overloaded meaning of p_t_d is conceptually confusing and leads to bugs that we end up working around in an ad-hoc fashion. This patch replaces all uses of processing_template_decl that care about its magnitude to instead look at the depth of current_template_parms via a new macro current_template_depth. This allows us to eliminate 3 workarounds in the concepts code: two about non-templated requires-expressions (in constraint.cc) and one about lambdas inside constraints (in cp_parser_requires_clause_expression etc). This also fixes the testcase in PR103408 about auto(x) used inside a non-templated requires-expression. The replacement was mostly mechanical, aside from two issues: * In synthesize_implicit_template_parm, when introducing a new templa= te parameter list for an abbreviated function template, we need to add the new level of current_template_parms sooner, before calling process_template_parm, since this latter function now looks at current_template_depth to determine the level of the new parameter. * In instantiate_class_template_1 after substituting a template friend declaration, we currently increment processing_template_decl around the call to make_friend_class so that the friend_depth computation within this subroutine yields a nonzero value. We could just replace this with an equivalent manipulation of current_template_depth, but this patch instead rewrites the friend_depth calculation within make_friend_class to not depend on p_t_d / c_t_d at all when called from instantiate_class_template_1. PR c++/103408 gcc/cp/ChangeLog: * constraint.cc (type_deducible_p): Remove workaround for non-templated requires-expressions. (normalize_placeholder_type_constraints): Likewise. * cp-tree.h (current_template_depth): Define. (PROCESSING_REAL_TEMPLATE_DECL): Inspect current_template_depth instead of the magnitude of processing_template_decl. * decl.c (start_decl): Likewise. (grokfndecl): Likewise. (grokvardecl): Likewise. (grokdeclarator): Likewise. * friend.c (make_friend_class): Likewise. Calculate friend_depth differently when called at instantiation time instead of parse time. (do_friend): Likewise. * parser.c (cp_parser_requires_clause_expression): Remove workaround for lambdas inside constraints. (cp_parser_constraint_expression): Likewise. (cp_parser_requires_expression): Likewise. (synthesize_implicit_template_parm): Add to current_template_pa= rms before calling process_template_parm. * pt.c (inline_needs_template_parms): Inspect current_template_depth instead of the magnitude of processing_template_decl. (push_inline_template_parms_recursive): Likewise. (maybe_begin_member_template_processing): Likewise. (begin_template_parm_list): Likewise. (process_template_parm): Likewise. (end_template_parm_list): Likewise. (push_template_decl): Likewise. (add_inherited_template_parms): Likewise. (instantiate_class_template_1): Don't adjust processing_template_decl around the call to make_friend_class. adjust_processing_template_decl to adjust_template_depth. Set current_template_parms instead of processing_template_decl when adjust_template_depth. (make_auto_1): Inspect current_template_depth instead of the magnitude of processing_template_decl. (splice_late_return_type): Likewise. * semantics.c (fixup_template_type): Likewise. gcc/testsuite/ChangeLog: * g++.dg/concepts/diagnostic18.C: Expect a "constraints on a non-templated function" error. * g++.dg/cpp23/auto-fncast11.C: New test.=