From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 7857) id 41D7D3858401; Sun, 19 Dec 2021 20:09:37 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 41D7D3858401 MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="utf-8" From: Matthias Kretz To: gcc-cvs@gcc.gnu.org Subject: [gcc r12-6066] c++: don't ICE on NAMESPACE_DECL inside FUNCTION_DECL X-Act-Checkin: gcc X-Git-Author: Matthias Kretz X-Git-Refname: refs/heads/master X-Git-Oldrev: 89cf57ea35d1e0a0b818997c737ac70b7310d9d9 X-Git-Newrev: 6bcb6ed5a44b6f271891246ef7ae568bfdc14e9c Message-Id: <20211219200937.41D7D3858401@sourceware.org> Date: Sun, 19 Dec 2021 20:09:37 +0000 (GMT) X-BeenThere: gcc-cvs@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-cvs mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 19 Dec 2021 20:09:37 -0000 https://gcc.gnu.org/g:6bcb6ed5a44b6f271891246ef7ae568bfdc14e9c commit r12-6066-g6bcb6ed5a44b6f271891246ef7ae568bfdc14e9c Author: Matthias Kretz Date: Wed Dec 15 09:45:06 2021 +0100 c++: don't ICE on NAMESPACE_DECL inside FUNCTION_DECL Code like void swap() { namespace __variant = __detail::__variant; ... } create a NAMESPACE_DECL where the CP_DECL_CONTEXT is a FUNCTION_DECL. DECL_TEMPLATE_INFO fails on NAMESPACE_DECL and therefore must be handled first in the assertion. Signed-off-by: Matthias Kretz gcc/cp/ChangeLog: * module.cc (trees_out::get_merge_kind): NAMESPACE_DECLs also cannot have a DECL_TEMPLATE_INFO. Diff: --- gcc/cp/module.cc | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/gcc/cp/module.cc b/gcc/cp/module.cc index f3e7af22699..8451e3dcc90 100644 --- a/gcc/cp/module.cc +++ b/gcc/cp/module.cc @@ -10067,9 +10067,10 @@ trees_out::get_merge_kind (tree decl, depset *dep) tree ctx = CP_DECL_CONTEXT (decl); if (TREE_CODE (ctx) == FUNCTION_DECL) { - /* USING_DECLs cannot have DECL_TEMPLATE_INFO -- this isn't - permitting them to have one. */ + /* USING_DECLs and NAMESPACE_DECLs cannot have DECL_TEMPLATE_INFO -- + this isn't permitting them to have one. */ gcc_checking_assert (TREE_CODE (decl) == USING_DECL + || TREE_CODE (decl) == NAMESPACE_DECL || !DECL_LANG_SPECIFIC (decl) || !DECL_TEMPLATE_INFO (decl));