public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [Ada] Fix temporary incorrectly-typed COMPONENT_REF
@ 2012-08-19 14:08 Eric Botcazou
  0 siblings, 0 replies; only message in thread
From: Eric Botcazou @ 2012-08-19 14:08 UTC (permalink / raw)
  To: gcc-patches

[-- Attachment #1: Type: Text/Plain, Size: 540 bytes --]

We generate a temporary incorrectly-typed COMPONENT_REF in gigi when building a 
derived tagged type with discriminant.  That's essentially harmless, but breaks 
the invariant that the type of the first operand of COMPONENT_REF is aggregate.

Tested on x86_64-suse-linux, applied on the mainline.


2012-08-19  Eric Botcazou  <ebotcazou@adacore.com>

	* gcc-interface/decl.c (gnat_to_gnu_entity) <E_Record_Type>: Use proper
	dummy type for the temporary COMPONENT_REF built for a derived tagged
	type with discriminant.


-- 
Eric Botcazou

[-- Attachment #2: p.diff --]
[-- Type: text/x-patch, Size: 1105 bytes --]

Index: gcc-interface/decl.c
===================================================================
--- gcc-interface/decl.c	(revision 190510)
+++ gcc-interface/decl.c	(working copy)
@@ -2988,6 +2988,7 @@ gnat_to_gnu_entity (Entity_Id gnat_entit
 	if (Present (Parent_Subtype (gnat_entity)))
 	  {
 	    Entity_Id gnat_parent = Parent_Subtype (gnat_entity);
+	    tree gnu_dummy_parent_type = make_node (RECORD_TYPE);
 	    tree gnu_parent;
 
 	    /* A major complexity here is that the parent subtype will
@@ -2999,11 +3000,11 @@ gnat_to_gnu_entity (Entity_Id gnat_entit
 	       each of those discriminants to a COMPONENT_REF of the above
 	       dummy parent referencing the corresponding discriminant of the
 	       base type of the parent subtype.  */
-	    gnu_get_parent = build3 (COMPONENT_REF, void_type_node,
+	    gnu_get_parent = build3 (COMPONENT_REF, gnu_dummy_parent_type,
 				     build0 (PLACEHOLDER_EXPR, gnu_type),
 				     build_decl (input_location,
 						 FIELD_DECL, NULL_TREE,
-						 void_type_node),
+						 gnu_dummy_parent_type),
 				     NULL_TREE);
 
 	    if (has_discr)

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2012-08-19 14:08 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-08-19 14:08 [Ada] Fix temporary incorrectly-typed COMPONENT_REF Eric Botcazou

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