From patchwork Fri Feb 9 21:50:00 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Patrick Palka X-Patchwork-Id: 1897255 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=KFO41Q9Y; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=8.43.85.97; helo=server2.sourceware.org; envelope-from=gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=patchwork.ozlabs.org) Received: from server2.sourceware.org (server2.sourceware.org [8.43.85.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4TWnbD3pkQz23h8 for ; Sat, 10 Feb 2024 08:50:31 +1100 (AEDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 463FE385829B for ; Fri, 9 Feb 2024 21:50:29 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by sourceware.org (Postfix) with ESMTPS id 476CB3858C35 for ; Fri, 9 Feb 2024 21:50:09 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 476CB3858C35 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=redhat.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 476CB3858C35 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=170.10.133.124 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1707515410; cv=none; b=nVldf6qo5CngP0DXbY8UeNL35/o59pPiBvPyJZvyydLsbHozVDzjva1uKW9QSgeHEcgvgADq2BaGsli/C3qLgKH7ySQwwjOF58sJcL8hhTbfPREbFNFD7+Ppe9S8KVK3YdPzfHDAZfDAmGolkk6NJ4nxDafYrTuMjiHnYeCgYDw= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1707515410; c=relaxed/simple; bh=yjOA0OYc3CA/kEAsoAzRbZ08r/v0Ql4sh132fQqs2GM=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=QuaHQ24d9FrD+mFlbQkU/H07QwlCx2cPmOOPa8yuVKl4BAD/5gq9D6IwGOvoC8n/3iJbjAsHCMTc5dCwpLGXZb2XItRra92udNNSIhDB6H4FwVjSMtG6c2XTrn9bJUtOR9BpKEvFSgVIXSKIZcLPphv+/BfrD2DLU8nWQaHYpVQ= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1707515408; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=GaDBy9zAn5Px5jn8QSQs1hqHXBh8NDYh/Vw6vql1uqs=; b=KFO41Q9YHdsFYHuuJMhUVcjMjdpCtlTjT8yerUZGt96zc9hPTVFsN+Zp8iKNj2VLZb7zNQ YR4vsXIW1GEbrnRE376QXFF0qwObeL+3git0lJ+rFmL5KQJEDnxJ4dyPL9Thh3SLXG/Q0W V9oTKPxTXjSWof5Gg9qlQqXS0Z8UNVk= Received: from mail-ot1-f69.google.com (mail-ot1-f69.google.com [209.85.210.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-642-_yhOuhzQOx6OHDLVmCS2aQ-1; Fri, 09 Feb 2024 16:50:08 -0500 X-MC-Unique: _yhOuhzQOx6OHDLVmCS2aQ-1 Received: by mail-ot1-f69.google.com with SMTP id 46e09a7af769-6e124429720so1421087a34.3 for ; Fri, 09 Feb 2024 13:50:07 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707515406; x=1708120206; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=GaDBy9zAn5Px5jn8QSQs1hqHXBh8NDYh/Vw6vql1uqs=; b=p6jflU3j8NzQLUIjL1LC6+hO3IjKxwxnQL1iJyObvFlx2D81gJNIrnt0Bvxjl16Cs6 /wiUKPjX1PbqIgnnQCG3ZYy0/tErUTYIQEhYr8yvCekjy9OaSPfjMEOvjzEHxAC/0Gpb FyZDvkLkWy702whfALWu67AImq5hH4nRLtNqIekZJD3Kesu9REtgmw6iCcFyMwSsLwaz omCgIEtUv2EvKPC0jj7OpuC8X2SKG2+PtBE0i4hHbBO4pQvCktsHtkI/77EtS0P2JSum A8ylxjCU8rmB9omXk9ZrHncRhapIV0VFMIiMNlT7Sp0Ky7VbIP0D91+UjObbEAI8TVT4 6BAw== X-Gm-Message-State: AOJu0YzQHYPSWCEdUpcV2zqQH6/AluV71uFFhBlXgDOKgrnodf8RWua0 0vVp16zG/wkR0m9WKfaRaLguts+hvRZIbBVs6QCYnxfDRssF1lxzjymOkrrP/dF48ZjpLy6zWgU NhTKHT1+2aWcQ1gKysqDVZjvx1fItMCswG8UfqeuAOsIR7GGWDm1C2crYtDY3hMo1MqdWQ78dda H87/jQ9xIRWVWoS3y/cQr+q+gE+mL5bfXqan5y X-Received: by 2002:a9d:3e0d:0:b0:6e2:bc4f:5858 with SMTP id a13-20020a9d3e0d000000b006e2bc4f5858mr376850otd.17.1707515406153; Fri, 09 Feb 2024 13:50:06 -0800 (PST) X-Google-Smtp-Source: AGHT+IFAe34I4LA7u1Mqtz+XkrT1+WZBed9PWRtz9B5+piaM4FZ++5HNAP/JGfUtFjXBSlIdhVR/gA== X-Received: by 2002:a9d:3e0d:0:b0:6e2:bc4f:5858 with SMTP id a13-20020a9d3e0d000000b006e2bc4f5858mr376830otd.17.1707515405789; Fri, 09 Feb 2024 13:50:05 -0800 (PST) X-Forwarded-Encrypted: i=1; AJvYcCVTND7q+2EoDkLge1zheih1CMKyITFFeFB0xfQRQyAC+NTssnu52pTX2E6hLQU8jqc0rDh25J0E34z9ft2qpStgttDJNtByd6exfsu9dYNRf5o= Received: from localhost.localdomain (ool-457670bb.dyn.optonline.net. [69.118.112.187]) by smtp.gmail.com with ESMTPSA id kr21-20020ac861d5000000b0042c594ee9c2sm930133qtb.63.2024.02.09.13.50.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 09 Feb 2024 13:50:05 -0800 (PST) From: Patrick Palka To: gcc-patches@gcc.gnu.org Cc: jason@redhat.com, nathan@acm.org, Patrick Palka Subject: [PATCH 1/2] c++/modules: reduce lazy loading recursion Date: Fri, 9 Feb 2024 16:50:00 -0500 Message-ID: <20240209215001.1196422-1-ppalka@redhat.com> X-Mailer: git-send-email 2.43.0.561.g235986be82 MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-Spam-Status: No, score=-13.7 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H5, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_NONE, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org Bootstrapped and regtested on x86_64-pc-linux-gnu, does this look OK for trunk -- >8 -- It turns out that with modules we can call mangle_decl recursively, which is a problem because the global mangling state isn't recursion aware. The recursion happens from write_closure_type_name, which calls lambda_function, which performs name lookup, which can trigger lazy loading, which can call maybe_clone_body for a newly loaded cdtor, which can inspect DECL_ASSEMBLER_NAME, which enters mangling. This was observed when using fmtlib as a module with trunk and it leads to a bogus "mangling conflicts with a previous mangle error" followed by an ICE from cdtor_comdat_group due to a mangling mismatch. This patch fixes this by sidestepping lazy loading when performing the op() lookup in lambda_function, so that we don't accidentally end up entering mangling recursively. This should be safe since the lazy load should still get triggered by some other name lookup. In passing it was noticed that lazy loading can get quite recursive ultimately due to the name lookups from check_local_shadow, which may perform lazy loading, which cause us to instantiate/clone things, which end up calling check_local_shadow. This patch fixes this by implementating an optimization suggested by Jason: > I think we shouldn't bother with check_local_shadow in a clone or > instantiation, only when actually parsing. This reduces the maximum depth of lazy loading recursion for a simple modular Hello World from ~115 to ~12. gcc/cp/ChangeLog: * lambda.cc (lambda_function): Call get_class_binding_direct instead of lookup_member to sidestep lazy loading. * name-lookup.cc (check_local_shadow): Punt if we're in a function context that's definitely not actual parsing. --- gcc/cp/lambda.cc | 4 +--- gcc/cp/name-lookup.cc | 17 +++++++++++++++++ 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/gcc/cp/lambda.cc b/gcc/cp/lambda.cc index 1d37e5a52b9..4b1f9391fee 100644 --- a/gcc/cp/lambda.cc +++ b/gcc/cp/lambda.cc @@ -175,9 +175,7 @@ lambda_function (tree lambda) if (CLASSTYPE_TEMPLATE_INSTANTIATION (type) && !COMPLETE_OR_OPEN_TYPE_P (type)) return NULL_TREE; - lambda = lookup_member (type, call_op_identifier, - /*protect=*/0, /*want_type=*/false, - tf_warning_or_error); + lambda = get_class_binding_direct (type, call_op_identifier); if (lambda) lambda = STRIP_TEMPLATE (get_first_fn (lambda)); return lambda; diff --git a/gcc/cp/name-lookup.cc b/gcc/cp/name-lookup.cc index e58f3b5cb4d..ca5ba87bc76 100644 --- a/gcc/cp/name-lookup.cc +++ b/gcc/cp/name-lookup.cc @@ -3275,6 +3275,23 @@ check_local_shadow (tree decl) if (TREE_CODE (decl) == PARM_DECL && !DECL_CONTEXT (decl)) return NULL_TREE; + if (DECL_FUNCTION_SCOPE_P (decl)) + { + tree ctx = DECL_CONTEXT (decl); + if (DECL_CLONED_FUNCTION_P (ctx) + || DECL_TEMPLATE_INSTANTIATED (ctx) + || (DECL_LANG_SPECIFIC (ctx) + && DECL_DEFAULTED_FN (ctx)) + || (LAMBDA_FUNCTION_P (ctx) + && LAMBDA_EXPR_REGEN_INFO (CLASSTYPE_LAMBDA_EXPR + (DECL_CONTEXT (ctx))))) + /* It suffices to check shadowing only when actually parsing. + So punt for clones, instantiations, defaulted functions and + regenerated lambdas. This optimization helps lazy loading + cascades with modules. */ + return NULL_TREE; + } + tree old = NULL_TREE; cp_binding_level *old_scope = NULL; if (cxx_binding *binding = outer_binding (DECL_NAME (decl), NULL, true)) From patchwork Fri Feb 9 21:50:01 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Patrick Palka X-Patchwork-Id: 1897256 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=X8ymd4dI; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=2620:52:3:1:0:246e:9693:128c; helo=server2.sourceware.org; envelope-from=gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=patchwork.ozlabs.org) Received: from server2.sourceware.org (server2.sourceware.org [IPv6:2620:52:3:1:0:246e:9693:128c]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4TWnbG2gZKz23h8 for ; Sat, 10 Feb 2024 08:50:34 +1100 (AEDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 5ADE6385840B for ; Fri, 9 Feb 2024 21:50:30 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by sourceware.org (Postfix) with ESMTPS id 86B393858C39 for ; Fri, 9 Feb 2024 21:50:11 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 86B393858C39 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=redhat.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 86B393858C39 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=170.10.133.124 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1707515412; cv=none; b=kgBufXFw2jVYqhhIYTCy2JICB/WPPZs80C+vLh8Hu9ZtaZGIOqml0QEMcV73wfSkrIetzbXVS9AFAaf+EWiIp8WNNgRwAkmjpQZ40zVOCTnTvYaHnJ2XYED9+Df3dPsLhmLTUE5dmDpsTUSHXoJnizbwf/KWTB7GZQuEFY5ZxVk= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1707515412; c=relaxed/simple; bh=YLGqOplDmVk4mW32prPSzh1PkIDSLmXBfXMVqo77N9k=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=RVFj/H6l9At4pZe1HJV6zQ6+Qy6Fx79f0+jeqbnhTgbvesTqfjDIUWkwu38M19cCTyMCNnPpGKBQAAMmvkZedNHhggFY1JtphydvuitmEWQSg3fFDl43HsTTMwASV3sLw5duMTV2Cff6qrhNoWcH4TuI83Mq+fv+f5X6JdSiSFQ= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1707515411; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=sAh13PILOxPwUNmChodx9BhrUB3wspZutLQfshL+jcE=; b=X8ymd4dIKzYFm860MKOXRjpjkkHCs67sX5hy6fqD9xps5oqFKglr1cqfFxaOPyTCDg3AZJ tBhdd/R9fz/esaRucPFCSCMUTAbOwvzfQhlKr6vtdEppLfrmyNZAXOifoGHTagVIYPUGCr 1sSQddu/eWzezpV4iiA6894svX1Jsjg= Received: from mail-qt1-f198.google.com (mail-qt1-f198.google.com [209.85.160.198]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-114-sN4pQ4XWOkiAdmDQPHmJsg-1; Fri, 09 Feb 2024 16:50:10 -0500 X-MC-Unique: sN4pQ4XWOkiAdmDQPHmJsg-1 Received: by mail-qt1-f198.google.com with SMTP id d75a77b69052e-42c4a173008so11699671cf.0 for ; Fri, 09 Feb 2024 13:50:10 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707515408; x=1708120208; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=sAh13PILOxPwUNmChodx9BhrUB3wspZutLQfshL+jcE=; b=D46ahylPR+3WI5We8FZFWcEGS2OZYnCt3ABJDyYdgUNFbNzf4xTf+tZDgfbRSOE5kc R3JkwIAQpCr3Sh/1QK4qN7jwngEyIDPUkgSaMdyXWJBwY3jyJE+2mPL53Jz9KSukLNfU uxYAG0C+XONjjkunnlMK+iJYr5ws8YqtpfuhCiiK9G00NHz1rBvMJenzBWICqqUV7kD/ PkPih8Ca7d/D9fMjrud5JZNNzUPv2dc2PO+ude2ps49aUQRdTP9MwwPIrzSEq/Ajn40G Aab5uy4+RIYIVYnNvvQqwMqIy+kusGGo1+nv0GhCqt6+6aOl5gDiusObM35GRyIgxKJx jexw== X-Gm-Message-State: AOJu0Yz9WpxiweBtwxMsI9vtSsk7qZJWhGqDw9/VfwcggY+LP38NROkO CTjS34G+NCNmMDsSAbSg7uzg9DvFy+tXoMvH5BffnjMhxuvMhSIy9RxS5Jr/t+nXi66eE5sRXbP U/GuE5cL4OYERxKgfdinkMR3rrgBDF2QNdpF5eTqNspCCSmTs5ZkaSPm1hfypA53SYQrijb3RTs E4x7bd57OdJwDthuI/wTNgaXOUr08f7zKJ/44x X-Received: by 2002:a05:622a:8095:b0:42c:64fa:604c with SMTP id js21-20020a05622a809500b0042c64fa604cmr242552qtb.2.1707515408442; Fri, 09 Feb 2024 13:50:08 -0800 (PST) X-Google-Smtp-Source: AGHT+IFQ2EsMR9hCSLzx2Qk2mtxXdz8gwWaC2AgNDBqJDPGUPCly+76MiO17/crOYyIJ8NrU/uR6nQ== X-Received: by 2002:a05:622a:8095:b0:42c:64fa:604c with SMTP id js21-20020a05622a809500b0042c64fa604cmr242539qtb.2.1707515408128; Fri, 09 Feb 2024 13:50:08 -0800 (PST) X-Forwarded-Encrypted: i=1; AJvYcCWHhUrtrYDIHSCsj5s0gUSut7NZwRSq9kxb2jYisn9YzaZTsqsAC9bq3EiL56P/RA+WoeYoohlY2md3to/I8UdzI6pdU51b/sCXzc4RbpjsKnI= Received: from localhost.localdomain (ool-457670bb.dyn.optonline.net. [69.118.112.187]) by smtp.gmail.com with ESMTPSA id kr21-20020ac861d5000000b0042c594ee9c2sm930133qtb.63.2024.02.09.13.50.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 09 Feb 2024 13:50:06 -0800 (PST) From: Patrick Palka To: gcc-patches@gcc.gnu.org Cc: jason@redhat.com, nathan@acm.org, Patrick Palka Subject: [PATCH 2/2] c++/modules: ICE with modular fmtlib Date: Fri, 9 Feb 2024 16:50:01 -0500 Message-ID: <20240209215001.1196422-2-ppalka@redhat.com> X-Mailer: git-send-email 2.43.0.561.g235986be82 In-Reply-To: <20240209215001.1196422-1-ppalka@redhat.com> References: <20240209215001.1196422-1-ppalka@redhat.com> MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-Spam-Status: No, score=-12.2 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H5, RCVD_IN_MSPIKE_WL, RCVD_IN_SORBS_WEB, SPF_HELO_NONE, SPF_NONE, TXREP, T_SCC_BODY_TEXT_LINE, URIBL_BLACK autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org Bootstrapped and regtested on x86_64-pc-linux-gnu, does this look OK for trunk? I'll try to reduce and add testcases overnight for these separate bugs before pushing. -- >8 -- Building modular fmtlib triggered two small modules bugs in C++23 and C++26 mode respectively (due to libstdc++ header differences). The first is that a TEMPLATE_DECL having DECL_LANG_SPECIFIC doesn't necessarily imply that its DECL_TEMPLATE_RESULT has DECL_LANG_SPECIFIC. So we need to use STRIP_TEMPLATE consistently; this is a follow-up to r12-7187-gdb84f382ae3dc2. The second is that get_originating_module_decl was ICEing on class-scope enumerators injected via using-enum. gcc/cp/ChangeLog: * module.cc (depset::hash::add_specializations): Use STRIP_TEMPLATE consistently. (get_originating_module_decl): Handle class-scope CONST_DECL. --- 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 3c2fef0e3f4..659fa03dae1 100644 --- a/gcc/cp/module.cc +++ b/gcc/cp/module.cc @@ -13248,7 +13248,7 @@ depset::hash::add_specializations (bool decl_p) if (use_tpl == 1) /* Implicit instantiations only walked if we reach them. */ needs_reaching = true; - else if (!DECL_LANG_SPECIFIC (spec) + else if (!DECL_LANG_SPECIFIC (STRIP_TEMPLATE (spec)) || !DECL_MODULE_PURVIEW_P (STRIP_TEMPLATE (spec))) /* Likewise, GMF explicit or partial specializations. */ needs_reaching = true; @@ -18708,7 +18708,8 @@ get_originating_module_decl (tree decl) && (TREE_CODE (DECL_CONTEXT (decl)) == ENUMERAL_TYPE)) decl = TYPE_NAME (DECL_CONTEXT (decl)); else if (TREE_CODE (decl) == FIELD_DECL - || TREE_CODE (decl) == USING_DECL) + || TREE_CODE (decl) == USING_DECL + || TREE_CODE (decl) == CONST_DECL) { decl = DECL_CONTEXT (decl); if (TREE_CODE (decl) != FUNCTION_DECL)