diff options
author | Justin Squirek <squirek@adacore.com> | 2019-09-18 08:33:23 +0000 |
---|---|---|
committer | Pierre-Marie de Rodat <pmderodat@gcc.gnu.org> | 2019-09-18 08:33:23 +0000 |
commit | 483af72e4bf2499fdbbf6b6e061318eaa9ba2b2d (patch) | |
tree | 8ff6a4e9492ec071e4d3e391a8c978ce26d929b3 /gcc | |
parent | 1b2f53bb9ad9c903a126bbe5d6c5672550a54c13 (diff) | |
download | gcc-483af72e4bf2499fdbbf6b6e061318eaa9ba2b2d.zip gcc-483af72e4bf2499fdbbf6b6e061318eaa9ba2b2d.tar.gz gcc-483af72e4bf2499fdbbf6b6e061318eaa9ba2b2d.tar.bz2 |
[Ada] Spurious ineffective use_clause warning
This patch fixes an issue whereby expansion of post conditions may lead
to spurious ineffective use_clause warnings when a use type clause is
present in a package specification and a use package clause exists in
the package body on the package containing said type.
2019-09-18 Justin Squirek <squirek@adacore.com>
gcc/ada/
* sem_ch8.adb (Use_One_Type): Add guard to prevent warning on a
reundant use package clause where there is no previous
use_clause in the chain.
gcc/testsuite/
* gnat.dg/warn30.adb, gnat.dg/warn30.ads: New testcase.
From-SVN: r275861
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/ada/ChangeLog | 6 | ||||
-rw-r--r-- | gcc/ada/sem_ch8.adb | 17 | ||||
-rw-r--r-- | gcc/testsuite/ChangeLog | 4 | ||||
-rw-r--r-- | gcc/testsuite/gnat.dg/warn30.adb | 10 | ||||
-rw-r--r-- | gcc/testsuite/gnat.dg/warn30.ads | 6 |
5 files changed, 38 insertions, 5 deletions
diff --git a/gcc/ada/ChangeLog b/gcc/ada/ChangeLog index cbb1e16..6823972 100644 --- a/gcc/ada/ChangeLog +++ b/gcc/ada/ChangeLog @@ -1,5 +1,11 @@ 2019-09-18 Justin Squirek <squirek@adacore.com> + * sem_ch8.adb (Use_One_Type): Add guard to prevent warning on a + reundant use package clause where there is no previous + use_clause in the chain. + +2019-09-18 Justin Squirek <squirek@adacore.com> + * exp_ch4.adb (Expand_N_Type_Conversion): Add calculation of an alternative operand for the purposes of generating accessibility checks. diff --git a/gcc/ada/sem_ch8.adb b/gcc/ada/sem_ch8.adb index a7918da..5d03f835 100644 --- a/gcc/ada/sem_ch8.adb +++ b/gcc/ada/sem_ch8.adb @@ -10337,11 +10337,18 @@ package body Sem_Ch8 is -- The package where T is declared is already used elsif In_Use (Scope (T)) then - Error_Msg_Sloc := - Sloc (Find_Most_Prev (Current_Use_Clause (Scope (T)))); - Error_Msg_NE -- CODEFIX - ("& is already use-visible through package use clause #??", - Id, T); + -- Due to expansion of contracts we could be attempting to issue + -- a spurious warning - so verify there is a previous use clause. + + if Current_Use_Clause (Scope (T)) /= + Find_Most_Prev (Current_Use_Clause (Scope (T))) + then + Error_Msg_Sloc := + Sloc (Find_Most_Prev (Current_Use_Clause (Scope (T)))); + Error_Msg_NE -- CODEFIX + ("& is already use-visible through package use clause #??", + Id, T); + end if; -- The current scope is the package where T is declared diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index bf67722..e9966b2 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,5 +1,9 @@ 2019-09-18 Justin Squirek <squirek@adacore.com> + * gnat.dg/warn30.adb, gnat.dg/warn30.ads: New testcase. + +2019-09-18 Justin Squirek <squirek@adacore.com> + * gnat.dg/access8.adb, gnat.dg/access8_pkg.adb, gnat.dg/access8_pkg.ads: New testcase. diff --git a/gcc/testsuite/gnat.dg/warn30.adb b/gcc/testsuite/gnat.dg/warn30.adb new file mode 100644 index 0000000..841c70e --- /dev/null +++ b/gcc/testsuite/gnat.dg/warn30.adb @@ -0,0 +1,10 @@ +-- { dg-do compile } +-- { dg-options "-gnatwa" } +with Interfaces; use Interfaces; + +package body Warn30 is + procedure Incr (X : in out Interfaces.Integer_64) is + begin + X := X + 1; + end Incr; +end Warn30;
\ No newline at end of file diff --git a/gcc/testsuite/gnat.dg/warn30.ads b/gcc/testsuite/gnat.dg/warn30.ads new file mode 100644 index 0000000..3b60816 --- /dev/null +++ b/gcc/testsuite/gnat.dg/warn30.ads @@ -0,0 +1,6 @@ +with Interfaces; use type Interfaces.Integer_64; + +package Warn30 is + procedure Incr (X : in out Interfaces.Integer_64) with + Post => X = X'Old + 1; +end Warn30; |