[Ada] Don't expect enumeration literals to be renamings

Message ID 20211025150905.GA346487@adacore.com
State Committed
Commit f977a792721cdaa0d6cbda689b3a6930cf510f7e
Headers
Series [Ada] Don't expect enumeration literals to be renamings |

Commit Message

Pierre-Marie de Rodat Oct. 25, 2021, 3:09 p.m. UTC
  When using cross-reference information to get subprogram effects in
SPARK (i.e. its reads and writes), we were calling Renamed_Object on
enumeration literals. This was pointless but harmless; now it rightly
triggers an assertion failure in developer builds, so avoid that.

Tested on x86_64-pc-linux-gnu, committed on trunk

gcc/ada/

	* lib-xref.adb (Get_Through_Renamings): Exit loop when an
	enumeration literal is found.
  

Patch

diff --git a/gcc/ada/lib-xref.adb b/gcc/ada/lib-xref.adb
--- a/gcc/ada/lib-xref.adb
+++ b/gcc/ada/lib-xref.adb
@@ -481,7 +481,9 @@  package body Lib.Xref is
                            --  e.g. function call, slicing of a function call,
                            --  pointer dereference, etc.
 
-                           if No (Obj) then
+                           if No (Obj)
+                             or else Ekind (Obj) = E_Enumeration_Literal
+                           then
                               return Empty;
                            end if;
                         else