diff options
author | Simon Buist <buist@adacore.com> | 2019-07-10 09:02:12 +0000 |
---|---|---|
committer | Pierre-Marie de Rodat <pmderodat@gcc.gnu.org> | 2019-07-10 09:02:12 +0000 |
commit | 1ae0159eb46044545610b78fc4ea82427c45c568 (patch) | |
tree | aba954c995b32716e71cf247113d6b8c0e882f66 | |
parent | f35688c95a8ab5d3d6eeee51623d69705a00b115 (diff) | |
download | gcc-1ae0159eb46044545610b78fc4ea82427c45c568.zip gcc-1ae0159eb46044545610b78fc4ea82427c45c568.tar.gz gcc-1ae0159eb46044545610b78fc4ea82427c45c568.tar.bz2 |
[Ada] Entity names are not unique
This patch updates the Unique_Name procedure in order to prefix the
string "ada___" to child units that have a nested subprogram or package,
so that they do not clash with a parent package of the same name.
This is for GNATprove only and does not affect regular compilation.
2019-07-10 Simon Buist <buist@adacore.com>
gcc/ada/
* sem_util.ads (Child_Prefix): New constant.
* sem_util.adb (Unique_Name): Add a special prefix to child
units that have a nested subprogram or package.
From-SVN: r273343
-rw-r--r-- | gcc/ada/ChangeLog | 6 | ||||
-rw-r--r-- | gcc/ada/sem_util.adb | 2 | ||||
-rw-r--r-- | gcc/ada/sem_util.ads | 4 |
3 files changed, 12 insertions, 0 deletions
diff --git a/gcc/ada/ChangeLog b/gcc/ada/ChangeLog index f99b6db..7e609bd 100644 --- a/gcc/ada/ChangeLog +++ b/gcc/ada/ChangeLog @@ -1,3 +1,9 @@ +2019-07-10 Simon Buist <buist@adacore.com> + + * sem_util.ads (Child_Prefix): New constant. + * sem_util.adb (Unique_Name): Add a special prefix to child + units that have a nested subprogram or package. + 2019-07-10 Arnaud Charlet <charlet@adacore.com> * sfn_scan.adb (Scan_SFN_Pragmas): Add pragma Assert. diff --git a/gcc/ada/sem_util.adb b/gcc/ada/sem_util.adb index e011c09..448eea1 100644 --- a/gcc/ada/sem_util.adb +++ b/gcc/ada/sem_util.adb @@ -25781,6 +25781,8 @@ package body Sem_Util is end if; end; + elsif Is_Child_Unit (U) then + return Child_Prefix & Unique_Name (S) & "__" & This_Name; else return Unique_Name (S) & "__" & This_Name; end if; diff --git a/gcc/ada/sem_util.ads b/gcc/ada/sem_util.ads index 3eb9d57..808d693 100644 --- a/gcc/ada/sem_util.ads +++ b/gcc/ada/sem_util.ads @@ -2854,6 +2854,10 @@ package Sem_Util is -- Return a unique name for entity E, which could be used to identify E -- across compilation units. + Child_Prefix : constant String := "ada___"; + -- Prefix for child packages when building a unique name for an entity. It + -- is included here to share between Unique_Name and gnatprove. + function Unit_Is_Visible (U : Entity_Id) return Boolean; -- Determine whether a compilation unit is visible in the current context, -- because there is a with_clause that makes the unit available. Used to |