[c-family] Fix PR ada/113397

Message ID 2170135.irdbgypaU6@fomalhaut
State Accepted
Headers
Series [c-family] Fix PR ada/113397 |

Checks

Context Check Description
snail/gcc-patch-check success Github commit url

Commit Message

Eric Botcazou Jan. 16, 2024, 11:17 a.m. UTC
  It is a regression on the mainline for -fdump-ada-spec in a pathological case.

Tested on x86-64/Linux, applied on the mainline.


2024-01-16  Eric Botcazou  <ebotcazou@adacore.com>

	PR ada/113397
	* c-ada-spec.cc (check_type_name_conflict): Add guard for the
	presence of DECL_NAME on a TYPE_DECL.
  

Patch

diff --git a/gcc/c-family/c-ada-spec.cc b/gcc/c-family/c-ada-spec.cc
index 7d886c0f92e..4b245ed6975 100644
--- a/gcc/c-family/c-ada-spec.cc
+++ b/gcc/c-family/c-ada-spec.cc
@@ -1566,6 +1566,8 @@  check_type_name_conflict (pretty_printer *buffer, tree t)
 	s = "";
       else if (TREE_CODE (TYPE_NAME (tmp)) == IDENTIFIER_NODE)
 	s = IDENTIFIER_POINTER (TYPE_NAME (tmp));
+      else if (!DECL_NAME (TYPE_NAME (tmp)))
+	s = "";
       else
 	s = IDENTIFIER_POINTER (DECL_NAME (TYPE_NAME (tmp)));