Bug 106646 - [C++23] P2437R1 - Support for #warning
Summary: [C++23] P2437R1 - Support for #warning
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: c++ (show other bugs)
Version: unknown
: P3 normal
Target Milestone: ---
Assignee: Jakub Jelinek
URL:
Keywords:
Depends on:
Blocks: c++23-core
  Show dependency treegraph
 
Reported: 2022-08-16 16:46 UTC by Marek Polacek
Modified: 2022-08-24 08:05 UTC (History)
1 user (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2022-08-22 00:00:00


Attachments
gcc13-pr106646.patch (1.01 KB, patch)
2022-08-22 09:49 UTC, Jakub Jelinek
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Marek Polacek 2022-08-16 16:46:57 UTC
See <https://wg21.link/p2437r1>.

Yes, we already have it, but we should still double check that we implement everything the paper talks about.
Comment 1 Joseph S. Myers 2022-08-18 23:04:21 UTC
Enabled for C2x (i.e. stopped -pedantic diagnosing it) with commit d7c3000147c1d8090f66a2baf4623d2c0dfe8eb6 - C++ will presumably want to adjust the diagnostics as well as enabling for relevant C++ versions and adding associated tests.
Comment 2 Marek Polacek 2022-08-19 14:29:46 UTC
Thanks, I can look into that for C++.

I notice that with your patch we say "#warning before C2X is a GCC extension" even when compiling with cc1plus; I suppose the C2X message should be guarded by CPP_OPTION (pfile, cplusplus).
Comment 3 Jakub Jelinek 2022-08-22 09:49:22 UTC
Created attachment 53488 [details]
gcc13-pr106646.patch

Untested implementation.
Comment 4 GCC Commits 2022-08-24 07:56:45 UTC
The master branch has been updated by Jakub Jelinek <jakub@gcc.gnu.org>:

https://gcc.gnu.org/g:365202625d2f2d6694dba889ca67498fefb59c68

commit r13-2167-g365202625d2f2d6694dba889ca67498fefb59c68
Author: Jakub Jelinek <jakub@redhat.com>
Date:   Wed Aug 24 09:55:57 2022 +0200

    preprocessor: Implement C++23 P2437R1 - Support for #warning [PR106646]
    
    On Thu, Aug 18, 2022 at 11:02:44PM +0000, Joseph Myers wrote:
    > ISO C2x standardizes the existing #warning extension.  Arrange
    > accordingly for it not to be diagnosed with -std=c2x -pedantic, but to
    > be diagnosed with -Wc11-c2x-compat.
    
    And here is the corresponding C++ version.
    Don't pedwarn about this for C++23/GNU++23 and tweak the diagnostics
    for C++ otherwise, + testsuite coverage.
    The diagnostic wording is similar e.g. to the #elifdef diagnostics.
    
    2022-08-24  Jakub Jelinek  <jakub@redhat.com>
    
            PR c++/106646
            * init.cc: Implement C++23 P2437R1 - Support for #warning.
            (lang_defaults): Set warning_directive for GNUCXX23 and CXX23.
            * directives.cc (directive_diagnostics): Use different wording of
            #warning pedwarn for C++.
    
            * g++.dg/cpp/warning-1.C: New test.
            * g++.dg/cpp/warning-2.C: New test.
            * g++.dg/cpp/warning-3.C: New test.
Comment 5 Jakub Jelinek 2022-08-24 08:05:08 UTC
Implemented for GCC 13.