From 506cd567d1794415f3d28ca6af72c91c4859b77a Mon Sep 17 00:00:00 2001
From: Tristan Gingold <tgingold@free.fr>
Date: Sun, 16 May 2021 10:17:42 +0200
Subject: vhdl-utils: an object alias may not have a subtype indication.  Fix
 #1765

---
 src/vhdl/vhdl-utils.adb | 15 ++++++++++-----
 1 file changed, 10 insertions(+), 5 deletions(-)

(limited to 'src')

diff --git a/src/vhdl/vhdl-utils.adb b/src/vhdl/vhdl-utils.adb
index 578576e1e..46c9bcd72 100644
--- a/src/vhdl/vhdl-utils.adb
+++ b/src/vhdl/vhdl-utils.adb
@@ -1088,11 +1088,16 @@ package body Vhdl.Utils is
             | Iir_Kind_Interface_Variable_Declaration
             | Iir_Kind_Interface_Signal_Declaration
             | Iir_Kind_Object_Alias_Declaration =>
-            if (Get_Kind (Get_Subtype_Indication (Base))
-                = Iir_Kind_Subtype_Attribute)
-            then
-               return True;
-            end if;
+            declare
+               Ind : constant Iir := Get_Subtype_Indication (Base);
+            begin
+               --  Note: an object alias may not have subtype indication.
+               if Ind /= Null_Iir
+                 and then Get_Kind (Ind) = Iir_Kind_Subtype_Attribute
+               then
+                  return True;
+               end if;
+            end;
          when Iir_Kind_Dereference
             | Iir_Kind_Implicit_Dereference =>
             null;
-- 
cgit v1.2.3