From patchwork Mon Dec 18 21:31:35 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jason Merrill X-Patchwork-Id: 1877665 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=Sw6YY16H; 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 4SvChF2rLtz1ydg for ; Tue, 19 Dec 2023 08:31:56 +1100 (AEDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 86FE13857C63 for ; Mon, 18 Dec 2023 21:31:54 +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 7CA1A3858C78 for ; Mon, 18 Dec 2023 21:31:43 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 7CA1A3858C78 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 7CA1A3858C78 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=1702935104; cv=none; b=Srf/DkVPHrlMfPp92eyilD4uaJrVDlGjJcJBXXv++SkdhrqkfinEKg2JfZhyImzlm4GlOInztk2h38R52XoYJWLUVMr/8rEXrLU80GQDBVvnYnpUGyxYqA7Uxlwi6gHMxV8kbVXYfktuwxzzNEqXgrUKUdZEQUojW5dLEn93JkY= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1702935104; c=relaxed/simple; bh=gFPnfjPbjzQW409x1no4tIBjcbm3hbO36wXNRprSnO4=; h=DKIM-Signature:From:To:Subject:Date:Message-Id:MIME-Version; b=Tbc1cvvq2WM+4N6EI1xY39Sqxo8rOwdWk98lMPJdFoYddF7a2UNlXaDHHHB/TxuaoY2frSfYRzMb1XWIN94YVU1XV9fjMd0yK99wiO4B3Hs5b0Etnl0vtHj8HOhCWTjxCxTefBkrq2H8uHe6Ksod12O1yU+ua1urmsmFdOPaweE= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1702935103; 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=zjNDhpdP2MxaUL4TcAkYNDeCM9weiDW77nu449SmxKM=; b=Sw6YY16H5q+11TglVBw8L3xEobc3qAuFjjPgIOLG/CuWXxgv4dIfJbh5nRlJsG+IyW+/Hn Rs+G68bVFA4TlHHH8JcmQsxVpCjNKxgFvXJEa5BOPWQzOA+ce9lFMVN600m7mYnLLjsgCA sRhPF/zFgQT54anXk4GVFle3PzjWaXA= Received: from mail-qv1-f70.google.com (mail-qv1-f70.google.com [209.85.219.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-694-def0ij1MPKW5X5ugEXfWAQ-1; Mon, 18 Dec 2023 16:31:39 -0500 X-MC-Unique: def0ij1MPKW5X5ugEXfWAQ-1 Received: by mail-qv1-f70.google.com with SMTP id 6a1803df08f44-67ac7372fd8so56339606d6.2 for ; Mon, 18 Dec 2023 13:31:39 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1702935099; x=1703539899; 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=zjNDhpdP2MxaUL4TcAkYNDeCM9weiDW77nu449SmxKM=; b=s407neMu09Gi74Ey4SRHxjCoek9cTs4QCaoG/8sCL6viVi6IpUmWw9GEaEctIESOZi vv1Co3x9R7t4GwV4YVNWxouWCKJbyZWDi7jz/7j1deGXp4iZNA76yweuZb5mZuKZ3blA I523z8mVEfU5aQHyfVl59euAJoeZLH5GOAoqRKZCtGRnd2xULJQqRTNMM9oxtAClg6JD dOSExjWuoeMyHqQyprp8mgz30RLNjewKW4eOxiPTamWmL0YqmTzQvdqkuqTCELvJ963P 5QD21MXfP4bYLLX67+8tIanIQrafoREk5Azwm8Pig1l+Ol3G+4RFA7mgkg4h9MrBo1Jl czCg== X-Gm-Message-State: AOJu0Yw7WeNSYvHkK9Y4o+47inBWb7Oi6EkSGBt+rjBr8Bcq1dpPBk5E 3vdnSjmJ2s4ZDk0WDHqdu4PLkIel4HaVun/cs5+zh/XjA7J8Cf3vaulMddXiZHNcmc+b8edORD7 3hT5O6pXIKKlnXNaEfR5Q1PQL/RAVn1jitF9nO2gaobvT9CXqisaCt7TPILsU8dY9s+3T9qbIyA == X-Received: by 2002:a0c:c48d:0:b0:67a:a5c3:8110 with SMTP id u13-20020a0cc48d000000b0067aa5c38110mr17055198qvi.3.1702935099013; Mon, 18 Dec 2023 13:31:39 -0800 (PST) X-Google-Smtp-Source: AGHT+IFDuxh5sZQYj3ptkIu6ZdZh9bWe5wy2/pi1cMnjkcdozxlMWpPwmF3fzmlcZnwbcxMJ+snA/g== X-Received: by 2002:a0c:c48d:0:b0:67a:a5c3:8110 with SMTP id u13-20020a0cc48d000000b0067aa5c38110mr17055191qvi.3.1702935098676; Mon, 18 Dec 2023 13:31:38 -0800 (PST) Received: from jason.com (130-44-146-16.s12558.c3-0.arl-cbr1.sbo-arl.ma.cable.rcncustomer.com. [130.44.146.16]) by smtp.gmail.com with ESMTPSA id ml7-20020a056214584700b0067f41cef057sm1431995qvb.102.2023.12.18.13.31.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 18 Dec 2023 13:31:38 -0800 (PST) From: Jason Merrill To: gcc-patches@gcc.gnu.org, Nathan Sidwell Cc: Nathaniel Shead , Patrick Palka Subject: [PATCH RFC] c++/modules: __class_type_info and modules Date: Mon, 18 Dec 2023 16:31:35 -0500 Message-Id: <20231218213135.2720773-1-jason@redhat.com> X-Mailer: git-send-email 2.39.3 MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-Spam-Status: No, score=-12.3 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_H3, 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 Tested x86_64-pc-linux-gnu. Does this make sense? Did you have another theory about how to merge these? -- 8< -- Doing a dynamic_cast in both TUs broke because we were declaring a new __class_type_info in _b that conflicted with the one imported in the global module from _a. lookup_elaborated_type has a comment that we probably don't want to find such imports in general, but in this case it seems necessary to make the artificial lazy declarations of RTTI types work. gcc/cp/ChangeLog: * name-lookup.cc (lookup_elaborated_type): Look for bindings in the global namespace in the ABI namespace. gcc/testsuite/ChangeLog: * g++.dg/modules/pr106304_b.C: Add dynamic_cast. --- gcc/cp/name-lookup.cc | 10 ++++++++++ gcc/testsuite/g++.dg/modules/pr106304_b.C | 1 + 2 files changed, 11 insertions(+) base-commit: 5347263b347d02e875879ca40ca6e289ac178919 prerequisite-patch-id: 66735c0c7beb22586ed4b632d10ec9094bb9920c diff --git a/gcc/cp/name-lookup.cc b/gcc/cp/name-lookup.cc index 09dc6ef3e5a..f15b338025d 100644 --- a/gcc/cp/name-lookup.cc +++ b/gcc/cp/name-lookup.cc @@ -8092,6 +8092,16 @@ lookup_elaborated_type (tree name, TAG_how how) // FIXME: This isn't quite right, if we find something // here, from the language PoV we're not supposed to // know it? + // We at least need to do this in __cxxabiv1 to unify lazy + // declarations of __class_type_info in build_dynamic_cast_1. + if (current_namespace == abi_node) + { + tree g = (BINDING_VECTOR_CLUSTER (*slot, 0) + .slots[BINDING_SLOT_GLOBAL]); + for (ovl_iterator iter (g); iter; ++iter) + if (qualify_lookup (*iter, LOOK_want::TYPE)) + return *iter; + } } } } diff --git a/gcc/testsuite/g++.dg/modules/pr106304_b.C b/gcc/testsuite/g++.dg/modules/pr106304_b.C index e8333909c8d..0d1da086176 100644 --- a/gcc/testsuite/g++.dg/modules/pr106304_b.C +++ b/gcc/testsuite/g++.dg/modules/pr106304_b.C @@ -5,4 +5,5 @@ module pr106304; void f(A& a) { as_b(a); + dynamic_cast(&a); }