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.
Tested on x86_64-pc-linux-gnu, committed on trunk
2018-05-28 Justin Squirek <squi...@adacore.com>
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.
--- gcc/ada/sem_ch8.adb
+++ 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
--- /dev/null
new file mode 100644
+++ 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;
--- /dev/null
new file mode 100644
+++ gcc/testsuite/gnat.dg/warn15-core.ads
@@ -0,0 +1,4 @@
+with Warn15.Interfaces;
+
+package Warn15.Core is
+end Warn15.Core;
--- /dev/null
new file mode 100644
+++ gcc/testsuite/gnat.dg/warn15-interfaces.ads
@@ -0,0 +1,3 @@
+package Warn15.Interfaces is
+end Warn15.Interfaces;
+
--- /dev/null
new file mode 100644
+++ gcc/testsuite/gnat.dg/warn15.ads
@@ -0,0 +1,2 @@
+package Warn15 is
+end Warn15;