On 8/27/25 4:03 AM, Jakub Jelinek wrote:
Hi!

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.

Bootstrapped/regtested on x86_64-linux and i686-linux, tested on the
testcase on cross to powerpc64le-linux, ok for trunk?

OK.

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.

--- gcc/c-family/c-cppbuiltin.cc.jj     2025-08-15 22:31:17.244081706 +0200
+++ gcc/c-family/c-cppbuiltin.cc        2025-08-26 14:26:49.221668918 +0200
@@ -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" : "");

        Jakub


Reply via email to