Bug 120773 - [C++26] P3618R0 - Allow attaching main to the global module
Summary: [C++26] P3618R0 - Allow attaching main to the global module
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: c++ (show other bugs)
Version: 16.0
: P3 enhancement
Target Milestone: ---
Assignee: Jakub Jelinek
URL:
Keywords: c++26
Depends on:
Blocks: c++-modules c++26-core
  Show dependency treegraph
 
Reported: 2025-06-23 08:59 UTC by Jakub Jelinek
Modified: 2025-06-24 17:02 UTC (History)
3 users (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2025-06-23 00:00:00


Attachments
gcc16-pr120773.patch (1007 bytes, patch)
2025-06-23 16:31 UTC, Jakub Jelinek
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Jakub Jelinek 2025-06-23 08:59:22 UTC
See <https://wg21.link/P3618R0>.
Comment 1 Andrew Pinski 2025-06-23 09:28:36 UTC
.
Comment 2 Jakub Jelinek 2025-06-23 16:31:38 UTC
Created attachment 61690 [details]
gcc16-pr120773.patch

Untested fix.
Comment 3 GCC Commits 2025-06-24 17:01:03 UTC
The master branch has been updated by Jakub Jelinek <jakub@gcc.gnu.org>:

https://gcc.gnu.org/g:ed7fc2b29ead88be30b40ec2c3c51495200b08c4

commit r16-1657-ged7fc2b29ead88be30b40ec2c3c51495200b08c4
Author: Jakub Jelinek <jakub@redhat.com>
Date:   Tue Jun 24 19:00:11 2025 +0200

    c++: Implement C++26 P3618R0 - Allow attaching main to the global module [PR120773]
    
    The following patch implements the P3618R0 paper by tweaking pedwarn
    condition, adjusting pedwarn wording, adjusting one testcase and adding 4
    new ones.  The paper was voted in as DR, so it isn't guarded on C++ version.
    
    2025-06-24  Jakub Jelinek  <jakub@redhat.com>
    
            PR c++/120773
            * decl.cc (grokfndecl): Implement C++26 P3618R0 - Allow attaching
            main to the global module.  Only pedwarn for current_lang_name
            other than lang_name_cplusplus and adjust pedwarn wording.
    
            * g++.dg/parse/linkage5.C: Don't expect error on
            extern "C++" int main ();.
            * g++.dg/parse/linkage7.C: New test.
            * g++.dg/parse/linkage8.C: New test.
            * g++.dg/modules/main-2.C: New test.
            * g++.dg/modules/main-3.C: New test.
Comment 4 Jakub Jelinek 2025-06-24 17:02:50 UTC
Implemented for GCC 16.