https://gcc.gnu.org/g:f7e1245c2ba103b047ef21751cde605a87d1cd43
commit r15-11565-gf7e1245c2ba103b047ef21751cde605a87d1cd43 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. (cherry picked from commit 6e2ffc51ae89f88292dc9b7256e9fba8db199499) 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 7ffda8b01ef6..7af444fbe1a4 100644 --- a/gcc/c-family/c-cppbuiltin.cc +++ b/gcc/c-family/c-cppbuiltin.cc @@ -1324,7 +1324,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
