From 715a5d519184ef4251d590ef874e2ef493e92ffe Mon Sep 17 00:00:00 2001 From: Hristian Kirtchev Date: Thu, 11 Jan 2018 08:54:21 +0000 Subject: [PATCH] [Ada] Incorrect diagnostic on illegal with clause This patch updates the detection of illegal with clauses which import private child packages to properly detect a grandchild of Ada. ------------ -- Source -- ------------ -- fake.ads package Fake is end Fake; -- fake-ada.ads package Fake.Ada is end Fake.Ada; -- fake-ada-text_io.ads package Fake.Ada.Text_IO is end Fake.Ada.Text_IO; -- fake-ada-text_io-float_io.ads private generic type Num is digits <>; package Fake.Ada.Text_IO.Float_IO is end Fake.Ada.Text_IO.Float_IO; -- fake-float_io.ads private generic type Num is digits <>; package Fake.Float_IO is end Fake.Float_IO; -- main.ads with Fake.Ada.Text_IO.Float_IO; with Fake.Float_IO; package Main is end Main; ---------------------------- -- Compilation and output -- ---------------------------- $ gcc -c main.ads main.ads:1:06: unit in with clause is private child unit main.ads:1:06: current unit must also have parent "Text_IO" main.ads:2:06: unit in with clause is private child unit main.ads:2:06: current unit must also have parent "Fake" 2018-01-11 Hristian Kirtchev gcc/ada/ * sem_ch10.adb (Check_Private_Child_Unit): Ensure that the enclosing scope of package Ada is Standard. From-SVN: r256515 --- gcc/ada/ChangeLog | 5 +++++ gcc/ada/sem_ch10.adb | 4 +++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/gcc/ada/ChangeLog b/gcc/ada/ChangeLog index e81b9bf1ee6..2bc53d7f8dc 100644 --- a/gcc/ada/ChangeLog +++ b/gcc/ada/ChangeLog @@ -1,3 +1,8 @@ +2018-01-11 Hristian Kirtchev + + * sem_ch10.adb (Check_Private_Child_Unit): Ensure that the enclosing + scope of package Ada is Standard. + 2018-01-11 Ed Schonberg * sem_ch13.adb (Replace_Type_Ref): Handle properly reference to a diff --git a/gcc/ada/sem_ch10.adb b/gcc/ada/sem_ch10.adb index 4b828c9f4f0..6c360571668 100644 --- a/gcc/ada/sem_ch10.adb +++ b/gcc/ada/sem_ch10.adb @@ -6,7 +6,7 @@ -- -- -- B o d y -- -- -- --- Copyright (C) 1992-2017, Free Software Foundation, Inc. -- +-- Copyright (C) 1992-2018, Free Software Foundation, Inc. -- -- -- -- GNAT is free software; you can redistribute it and/or modify it under -- -- terms of the GNU General Public License as published by the Free Soft- -- @@ -2995,6 +2995,8 @@ package body Sem_Ch10 is if Ekind (Priv_Child) = E_Generic_Package and then Chars (Priv_Child) in Text_IO_Package_Name and then Chars (Scope (Scope (Priv_Child))) = Name_Ada + and then Scope (Scope (Scope (Priv_Child))) = + Standard_Standard then Error_Msg_NE ("& is a nested package, not a compilation unit", -- 2.30.2