public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH] Avoid emitting "sizetype" type names into .debug_info (PR debug/80263)
@ 2017-04-01 12:27 Jakub Jelinek
  2017-04-03 11:11 ` Pedro Alves
  0 siblings, 1 reply; 3+ messages in thread
From: Jakub Jelinek @ 2017-04-01 12:27 UTC (permalink / raw)
  To: Jason Merrill; +Cc: gcc-patches

Hi!

This PR is about debug info containing the artificial "sizetype" type
as name of a DW_TAG_base_type, which can clash with user sizetype
identifiers etc.

Apparently we already have code that attempts to not expose that type,
but only do that if sizetype has TYPE_DECL as TYPE_NAME and that denotes
some other, standard, type.

The following patch extends it to attempt to emit size_type_node name
instead of "sizetype" if both sizetype and size_type_node have the
same precision and signedness.

Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk?

2017-04-01  Jakub Jelinek  <jakub@redhat.com>

	PR debug/80263
	* dwarf2out.c (modified_type_die): Try harder not to emit internal
	sizetype type into debug info.

	* gcc.dg/debug/dwarf2/pr80263.c: New test.

--- gcc/dwarf2out.c.jj	2017-03-31 20:39:54.000000000 +0200
+++ gcc/dwarf2out.c	2017-04-01 11:24:50.319288819 +0200
@@ -12464,20 +12464,29 @@ modified_type_die (tree type, int cv_qua
      this type.  */
   qualified_type = get_qualified_type (type, cv_quals);
 
-  if (qualified_type == sizetype
-      && TYPE_NAME (qualified_type)
-      && TREE_CODE (TYPE_NAME (qualified_type)) == TYPE_DECL)
+  if (qualified_type == sizetype)
     {
-      tree t = TREE_TYPE (TYPE_NAME (qualified_type));
+      /* Try not to expose the internal sizetype type's name.  */
+      if (TYPE_NAME (qualified_type)
+	  && TREE_CODE (TYPE_NAME (qualified_type)) == TYPE_DECL)
+	{
+	  tree t = TREE_TYPE (TYPE_NAME (qualified_type));
 
-      gcc_checking_assert (TREE_CODE (t) == INTEGER_TYPE
-			   && TYPE_PRECISION (t)
-			   == TYPE_PRECISION (qualified_type)
-			   && TYPE_UNSIGNED (t)
-			   == TYPE_UNSIGNED (qualified_type));
-      qualified_type = t;
+	  gcc_checking_assert (TREE_CODE (t) == INTEGER_TYPE
+			       && (TYPE_PRECISION (t)
+				   == TYPE_PRECISION (qualified_type))
+			       && (TYPE_UNSIGNED (t)
+				   == TYPE_UNSIGNED (qualified_type)));
+	  qualified_type = t;
+	}
+      else if (qualified_type == sizetype
+	       && TREE_CODE (sizetype) == TREE_CODE (size_type_node)
+	       && TYPE_PRECISION (sizetype) == TYPE_PRECISION (size_type_node)
+	       && TYPE_UNSIGNED (sizetype) == TYPE_UNSIGNED (size_type_node))
+	qualified_type = size_type_node;
     }
 
+
   /* If we do, then we can just use its DIE, if it exists.  */
   if (qualified_type)
     {
--- gcc/testsuite/gcc.dg/debug/dwarf2/pr80263.c.jj	2017-04-01 11:29:32.648668616 +0200
+++ gcc/testsuite/gcc.dg/debug/dwarf2/pr80263.c	2017-04-01 11:31:42.954996922 +0200
@@ -0,0 +1,7 @@
+/* PR debug/80263 */
+/* { dg-do compile } */
+/* { dg-options "-g -dA" } */
+
+char array[1];
+
+/* { dg-final { scan-assembler-not {\msizetype} } } */

	Jakub

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2017-04-03 11:31 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-04-01 12:27 [PATCH] Avoid emitting "sizetype" type names into .debug_info (PR debug/80263) Jakub Jelinek
2017-04-03 11:11 ` Pedro Alves
2017-04-03 11:31   ` Pedro Alves

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).