Routine Denotes_Same_Object wrongly handled renamings of renamings. In a code like this: B : Integer renames A; C : Integer renames B; names "B" and "C" differ and their renamed object names "A" and "B" differ too. This patch rewrites this routine to literally follow the RM, which fixes the problem with renamings. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * sem_util.adb (Denotes_Same_Object): Explicitly test for node kinds being the same; deal with renamings one-by-one; adjust numbers in references to the Ada RM.