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

commit r16-3413-gf707c093dee0468a3ef837a6c40afcf4c7fa7e46
Author: Jakub Jelinek <ja...@redhat.com>
Date:   Wed Aug 27 14:00:51 2025 +0200

    c++: Fix up cpp_warn on __STDCPP_FLOAT*_T__ [PR121520]
    
    I got the cpp_warn on __STDCPP_FLOAT*_T__ if we aren't predefining those
    wrong, so e.g. on powerpc64le we don't diagnose #undef __STDCPP_FLOAT16_T__.
    I've added it as else if on the
    if (c_dialect_cxx () && cxx_dialect > cxx20 && !floatn_nx_types[i].extended)
    condition, which means cpp_warn is called in case a target supports some
    extended type like _Float32x, cpp_warn is called on __STDCPP_FLOAT32_T__
    (where when it supported _Float32 as well it did cpp_define_warn
    (pfile, "__STDCPP_FLOAT32_T__=1") earlier).
    On targets where the types aren't supported the earlier
    if (FLOATN_NX_TYPE_NODE (i) == NULL_TREE) continue;
    path is taken.
    
    This patch fixes it to cpp_warn on the non-extended types for C++23
    if the target doesn't support them and cpp_define_warn as before if it does.
    
    2025-08-27  Jakub Jelinek  <ja...@redhat.com>
    
            PR target/121520
            * c-cppbuiltin.cc (c_cpp_builtins): Properly call cpp_warn
            for __STDCPP_FLOAT<NN>_T__ if FLOATN_NX_TYPE_NODE (i) is NULL
            for C++23 for non-extended types and don't call cpp_warn for
            extended types.

Diff:
---
 gcc/c-family/c-cppbuiltin.cc | 16 ++++++++--------
 1 file changed, 8 insertions(+), 8 deletions(-)

diff --git a/gcc/c-family/c-cppbuiltin.cc b/gcc/c-family/c-cppbuiltin.cc
index fe80e1f80fff..6b22f9e60b14 100644
--- a/gcc/c-family/c-cppbuiltin.cc
+++ b/gcc/c-family/c-cppbuiltin.cc
@@ -1327,22 +1327,22 @@ c_cpp_builtins (cpp_reader *pfile)
 
   for (int i = 0; i < NUM_FLOATN_NX_TYPES; i++)
     {
-      if (FLOATN_NX_TYPE_NODE (i) == NULL_TREE)
-       continue;
       if (c_dialect_cxx ()
          && cxx_dialect > cxx20
          && !floatn_nx_types[i].extended)
        {
          char name[sizeof ("__STDCPP_FLOAT128_T__=1")];
+         if (FLOATN_NX_TYPE_NODE (i) == NULL_TREE)
+           {
+             sprintf (name, "__STDCPP_FLOAT%d_T__", floatn_nx_types[i].n);
+             cpp_warn (pfile, name);
+             continue;
+           }
          sprintf (name, "__STDCPP_FLOAT%d_T__=1", floatn_nx_types[i].n);
          cpp_define_warn (pfile, name);
        }
-      else if (cxx_dialect >= cxx23)
-       {
-         char name[sizeof ("__STDCPP_FLOAT128_T__")];
-         sprintf (name, "__STDCPP_FLOAT%d_T__", floatn_nx_types[i].n);
-         cpp_warn (pfile, name);
-       }
+      else if (FLOATN_NX_TYPE_NODE (i) == NULL_TREE)
+       continue;
       char prefix[20], csuffix[20];
       sprintf (prefix, "FLT%d%s", floatn_nx_types[i].n,
               floatn_nx_types[i].extended ? "X" : "");

Reply via email to