diff mbox series

Small fix to PLACEHOLDER_EXPR handling in loc_list_from_tree_1

Message ID 1710808.rLG1GxIPQk@fomalhaut
State New
Headers show
Series Small fix to PLACEHOLDER_EXPR handling in loc_list_from_tree_1 | expand

Commit Message

Eric Botcazou Dec. 10, 2020, 2:45 p.m. UTC
This case handles the discriminated record types of Ada: the PLACEHOLDER_EXPR 
is the "template" expression for the discriminant in the type definition. Now 
for some components, typically arrays whose upper bound is the discriminant, 
the compiler creates a local subtype for the component, so the code needs to 
be able to deal with this nested type.

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


2020-12-10  Eric Botcazou  <ebotcazou@adacore.com>

	* dwarf2out.c (loc_list_from_tree_1) <PLACEHOLDER_EXPR>: Deal with
	a nested context type
diff mbox series

Patch

diff --git a/gcc/dwarf2out.c b/gcc/dwarf2out.c
index 7b340baf422..0baa056447c 100644
--- a/gcc/dwarf2out.c
+++ b/gcc/dwarf2out.c
@@ -18245,10 +18245,11 @@  loc_list_from_tree_1 (tree loc, int want_address,
     case PLACEHOLDER_EXPR:
       /* This case involves extracting fields from an object to determine the
 	 position of other fields. It is supposed to appear only as the first
-         operand of COMPONENT_REF nodes and to reference precisely the type
-         that the context allows.  */
+	 operand of COMPONENT_REF nodes and to reference precisely the type
+	 that the context allows or its enclosing type.  */
       if (context != NULL
-          && TREE_TYPE (loc) == context->context_type
+	  && (TREE_TYPE (loc) == context->context_type
+	      || TREE_TYPE (loc) == TYPE_CONTEXT (context->context_type))
 	  && want_address >= 1)
 	{
 	  if (dwarf_version >= 3 || !dwarf_strict)