public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* Fix representation of gcov_info_type
@ 2014-06-28 18:22 Jan Hubicka
  2014-07-07  8:44 ` Richard Biener
  0 siblings, 1 reply; 7+ messages in thread
From: Jan Hubicka @ 2014-06-28 18:22 UTC (permalink / raw)
  To: gcc-patches

Hi,
This is first bug noticed by the type consistency checks I added.

gcov_info_type is a structure that contains function pointer to itself.  While
building it we first build a structure w/o size and fields, then we build a
function type that produces a qualified variant of the structure (not sure why
that legwork is needed). Then we add fields via finish_builtin_struct.
It sets the fields to structure but not its variant and then does layout_type
that actually copies size to all variants. So we end up with TYPE_COMPLETE_P variant
that has size but no fields.  This is quite obviously wrong.

Fixed thus. Bootstrapped, lto-bootstrapped and regtested x86_64-linux, comitted.

	* stor-layout.c (finish_builtin_struct): Copy fields into
	the variants.

Index: stor-layout.c
===================================================================
--- stor-layout.c	(revision 212098)
+++ stor-layout.c	(working copy)
@@ -2065,7 +2065,7 @@ void
 finish_builtin_struct (tree type, const char *name, tree fields,
 		       tree align_type)
 {
-  tree tail, next;
+  tree tail, next, variant;
 
   for (tail = NULL_TREE; fields; tail = fields, fields = next)
     {
@@ -2074,6 +2074,10 @@ finish_builtin_struct (tree type, const
       DECL_CHAIN (fields) = tail;
     }
   TYPE_FIELDS (type) = tail;
+  for (variant = TYPE_MAIN_VARIANT (type);
+       variant != 0;
+       variant = TYPE_NEXT_VARIANT (variant))
+    TYPE_FIELDS (variant) = tail;
 
   if (align_type)
     {

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

end of thread, other threads:[~2014-07-08 20:40 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-06-28 18:22 Fix representation of gcov_info_type Jan Hubicka
2014-07-07  8:44 ` Richard Biener
2014-07-08  0:25   ` Jan Hubicka
2014-07-08 10:58     ` Richard Biener
2014-07-08 14:03       ` Jan Hubicka
2014-07-08 14:51         ` Richard Biener
2014-07-08 20:40           ` Jan Hubicka

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).