From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-pg1-x530.google.com (mail-pg1-x530.google.com [IPv6:2607:f8b0:4864:20::530]) by sourceware.org (Postfix) with ESMTPS id C7BA03858D33 for ; Mon, 27 Nov 2023 04:59:47 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org C7BA03858D33 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gmail.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org C7BA03858D33 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2607:f8b0:4864:20::530 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1701061189; cv=none; b=xMXuEQtbfvRX4qOgZtwtZT95zvk+z23a4NLl2kIGSNV0GuAOtxkN74HWjIakn/W9TvFYAdlZfxugbM3P3uxjfyJhXa8X77k4cyB4KsS4KcgelKoBwk1AQLnB1QudbXQCYIcV8j61ANOJptprpwhEb+K8KA+vRVHdEBu9ZoX8u0o= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1701061189; c=relaxed/simple; bh=gkPJzl/VOrgy60Qw7jtpqDgEk5+Qmt4SR41bKtnfXPc=; h=DKIM-Signature:Message-ID:Date:From:To:Subject:MIME-Version; b=qhJC1gsNFx+8XEc8Ll+w9BQm4OUAocHLLVF3dwsGmNGXu4gUUb8NTUwWjNsZSW4Pca6GS7eBdpj48ZMtKGhPtesIiVM4UE2ZJT3QYjT8rP0ZvSYz6jR50ci3FwSUs/HcZ5KDMwvz6MmpTLSHkvzQUolfEwjI83HkkP/MIKJfy98= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-pg1-x530.google.com with SMTP id 41be03b00d2f7-53fa455cd94so2328779a12.2 for ; Sun, 26 Nov 2023 20:59:47 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1701061186; x=1701665986; darn=gcc.gnu.org; h=in-reply-to:content-disposition:mime-version:references:subject:cc :to:from:date:message-id:from:to:cc:subject:date:message-id:reply-to; bh=2rhHUxYzoX/9BPzFqiaM84jyZRo9eCccZUyB5YDCvLw=; b=QRcwPQgYBzrVhj9JRI3iJZXq/OI1vttnQaey2l833M/nT84Lpv8WoayZF35kMhf2rN HUCpjVuYfNq6f/9rBZOw1raOY/L82z8mn7MY1DeRWym/QO/8v9xFf8pdKBCdb0RRiJ6+ ykeN6LL8s0fv++9gxv1boP3RGOUuRwO6bEfyJbwjzlGMnbLAfTWqQL5qtSGyGG0FLUbn 4WZPPA0hc4C3sQo6KrMc1xErrtUrZ0w7bya7y10zE6GjV8Nbb8NOuEfqCUU8F6M7TrzD EKMMiWz5AWn0hHD33DgnFbFg4+vTD0ACstDGUQ3lLkn+kyPY1GSoQkdLsi8aOMdju/GM PWug== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1701061186; x=1701665986; h=in-reply-to:content-disposition:mime-version:references:subject:cc :to:from:date:message-id:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=2rhHUxYzoX/9BPzFqiaM84jyZRo9eCccZUyB5YDCvLw=; b=Ph0RARdugzvE43DliDWYUnQbUQT0EPLkgmolMJpEKAoJd+5Ap3qAR+BF4muCJ+gF2G 4u2OqfWiIKFHkcN50ExvDL7K0ju/hnKG3K1U4lzOD8tiCUXQ3moAR9YSzt3YwhaTren9 0DXS99/dgHhgY8ueb3dOa9p3/VpQDIYdGT6fO1t7pCKHY6m3LycMoDotttouV+R5AyZk NSccPmdAZgURoQnPjcAt7qwkRdQZTfKoYezAzt2BqNtm9LEN3FvjNpEN72xTxIUNcboU v1FJhzLRa6krk/INl3FKlF1soDff/sZfj36EzASqMztTr+azHfTh2VGnrhDruuAqIiPa x7yg== X-Gm-Message-State: AOJu0Yx/NfI5Qjl/B2wURxY+dMT7tL+v34q8n0BHFjX55NezlmCv7Di9 wujmkn5YcgyYjgtG94FqGbQ= X-Google-Smtp-Source: AGHT+IEtEcBUMQDZzHrtGOHcupygu6S/yaTmyrYlEe1wOE+NneszmIAIt3woprUV6jFilGyaagCllw== X-Received: by 2002:a17:902:c24c:b0:1cf:a126:e7f3 with SMTP id 12-20020a170902c24c00b001cfa126e7f3mr7877861plg.35.1701061186624; Sun, 26 Nov 2023 20:59:46 -0800 (PST) Received: from Thaum. ([124.168.116.122]) by smtp.gmail.com with ESMTPSA id j17-20020a170902da9100b001c44dbc92a2sm1103926plx.184.2023.11.26.20.59.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 26 Nov 2023 20:59:46 -0800 (PST) Message-ID: <65642242.170a0220.8bb8e.28e1@mx.google.com> X-Google-Original-Message-ID: Date: Mon, 27 Nov 2023 15:59:39 +1100 From: Nathaniel Shead To: Nathan Sidwell Cc: gcc-patches@gcc.gnu.org, Jason Merrill Subject: Re: [PATCH] c++: Check module attachment instead of purview when necessary [PR112631] References: <655b2b3f.a70a0220.ca3c4.d564@mx.google.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Spam-Status: No, score=-5.8 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,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 List-Id: On Thu, Nov 23, 2023 at 03:03:37PM -0500, Nathan Sidwell wrote: > On 11/20/23 04:47, Nathaniel Shead wrote: > > Bootstrapped and regtested on x86_64-pc-linux-gnu. I don't have write > > access. > > > > -- >8 -- > > > > Block-scope declarations of functions or extern values are not allowed > > when attached to a named module. Similarly, class member functions are > > not inline if attached to a named module. However, in both these cases > > we currently only check if the declaration is within the module purview; > > it is possible for such a declaration to occur within the module purview > > but not be attached to a named module (e.g. in an 'extern "C++"' block). > > This patch makes the required adjustments. > > > Ah I'd been puzzling over the default inlinedness of member-fns of > block-scope structs. Could you augment the testcase to make sure that's > right too? > > Something like: > > // dg-module-do link > export module Mod; > > export auto Get () { > struct X { void Fn () {} }; > return X(); > } > > > /// > import Mod > void Frob () { Get().Fn(); } > I gave this a try and it indeed doesn't work correctly; 'Fn' needs to be marked 'inline' for this to link (whether or not 'Get' itself is inline). I've tried tracing the code to work out what's going on but I've been struggling to work out how all the different flags (e.g. TREE_PUBLIC, TREE_EXTERNAL, TREE_COMDAT, DECL_NOT_REALLY_EXTERN) interact, which flags we want to be set where, and where the decision of what function definitions to emit is actually made. I did find that doing 'mark_used(decl)' on all member functions in block-scope structs seems to work however, but I wonder if that's maybe too aggressive or if there's something else we should be doing?