https://gcc.gnu.org/g:6e2ffc51ae89f88292dc9b7256e9fba8db199499

commit r17-1411-g6e2ffc51ae89f88292dc9b7256e9fba8db199499
Author: Zhou Qiankang <[email protected]>
Date:   Mon Jun 8 10:30:45 2026 +0800

    Don't define __FRACT_FBIT__ in C++ [PR 125642]
    
            PR c++/125642
    
    gcc/c-family/
    
            * c-cppbuiltin.cc (c_cpp_builtins): Don't define __FRACT_FBIT__
            in C++.
    
    gcc/testsuite/
    
            * g++.dg/pr125642.C: New test.

Diff:
---
 gcc/c-family/c-cppbuiltin.cc    | 2 +-
 gcc/testsuite/g++.dg/pr125642.C | 5 +++++
 2 files changed, 6 insertions(+), 1 deletion(-)

diff --git a/gcc/c-family/c-cppbuiltin.cc b/gcc/c-family/c-cppbuiltin.cc
index 7296ee8b3bac..900843e8d030 100644
--- a/gcc/c-family/c-cppbuiltin.cc
+++ b/gcc/c-family/c-cppbuiltin.cc
@@ -1378,7 +1378,7 @@ c_cpp_builtins (cpp_reader *pfile)
     }
 
   /* For fixed-point fibt, ibit, max, min, and epsilon.  */
-  if (targetm.fixed_point_supported_p ())
+  if (!c_dialect_cxx () && targetm.fixed_point_supported_p ())
     {
       builtin_define_fixed_point_constants ("SFRACT", "HR",
                                            short_fract_type_node);
diff --git a/gcc/testsuite/g++.dg/pr125642.C b/gcc/testsuite/g++.dg/pr125642.C
new file mode 100644
index 000000000000..76807156ad9b
--- /dev/null
+++ b/gcc/testsuite/g++.dg/pr125642.C
@@ -0,0 +1,5 @@
+/* { dg-do preprocess } */
+
+#ifdef __FRACT_FBIT__
+#error "we should not report _Fract support in C++"
+#endif

Reply via email to