[pushed] c++: handle _FloatNN redeclaration like bool [PR107128]

Message ID 20230313201636.152901-1-jason@redhat.com
State Committed
Headers
Series [pushed] c++: handle _FloatNN redeclaration like bool [PR107128] |

Commit Message

Jason Merrill March 13, 2023, 8:16 p.m. UTC
  Tested x86_64-pc-linux-gnu, applying to trunk.

-- 8< --

It's been inconvenient to compile testcases preprocessed with GCC 12 or
earlier because they break on

  typedef __float128 _Float128;

We already had code for handling this with bool and wchar_t, it just needs
to be extended to _FloatNN as well.

	PR c++/107128

gcc/cp/ChangeLog:

	* parser.cc (cp_parser_set_decl_spec_type): Use
	redefined_builtin_type for extended_float_type_p.

gcc/testsuite/ChangeLog:

	* g++.dg/warn/pragma-system_header6.h: New test.
	* g++.dg/warn/pragma-system_header6.C: New test.
---
 gcc/testsuite/g++.dg/warn/pragma-system_header6.h | 3 +++
 gcc/cp/parser.cc                                  | 2 ++
 gcc/testsuite/g++.dg/warn/pragma-system_header6.C | 1 +
 3 files changed, 6 insertions(+)
 create mode 100644 gcc/testsuite/g++.dg/warn/pragma-system_header6.h
 create mode 100644 gcc/testsuite/g++.dg/warn/pragma-system_header6.C


base-commit: 8e9c65d34c799c9dadea1e2e60b4180f26262829
  

Patch

diff --git a/gcc/testsuite/g++.dg/warn/pragma-system_header6.h b/gcc/testsuite/g++.dg/warn/pragma-system_header6.h
new file mode 100644
index 00000000000..989ccd8795a
--- /dev/null
+++ b/gcc/testsuite/g++.dg/warn/pragma-system_header6.h
@@ -0,0 +1,3 @@ 
+#pragma GCC system_header
+
+typedef float _Float32;
diff --git a/gcc/cp/parser.cc b/gcc/cp/parser.cc
index 533041946c0..a277003ea58 100644
--- a/gcc/cp/parser.cc
+++ b/gcc/cp/parser.cc
@@ -33452,10 +33452,12 @@  cp_parser_set_decl_spec_type (cp_decl_specifier_seq *decl_specs,
      C++-safe.  */
   if (decl_spec_seq_has_spec_p (decl_specs, ds_typedef)
       && !type_definition_p
+      && TYPE_P (type_spec)
       && (type_spec == boolean_type_node
 	  || type_spec == char8_type_node
 	  || type_spec == char16_type_node
 	  || type_spec == char32_type_node
+	  || extended_float_type_p (type_spec)
 	  || type_spec == wchar_type_node)
       && (decl_specs->type
 	  || decl_spec_seq_has_spec_p (decl_specs, ds_long)
diff --git a/gcc/testsuite/g++.dg/warn/pragma-system_header6.C b/gcc/testsuite/g++.dg/warn/pragma-system_header6.C
new file mode 100644
index 00000000000..924e4522cf0
--- /dev/null
+++ b/gcc/testsuite/g++.dg/warn/pragma-system_header6.C
@@ -0,0 +1 @@ 
+#include "pragma-system_header6.h"