diff options
author | Justin Squirek <squirek@adacore.com> | 2018-11-14 11:41:09 +0000 |
---|---|---|
committer | Pierre-Marie de Rodat <pmderodat@gcc.gnu.org> | 2018-11-14 11:41:09 +0000 |
commit | 7f0f5de19093d4550b48d3a26f1869e8def3f7e8 (patch) | |
tree | b276ce52e71a384ada6830fbeffcd3292664a52e | |
parent | 39b763713cdc656911944ea56225f77e9f27d4e3 (diff) | |
download | gcc-7f0f5de19093d4550b48d3a26f1869e8def3f7e8.zip gcc-7f0f5de19093d4550b48d3a26f1869e8def3f7e8.tar.gz gcc-7f0f5de19093d4550b48d3a26f1869e8def3f7e8.tar.bz2 |
[Ada] Visibility error on used enumerated type
This patch fixes an issue whereby the freezing of a nested package
containing an enumerated type declaration would cause visibility errors
on literals of such type when a use_all_type_clause for it appears
within the same declarative region.
2018-11-14 Justin Squirek <squirek@adacore.com>
gcc/ada/
* sem_ch7.adb (Uninstall_Declarations): Add conditional to avoid
uninstalling potential visibility during freezing on enumeration
literals.
gcc/testsuite/
* gnat.dg/enum5.adb: New testcase.
From-SVN: r266119
-rw-r--r-- | gcc/ada/ChangeLog | 6 | ||||
-rw-r--r-- | gcc/ada/sem_ch7.adb | 15 | ||||
-rw-r--r-- | gcc/testsuite/ChangeLog | 4 | ||||
-rw-r--r-- | gcc/testsuite/gnat.dg/enum5.adb | 11 |
4 files changed, 34 insertions, 2 deletions
diff --git a/gcc/ada/ChangeLog b/gcc/ada/ChangeLog index dbd7ee3..2f23526 100644 --- a/gcc/ada/ChangeLog +++ b/gcc/ada/ChangeLog @@ -1,3 +1,9 @@ +2018-11-14 Justin Squirek <squirek@adacore.com> + + * sem_ch7.adb (Uninstall_Declarations): Add conditional to avoid + uninstalling potential visibility during freezing on enumeration + literals. + 2018-11-14 Jerome Lambourg <lambourg@adacore.com> * env.c: Do not include crt_externs.h on iOS, as it does not diff --git a/gcc/ada/sem_ch7.adb b/gcc/ada/sem_ch7.adb index 6e9f531..1c732b4 100644 --- a/gcc/ada/sem_ch7.adb +++ b/gcc/ada/sem_ch7.adb @@ -2820,8 +2820,9 @@ package body Sem_Ch7 is -- a) If the entity is an operator, it may be a primitive operator of -- a type for which there is a visible use-type clause. - -- b) for other entities, their use-visibility is determined by a - -- visible use clause for the package itself. For a generic instance, + -- b) For other entities, their use-visibility is determined by a + -- visible use clause for the package itself or a use-all-type clause + -- applied directly to the entity's type. For a generic instance, -- the instantiation of the formals appears in the visible part, -- but the formals are private and remain so. @@ -2854,6 +2855,16 @@ package body Sem_Ch7 is Set_Is_Potentially_Use_Visible (Id); end if; + -- We need to avoid incorrectly marking enumeration literals + -- as non-visible when a visible use-all-type clause is in effect. + + elsif Type_In_Use (Etype (Id)) + and then Nkind (Current_Use_Clause (Etype (Id))) = + N_Use_Type_Clause + and then All_Present (Current_Use_Clause (Etype (Id))) + then + null; + else Set_Is_Potentially_Use_Visible (Id, False); end if; diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 3fddcce..2103f49 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,7 @@ +2018-11-14 Justin Squirek <squirek@adacore.com> + + * gnat.dg/enum5.adb: New testcase. + 2018-11-14 Hristian Kirtchev <kirtchev@adacore.com> * gnat.dg/bip_exception.adb, gnat.dg/bip_exception.ads, diff --git a/gcc/testsuite/gnat.dg/enum5.adb b/gcc/testsuite/gnat.dg/enum5.adb new file mode 100644 index 0000000..2e2694a --- /dev/null +++ b/gcc/testsuite/gnat.dg/enum5.adb @@ -0,0 +1,11 @@ +-- { dg-do compile } + +procedure Enum5 is + package Pack1 is + type Enum is (A, B, C); + end; + E1 : Pack1.Enum; + use all type Pack1.Enum; +begin + E1 := A; +end; |