summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorcharlet <charlet@138bc75d-0d04-0410-961f-82ee72b054a4>2014-02-19 11:18:32 +0000
committercharlet <charlet@138bc75d-0d04-0410-961f-82ee72b054a4>2014-02-19 11:18:32 +0000
commit5eb7493a6c50abfb826eb44947b1072d1205dd1a (patch)
tree2f3a0269b92213205395bf264a85a6a357457944
parenta9f5fea7fea29156d23f9dc423c31f6eec957c23 (diff)
downloadppe42-gcc-5eb7493a6c50abfb826eb44947b1072d1205dd1a.tar.gz
ppe42-gcc-5eb7493a6c50abfb826eb44947b1072d1205dd1a.zip
2014-02-19 Hristian Kirtchev <kirtchev@adacore.com>
* sem_ch3.adb (Analyze_Declarations): Analyze a package contract at the end of the private declarations (if applicable), otherwise analyze it and the end of the visible declarations. 2014-02-19 Ed Schonberg <schonberg@adacore.com> * style.adb (Missing_Overriding): If subprogram is an instantiation, place warning on the instance node itself, without mention of the original generic. Do not emit message if explicit Ada version is older than the introduction of the overriding indicator. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@207895 138bc75d-0d04-0410-961f-82ee72b054a4
-rw-r--r--gcc/ada/ChangeLog15
-rw-r--r--gcc/ada/sem_ch3.adb22
-rw-r--r--gcc/ada/style.adb19
3 files changed, 50 insertions, 6 deletions
diff --git a/gcc/ada/ChangeLog b/gcc/ada/ChangeLog
index d801603c624..567aa0d9d30 100644
--- a/gcc/ada/ChangeLog
+++ b/gcc/ada/ChangeLog
@@ -1,3 +1,18 @@
+2014-02-19 Hristian Kirtchev <kirtchev@adacore.com>
+
+ * sem_ch3.adb (Analyze_Declarations): Analyze
+ a package contract at the end of the private declarations (if
+ applicable), otherwise analyze it and the end of the visible
+ declarations.
+
+2014-02-19 Ed Schonberg <schonberg@adacore.com>
+
+ * style.adb (Missing_Overriding): If subprogram is an
+ instantiation, place warning on the instance node itself,
+ without mention of the original generic. Do not emit message
+ if explicit Ada version is older than the introduction of the
+ overriding indicator.
+
2014-02-19 Yannick Moy <moy@adacore.com>
* gnat_rm.texi: Doc clarifications.
diff --git a/gcc/ada/sem_ch3.adb b/gcc/ada/sem_ch3.adb
index daa4f4e51ce..98991e2bbc7 100644
--- a/gcc/ada/sem_ch3.adb
+++ b/gcc/ada/sem_ch3.adb
@@ -2342,10 +2342,24 @@ package body Sem_Ch3 is
if Present (L) then
Context := Parent (L);
- if Nkind (Context) = N_Package_Specification
- and then L = Visible_Declarations (Context)
- then
- Analyze_Package_Contract (Defining_Entity (Context));
+ if Nkind (Context) = N_Package_Specification then
+
+ -- When a package has private declarations, its contract must be
+ -- analyzed at the end of the said declarations. This way both the
+ -- analysis and freeze actions are properly synchronized in case
+ -- of private type use within the contract.
+
+ if L = Private_Declarations (Context) then
+ Analyze_Package_Contract (Defining_Entity (Context));
+
+ -- Otherwise the contract is analyzed at the end of the visible
+ -- declarations.
+
+ elsif L = Visible_Declarations (Context)
+ and then No (Private_Declarations (Context))
+ then
+ Analyze_Package_Contract (Defining_Entity (Context));
+ end if;
elsif Nkind (Context) = N_Package_Body then
In_Package_Body := True;
diff --git a/gcc/ada/style.adb b/gcc/ada/style.adb
index 33e0077e0d2..fffcf360cb4 100644
--- a/gcc/ada/style.adb
+++ b/gcc/ada/style.adb
@@ -29,6 +29,7 @@ with Csets; use Csets;
with Einfo; use Einfo;
with Errout; use Errout;
with Namet; use Namet;
+with Nlists; use Nlists;
with Opt; use Opt;
with Sinfo; use Sinfo;
with Sinput; use Sinput;
@@ -258,6 +259,7 @@ package body Style is
------------------------
procedure Missing_Overriding (N : Node_Id; E : Entity_Id) is
+ Nod : Node_Id;
begin
-- Perform the check on source subprograms and on subprogram instances,
@@ -266,15 +268,28 @@ package body Style is
if Style_Check_Missing_Overriding
and then (Comes_From_Source (N) or else Is_Generic_Instance (E))
- and then Ada_Version >= Ada_2005
+ and then Ada_Version_Explicit >= Ada_2005
then
+ -- If the subprogram is an instantiation, its declaration appears
+ -- within a wrapper package that precedes the instance node. Place
+ -- warning on the node to avoid references to the original generic.
+
+ if Nkind (N) = N_Subprogram_Declaration
+ and then Is_Generic_Instance (E)
+ then
+ Nod := Next (Parent (Parent (List_Containing (N))));
+
+ else
+ Nod := N;
+ end if;
+
if Nkind (N) = N_Subprogram_Body then
Error_Msg_NE -- CODEFIX
("(style) missing OVERRIDING indicator in body of&", N, E);
else
Error_Msg_NE -- CODEFIX
("(style) missing OVERRIDING indicator in declaration of&",
- N, E);
+ Nod, E);
end if;
end if;
end Missing_Overriding;
OpenPOWER on IntegriCloud