Commit 33931112 by Javier Miranda Committed by Arnaud Charlet

2008-05-20 Javier Miranda <miranda@adacore.com>

	    Ed Schonberg  <schonberg@adacore.com>
	    Hristian Kirtchev  <kirtchev@adacore.com>

	* sem_ch3.adb
	(Analyze_Object_Declaration): Fix over-conservative condition
	restricting use of predefined assignment with tagged types that have
	convention CPP.
	(Analyze_Object_Declaration): Relax the check regarding deferred
	constants declared in scopes other than packages since they can be
	completed with pragma Import.
	Add missing escaping of all-caps word 'CPP' in error messages.
	(Build_Discriminated_Subtype): Do not inherit representation clauses
	from parent type if subtype already carries them, because they are
	inherited earlier during derivation and already include those that may
	come from a partial view.

	* sem_ch9.adb, sem_ch5.adb, sem_ch6.adb (Analyze_Subprogram_Body):
	Check the declarations of a subprogram body for proper deferred
	constant completion.

	* sem_ch7.ads, sem_ch7.adb
	(Inspect_Deferred_Constant_Completion): Moved to sem_util.

From-SVN: r135638
parent de5cd98e
......@@ -870,6 +870,7 @@ package body Sem_Ch5 is
if Present (Decls) then
Analyze_Declarations (Decls);
Check_Completion;
Inspect_Deferred_Constant_Completion (Decls);
end if;
Analyze (HSS);
......
......@@ -1257,10 +1257,10 @@ package body Sem_Ch6 is
procedure Analyze_Subprogram_Body (N : Node_Id) is
Loc : constant Source_Ptr := Sloc (N);
Body_Deleted : constant Boolean := False;
Body_Spec : constant Node_Id := Specification (N);
Body_Id : Entity_Id := Defining_Entity (Body_Spec);
Prev_Id : constant Entity_Id := Current_Entity_In_Scope (Body_Id);
Body_Deleted : constant Boolean := False;
Conformant : Boolean;
HSS : Node_Id;
Missing_Ret : Boolean;
......@@ -1369,7 +1369,8 @@ package body Sem_Ch6 is
Plist : List_Id;
function Is_Inline_Pragma (N : Node_Id) return Boolean;
-- Simple predicate, used twice.
-- True when N is a pragma Inline or Inline_Awlays that applies
-- to this subprogram.
-----------------------
-- Is_Inline_Pragma --
......@@ -2045,6 +2046,7 @@ package body Sem_Ch6 is
-- Check completion, and analyze the statements
Check_Completion;
Inspect_Deferred_Constant_Completion (Declarations (N));
Analyze (HSS);
-- Deal with end of scope processing for the body
......
......@@ -100,12 +100,6 @@ package body Sem_Ch7 is
-- created at the beginning of the corresponding package body and inserted
-- before other body declarations.
procedure Inspect_Deferred_Constant_Completion (Decls : List_Id);
-- Examines the deferred constants in the private part of the package
-- specification, or in a package body. Emits the error message
-- "constant declaration requires initialization expression" if not
-- completed by an Import pragma.
procedure Install_Package_Entity (Id : Entity_Id);
-- Supporting procedure for Install_{Visible,Private}_Declarations.
-- Places one entity on its visibility chain, and recurses on the visible
......@@ -1604,41 +1598,6 @@ package body Sem_Ch7 is
Set_Homonym (Full_Id, H2);
end Exchange_Declarations;
------------------------------------------
-- Inspect_Deferred_Constant_Completion --
------------------------------------------
procedure Inspect_Deferred_Constant_Completion (Decls : List_Id) is
Decl : Node_Id;
begin
Decl := First (Decls);
while Present (Decl) loop
-- Deferred constant signature
if Nkind (Decl) = N_Object_Declaration
and then Constant_Present (Decl)
and then No (Expression (Decl))
-- No need to check internally generated constants
and then Comes_From_Source (Decl)
-- The constant is not completed. A full object declaration
-- or a pragma Import complete a deferred constant.
and then not Has_Completion (Defining_Identifier (Decl))
then
Error_Msg_N
("constant declaration requires initialization expression",
Defining_Identifier (Decl));
end if;
Decl := Next (Decl);
end loop;
end Inspect_Deferred_Constant_Completion;
----------------------------
-- Install_Package_Entity --
----------------------------
......
......@@ -6,7 +6,7 @@
-- --
-- S p e c --
-- --
-- Copyright (C) 1992-2007, Free Software Foundation, Inc. --
-- Copyright (C) 1992-2008, 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- --
......
......@@ -795,6 +795,7 @@ package body Sem_Ch9 is
if Present (Decls) then
Analyze_Declarations (Decls);
Inspect_Deferred_Constant_Completion (Decls);
end if;
if Present (Stats) then
......@@ -1908,6 +1909,7 @@ package body Sem_Ch9 is
Last_E := Last_Entity (Spec_Id);
Analyze_Declarations (Decls);
Inspect_Deferred_Constant_Completion (Decls);
-- For visibility purposes, all entities in the body are private. Set
-- First_Private_Entity accordingly, if there was no private part in the
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment