[prev in list] [next in list] [prev in thread] [next in thread] 

List:       gcc-patches
Subject:    [Ada] Add missing guard for TYPE_CANONICAL
From:       Eric Botcazou <ebotcazou () adacore ! com>
Date:       2019-06-29 7:32:26
Message-ID: 2563257.V9sFgjSYTM () polaris
[Download RAW message or body]

Otherwise this can crash on types with so-called structural equality.

Tested on x86-64/Linux, applied on all active branches.


2019-06-29  Eric Botcazou  <ebotcazou@adacore.com>

	* gcc-interface/decl.c (set_nonaliased_component_on_array_type): Add
	missing guard for the presence of TYPE_CANONICAL.
	(set_reverse_storage_order_on_array_type): Likewise.

-- 
Eric Botcazou
["p.diff" (p.diff)]

Index: gcc-interface/decl.c
===================================================================
--- gcc-interface/decl.c	(revision 337056)
+++ gcc-interface/decl.c	(revision 337057)
@@ -6144,7 +6144,8 @@ static void
 set_nonaliased_component_on_array_type (tree type)
 {
   TYPE_NONALIASED_COMPONENT (type) = 1;
-  TYPE_NONALIASED_COMPONENT (TYPE_CANONICAL (type)) = 1;
+  if (TYPE_CANONICAL (type))
+    TYPE_NONALIASED_COMPONENT (TYPE_CANONICAL (type)) = 1;
 }
 
 /* Set TYPE_REVERSE_STORAGE_ORDER on an array type built by means of
@@ -6154,7 +6155,8 @@ static void
 set_reverse_storage_order_on_array_type (tree type)
 {
   TYPE_REVERSE_STORAGE_ORDER (type) = 1;
-  TYPE_REVERSE_STORAGE_ORDER (TYPE_CANONICAL (type)) = 1;
+  if (TYPE_CANONICAL (type))
+    TYPE_REVERSE_STORAGE_ORDER (TYPE_CANONICAL (type)) = 1;
 }
 
 /* Return true if DISCR1 and DISCR2 represent the same discriminant.  */


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic