From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: 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 99E45385840D for ; Tue, 23 Apr 2024 16:45:06 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 99E45385840D 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 99E45385840D 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=1713890709; cv=none; b=i7NRI1IKoaK2WzMOhJ0+Iq7s/w1bJ6qIu/PDknLlEIyv5ieWf4OvnIfoWBs21+tty4An5fjFjF2iOg0jyORRRgDox+tRtZqBcrPLIxp8c31XPWWdICcGSOLCALHnqQ4eTj5sxVS5jk9wB4h34sE8/Iz7gejksCH+BTCKVOsus3Y= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1713890709; c=relaxed/simple; bh=1b7ko1i5LNaKQ0h3HxMNOn0+549Gv/kL0k3fp6/3qfk=; h=DKIM-Signature:From:Date:To:Subject:Message-ID:MIME-Version; b=TlgzZSZWSsw2D47HjUN1xkpvlEgiXt+XY+xadNRcFjrSxwPPl2ruckbxCp5uz7CcnRQaDshLls7BYV6Uls7g3oyMwLr4eEmsXQ8MRMiGclygEmZYp8q+Y+Gfe5q5fM+wxZj4b9lxIVRPQ9DRm8xkH2tqMiZ5nUdE8UFHujzy/bY= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1713890706; 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: in-reply-to:in-reply-to:references:references; bh=UJPpZATL+L5B6wn8LMBRamMY1Vwp2NImNWhnZG5Fnhc=; b=NkwU2jrGY70WTWUkMqsJiSIDq0ERdsLpCuXByi9oD52Q7cgqRqt3TOB+BB31iRi5QNRckM KDXGJge8QsdchS8wabRv3rRAxzzbrkf8c8lH6cMYpz4nWKokUR4N5X2vJmRiOxmtKAdy+Y pLJpPH0zksHbb9k7YZKTsLU0oK3LM4A= Received: from mail-yb1-f197.google.com (mail-yb1-f197.google.com [209.85.219.197]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-76-xrcoPtjyNFyAejHwuRIRpg-1; Tue, 23 Apr 2024 12:45:04 -0400 X-MC-Unique: xrcoPtjyNFyAejHwuRIRpg-1 Received: by mail-yb1-f197.google.com with SMTP id 3f1490d57ef6-de468af2b73so11595231276.0 for ; Tue, 23 Apr 2024 09:45:04 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1713890704; x=1714495504; h=mime-version:references:message-id:in-reply-to:subject:cc:to:date :from:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=UJPpZATL+L5B6wn8LMBRamMY1Vwp2NImNWhnZG5Fnhc=; b=jMn2yHFTaU7j24ANa9fhpMLLZhHDVGIQ5t5UYjYWoEPLx1cQHtZtZ2GoiYureo/PLQ 30+fOh8yKYNVPKKy+8RZYrw7hLebPNK0yStXTRO8gq926YdDfazEHZTVwRzEgriKScFw uzodxZl+HxCD29JE8srwLUTuxNBEHpXo4b40t1p9UqOEO+rhtwu2KqVmNnJ0tZhe6tsW nXMkIuIUxeq8gEoz1IQp14sAx8r8FFumubJpLjcAvCAuU/iRbM9FQVIBJFHjup7BwdMk jMR2uhU0gcRrqUuePVne33As28sVruJX+RZwZXYuqsF8Z4sfdSiEewjHmxEhGT9ZXjF3 DwIw== X-Gm-Message-State: AOJu0YwmYHH5NOpy/qtAsS6gGzWj5vhjd4UA68XVbIQe+q67+DAlt6Zl 5+R50JUoD3IJcVdiwfJhYBiaBIbeZqCmZwhut5Zmiz/cpWXGykcUdjcbaMvzC+z10jpRj1dPnRu qdVSLxYSQUZVWAGgvvbgbhF5fcVECi4nSNcukgAwUK9TSPl2nNwzlwQk= X-Received: by 2002:a25:8602:0:b0:dcd:3172:7269 with SMTP id y2-20020a258602000000b00dcd31727269mr136378ybk.2.1713890704187; Tue, 23 Apr 2024 09:45:04 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGcvUaO4LLNiUbiAeAUOI5WkFpFPCkDB36klJg+zdegrLlpN226t6Dl52hwJARCGgpUjOOXTA== X-Received: by 2002:a25:8602:0:b0:dcd:3172:7269 with SMTP id y2-20020a258602000000b00dcd31727269mr136357ybk.2.1713890703813; Tue, 23 Apr 2024 09:45:03 -0700 (PDT) Received: from [192.168.1.130] (ool-457670bb.dyn.optonline.net. [69.118.112.187]) by smtp.gmail.com with ESMTPSA id dc30-20020a05620a521e00b007906f83a273sm2571252qkb.94.2024.04.23.09.45.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 23 Apr 2024 09:45:03 -0700 (PDT) From: Patrick Palka X-Google-Original-From: Patrick Palka Date: Tue, 23 Apr 2024 12:45:02 -0400 (EDT) To: Patrick Palka cc: gcc-patches@gcc.gnu.org, jason@redhat.com, nathanieloshead@gmail.com Subject: Re: [PATCH] c++/modules: deduced return type merging [PR114795] In-Reply-To: <20240423164101.3016046-1-ppalka@redhat.com> Message-ID: <6293000f-a325-a8bf-dca8-c7273e5af25d@idea> References: <20240423164101.3016046-1-ppalka@redhat.com> MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=US-ASCII X-Spam-Status: No, score=-13.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_H4,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_NONE,TXREP,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 List-Id: On Tue, 23 Apr 2024, Patrick Palka wrote: > Tested on x86_64-pc-linux-gnu, does this look OK for trunk? > > -- >8 -- > > When merging an imported function template specialization with an > existing one, if the existing one has an undeduced return type and the > imported one's is already deduced, we need to propagate the deduced type > since once we install the imported definition we won't get a chance to > deduce it by normal means. > > This patch makes is_matching_decl propagate the deduced return type > alongside the existing propagate of the existing specification. I er, "alongside the existing propagation of the exception specification". > suppose could instead propagate it later when installing the imported > definition from read_definition, but it seems best to propagate it > sooner rather than later. > > PR c++/114795 > > gcc/cp/ChangeLog: > > * module.cc (trees_in::is_matching_decl): Propagate deduced > function return type. > > gcc/testsuite/ChangeLog: > > * g++.dg/modules/auto-4_a.H: New test. > * g++.dg/modules/auto-4_b.C: New test. > --- > gcc/cp/module.cc | 5 +++++ > gcc/testsuite/g++.dg/modules/auto-4_a.H | 14 ++++++++++++++ > gcc/testsuite/g++.dg/modules/auto-4_b.C | 15 +++++++++++++++ > 3 files changed, 34 insertions(+) > create mode 100644 gcc/testsuite/g++.dg/modules/auto-4_a.H > create mode 100644 gcc/testsuite/g++.dg/modules/auto-4_b.C > > diff --git a/gcc/cp/module.cc b/gcc/cp/module.cc > index d94d8ff4df9..e10e19ac9f7 100644 > --- a/gcc/cp/module.cc > +++ b/gcc/cp/module.cc > @@ -11537,6 +11537,11 @@ trees_in::is_matching_decl (tree existing, tree decl, bool is_typedef) > else if (!DEFERRED_NOEXCEPT_SPEC_P (d_spec) > && !comp_except_specs (d_spec, e_spec, ce_type)) > goto mismatch; > + > + /* Similarly if EXISTING has an undeduced return type, but DECL's > + is already deduced. */ > + if (undeduced_auto_decl (existing) && !undeduced_auto_decl (decl)) > + TREE_TYPE (existing) = change_return_type (TREE_TYPE (d_type), e_type); > } > else if (is_typedef) > { > diff --git a/gcc/testsuite/g++.dg/modules/auto-4_a.H b/gcc/testsuite/g++.dg/modules/auto-4_a.H > new file mode 100644 > index 00000000000..52b50533982 > --- /dev/null > +++ b/gcc/testsuite/g++.dg/modules/auto-4_a.H > @@ -0,0 +1,14 @@ > +// PR c++/114795 > +// { dg-additional-options "-fmodule-header" } > +// { dg-module-cmi {} } > + > +template > +struct A { > + auto f() { return 0; } Oops, this should be "return T();" to match the other definition below. > +}; > + > +template > +inline void g() { > + A a; > + a.f(); > +} > diff --git a/gcc/testsuite/g++.dg/modules/auto-4_b.C b/gcc/testsuite/g++.dg/modules/auto-4_b.C > new file mode 100644 > index 00000000000..378684ef6d0 > --- /dev/null > +++ b/gcc/testsuite/g++.dg/modules/auto-4_b.C > @@ -0,0 +1,15 @@ > +// PR c++/114795 > +// { dg-additional-options "-fmodules-ts -fno-module-lazy" } > + > +template > +struct A { > + auto f() { return T(); } > +}; > + > +A a; > + > +import "auto-4_a.H"; > + > +int main() { > + g(); // { dg-bogus "before deduction of 'auto'" "" { target *-*-* } 0 } > +} > -- > 2.45.0.rc0 > >