From aa76fac75101cd8694cedce1bee6a79f1f465130 Mon Sep 17 00:00:00 2001 From: Justin Squirek Date: Mon, 28 May 2018 08:53:00 +0000 Subject: [PATCH] [Ada] Misleading warning on unresolvable package name This patch fixes an issue whereby the compiler misidentified a package name containing the name of a standard runtime package as said package - leading to and improper error message prompting the user to "With" a package already in scope. 2018-05-28 Justin Squirek gcc/ada/ * sem_ch8.adb (Find_Expanded_Name): Add extra guard to make sure the misresolved package name is not a case of mistaken identity. gcc/testsuite/ * gnat.dg/warn15-core-main.adb, gnat.dg/warn15-core.ads, gnat.dg/warn15-interfaces.ads, gnat.dg/warn15.ads: New testcase. From-SVN: r260817 --- gcc/ada/ChangeLog | 5 +++++ gcc/ada/sem_ch8.adb | 6 +++++- gcc/testsuite/ChangeLog | 5 +++++ gcc/testsuite/gnat.dg/warn15-core-main.adb | 9 +++++++++ gcc/testsuite/gnat.dg/warn15-core.ads | 4 ++++ gcc/testsuite/gnat.dg/warn15-interfaces.ads | 3 +++ gcc/testsuite/gnat.dg/warn15.ads | 2 ++ 7 files changed, 33 insertions(+), 1 deletion(-) create mode 100644 gcc/testsuite/gnat.dg/warn15-core-main.adb create mode 100644 gcc/testsuite/gnat.dg/warn15-core.ads create mode 100644 gcc/testsuite/gnat.dg/warn15-interfaces.ads create mode 100644 gcc/testsuite/gnat.dg/warn15.ads diff --git a/gcc/ada/ChangeLog b/gcc/ada/ChangeLog index b1ccf573b06..10b2c21fa38 100644 --- a/gcc/ada/ChangeLog +++ b/gcc/ada/ChangeLog @@ -1,3 +1,8 @@ +2018-05-28 Justin Squirek + + * sem_ch8.adb (Find_Expanded_Name): Add extra guard to make sure the + misresolved package name is not a case of mistaken identity. + 2018-05-28 Yannick Moy * sem_res.adb (Resolve_Range): Re-resolve the low bound of a range in diff --git a/gcc/ada/sem_ch8.adb b/gcc/ada/sem_ch8.adb index 382f12dad7b..1716cc47666 100644 --- a/gcc/ada/sem_ch8.adb +++ b/gcc/ada/sem_ch8.adb @@ -6336,7 +6336,11 @@ package body Sem_Ch8 is -- If this is a selection from Ada, System or Interfaces, then -- we assume a missing with for the corresponding package. - if Is_Known_Unit (N) then + if Is_Known_Unit (N) + and then not (Present (Entity (Prefix (N))) + and then Scope (Entity (Prefix (N))) /= + Standard_Standard) + then if not Error_Posted (N) then Error_Msg_Node_2 := Selector; Error_Msg_N -- CODEFIX diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 0ec5cee07ae..8c3f007bc61 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2018-05-28 Justin Squirek + + * gnat.dg/warn15-core-main.adb, gnat.dg/warn15-core.ads, + gnat.dg/warn15-interfaces.ads, gnat.dg/warn15.ads: New testcase. + 2018-05-27 Steven G. Kargl * gfortran.dg/data_stmt_pointer.f90: new test. diff --git a/gcc/testsuite/gnat.dg/warn15-core-main.adb b/gcc/testsuite/gnat.dg/warn15-core-main.adb new file mode 100644 index 00000000000..9caa1b9d364 --- /dev/null +++ b/gcc/testsuite/gnat.dg/warn15-core-main.adb @@ -0,0 +1,9 @@ +-- { dg-do compile } + +with Interfaces.C; + +procedure Warn15.Core.Main is + use type Interfaces.C.unsigned; -- { dg-error "\"C\" not declared in \"Interfaces\"" } +begin + null; +end Warn15.Core.Main; diff --git a/gcc/testsuite/gnat.dg/warn15-core.ads b/gcc/testsuite/gnat.dg/warn15-core.ads new file mode 100644 index 00000000000..eadcc3835e2 --- /dev/null +++ b/gcc/testsuite/gnat.dg/warn15-core.ads @@ -0,0 +1,4 @@ +with Warn15.Interfaces; + +package Warn15.Core is +end Warn15.Core; diff --git a/gcc/testsuite/gnat.dg/warn15-interfaces.ads b/gcc/testsuite/gnat.dg/warn15-interfaces.ads new file mode 100644 index 00000000000..fa8f46a4256 --- /dev/null +++ b/gcc/testsuite/gnat.dg/warn15-interfaces.ads @@ -0,0 +1,3 @@ +package Warn15.Interfaces is +end Warn15.Interfaces; + diff --git a/gcc/testsuite/gnat.dg/warn15.ads b/gcc/testsuite/gnat.dg/warn15.ads new file mode 100644 index 00000000000..4b011b4a758 --- /dev/null +++ b/gcc/testsuite/gnat.dg/warn15.ads @@ -0,0 +1,2 @@ +package Warn15 is +end Warn15; -- 2.30.2