From patchwork Wed Jun 12 20:30:50 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jason Merrill X-Patchwork-Id: 1947116 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=BadcQzgc; 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 4Vzxys2LFkz20Pb for ; Thu, 13 Jun 2024 06:31:33 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 8B3973882169 for ; Wed, 12 Jun 2024 20:31:31 +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 2DD9F3882108 for ; Wed, 12 Jun 2024 20:31:03 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 2DD9F3882108 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 2DD9F3882108 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=1718224265; cv=none; b=L/UtXIp4WTEOnzidfNUtg+Fg9T2gfJg8A9zZmxgB7DpojkVclGCIaiktr2Slcz9t6KciD5zvSTeC2ZZ1oOaDkyp12+hEn7+Rd7KEt8GOjL1Xv2EO57r/F5JISwLj8Txmdg7pklsuWc1Pys1iCKg4sp4nqv6ZY7lAMf7q9ONiF2o= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1718224265; c=relaxed/simple; bh=YhrFdNuaqHIW9YGoWY7SgOOw+drFPML2NGe7pd4wAa0=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=BsiG3JAX30htA6jyIH6m3Qik5XIQ/SbKtGVq9cKks75YN0ha/5FhoD0TNYoCy0nge7dS0UoTKQbW0Gi7zs38RDReoKX/ysRblQRLE5Rp+GsJnxOPQpqhcDrvBK0SvS3/4DPFaSSd8qwsPFYohLyowbxJgpgz0pde+W9B+dqXgdg= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1718224262; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=uIgOiZXqdGgPW16iWUalEWHFVDdFRJywM9ZkLE9W5oM=; b=BadcQzgct7+oH6gekec+I2VT8dtFFUerD0iUW2QAU9pYw1fxF8+5/7YWG+5f6K9NfnCzKd LAo7ljsi1HDT3o4jRZGLGVSJLMjhz6K6zGyhp6Iw9Id/OEgcKHyoLz5jtcXgMf5bX+JOO7 ft0rNmXxBzEA/Y8azRukibcatPjcZhk= Received: from mail-yw1-f198.google.com (mail-yw1-f198.google.com [209.85.128.198]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-308-Xq7W0-A-Pf-yDlhZeraOfA-1; Wed, 12 Jun 2024 16:31:00 -0400 X-MC-Unique: Xq7W0-A-Pf-yDlhZeraOfA-1 Received: by mail-yw1-f198.google.com with SMTP id 00721157ae682-62a0841402aso4294897b3.2 for ; Wed, 12 Jun 2024 13:31:00 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1718224260; x=1718829060; h=content-transfer-encoding:mime-version:message-id:date:subject:to :from:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=uIgOiZXqdGgPW16iWUalEWHFVDdFRJywM9ZkLE9W5oM=; b=ugOstEK38zM6rKEc3clVVyFlqmpFlJ4HktdVx7rHHqDFFwinWBVvQP5qWAEsLyVhfi 8pp2FaZ3ENzhgnO8vwnOHAF0QoRHFramSV8v7fwNoqAENNjR6W9Eg1W9uZAVxuc2y7z3 C+nrKWTi6BAiEeNf72hfdLdTWJUY74qAu4sJVlxrqULgss1oxl7Q1egVjnQxzApB6QcK uB0IX3OySXWygCp5HsXRbidJjSauPZi4f3WCK1qhEkJ7j+zesGGsjCcEeh97W680vZGU JZwZ6NosEZIqSxE26Yw1bInXWkdR9KTjhGcoMtcQe+FEOXqPnd42lWY0qZHMEj0ELF3j Bczw== X-Gm-Message-State: AOJu0YzE5q78wiLJFXSfDP2LDRFe7Fk51zGki5F3Xhrzx/7qbe9/TffZ 5CEteCnTHtENkhVoxMKwfxitA+QKSL7/vXW+zcC9YlpTzirlwQlHGtPtz9NCV9UhJZQU6T+m+JE L28xNQdsxpAWBpGNB6gZvXgCONi7fX/W4XoihiPstO9J5OVQlp+YcPmlOT9Xh/Wwv955VFr6SSe +PuT64FyhIOROu8PxUn6LSBVfCSn47/LmP5Rs= X-Received: by 2002:a25:ab52:0:b0:dfe:73d8:4593 with SMTP id 3f1490d57ef6-dfe73d84715mr2552048276.48.1718224259095; Wed, 12 Jun 2024 13:30:59 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHG0sQBad0DZEg7+BmJTsC2TunCb0sbxQ3prieX453nLbHuMuukEMq6nBxz4QBBEz6mcrRzRg== X-Received: by 2002:a25:ab52:0:b0:dfe:73d8:4593 with SMTP id 3f1490d57ef6-dfe73d84715mr2552020276.48.1718224258522; Wed, 12 Jun 2024 13:30:58 -0700 (PDT) Received: from jason-thinkpadp1gen4i.rmtusma.csb (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 6a1803df08f44-6b075e37080sm42200876d6.46.2024.06.12.13.30.57 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 12 Jun 2024 13:30:57 -0700 (PDT) From: Jason Merrill To: gcc-patches@gcc.gnu.org Subject: [pushed] c++: repeated export using Date: Wed, 12 Jun 2024 16:30:50 -0400 Message-ID: <20240612203056.2524730-1-jason@redhat.com> X-Mailer: git-send-email 2.44.0 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_H4, 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, applying to trunk. -- 8< -- A sample implementation of module std was breaking because the exports included 'using std::operator&' twice. Since Nathaniel's r15-964 for PR114867, the first using added an extra instance of each function that was revealed/exported by that using, resulting in duplicates for lookup_maybe_add to dedup. But if the duplicate is the first thing in the list, lookup_add doesn't make an OVERLOAD, so trying to set OVL_USING_P crashes. Fixed by using ovl_make in the case where we want to set the flag. gcc/cp/ChangeLog: * tree.cc (lookup_maybe_add): Use ovl_make when setting OVL_USING_P. gcc/testsuite/ChangeLog: * g++.dg/modules/using-21_a.C: New test. --- gcc/cp/tree.cc | 8 ++++++-- gcc/testsuite/g++.dg/modules/using-21_a.C | 11 +++++++++++ 2 files changed, 17 insertions(+), 2 deletions(-) create mode 100644 gcc/testsuite/g++.dg/modules/using-21_a.C base-commit: 7bf072e87a03c9eaff9b7a1ac182537b70f0ba8e prerequisite-patch-id: 6c196fa553aea243ce21f45cd2ddf3daaa840921 diff --git a/gcc/cp/tree.cc b/gcc/cp/tree.cc index d2a8f79ffab..28648c14c6d 100644 --- a/gcc/cp/tree.cc +++ b/gcc/cp/tree.cc @@ -2526,11 +2526,15 @@ lookup_maybe_add (tree fns, tree lookup, bool deduping) predecessors onto the lookup. */ for (; fns != probe; fns = OVL_CHAIN (fns)) { - lookup = lookup_add (OVL_FUNCTION (fns), lookup); /* Propagate OVL_USING, but OVL_HIDDEN & OVL_DEDUP_P don't matter. */ if (OVL_USING_P (fns)) - OVL_USING_P (lookup) = true; + { + lookup = ovl_make (OVL_FUNCTION (fns), lookup); + OVL_USING_P (lookup) = true; + } + else + lookup = lookup_add (OVL_FUNCTION (fns), lookup); } /* And now skip this function. */ diff --git a/gcc/testsuite/g++.dg/modules/using-21_a.C b/gcc/testsuite/g++.dg/modules/using-21_a.C new file mode 100644 index 00000000000..ce6e3f920f1 --- /dev/null +++ b/gcc/testsuite/g++.dg/modules/using-21_a.C @@ -0,0 +1,11 @@ +// { dg-additional-options "-fmodules-ts -Wno-global-module" } + +module; +namespace foo { + void baz(); +} +export module foo; +namespace foo { + export using foo::baz; + export using foo::baz; +}