Commit 88b32fc3 by Bob Duff Committed by Arnaud Charlet

g-awk.adb (Default_Session, [...]): Compile this file in Ada 95 mode, because it…

g-awk.adb (Default_Session, [...]): Compile this file in Ada 95 mode, because it violates the new rules for AI-318.

2006-10-31  Bob Duff  <duff@adacore.com>
	    Robert Dewar  <dewar@adacore.com>
	    Ed Schonberg  <schonberg@adacore.com>

	* g-awk.adb (Default_Session, Current_Session): Compile this file in
	Ada 95 mode, because it violates the new rules for AI-318.

	* g-awk.ads: Use overloaded subprograms in every case where we used to
	have a default of Current_Session. This makes the code closer to be
	correct for both Ada 95 and 2005.

	* g-moreex.adb (Occurrence): Turn off warnings for illegal-in-Ada-2005
	code, relying on the fact that the compiler generates a warning
	instead of an error in -gnatg mode.

	* lib-xref.ads (Xref_Entity_Letters): Add entry for new
	E_Return_Statement entity kind.
	Add an entry for E_Incomplete_Subtype in Xref_Entity_Letters.

	* par.adb (P_Interface_Type_Definition): Addition of one formal to
	report an error if the reserved word abstract has been previously found.
	(SS_End_Type): Add E_Return for new extended_return_statement syntax.
        
        * par-ch4.adb (P_Aggregate_Or_Paren_Expr): Improve message for
	parenthesized range attribute usage
	(P_Expression_No_Right_Paren): Add missing comment about error recovery.

	* par-ch6.adb (P_Return_Object_Declaration): AI-318: Allow "constant"
	in the syntax for extended_return_statement. This is not in the latest
	RM, but the ARG is expected to issue an AI allowing this.
	(P_Return_Subtype_Indication,P_Return_Subtype_Indication): Remove
	N_Return_Object_Declaration. We now use N_Object_Declaration instead.
	(P_Return_Object_Declaration, P_Return_Subtype_Indication,
	P_Return_Statement): Parse the new syntax for extended_return_statement.

	* par-endh.adb (Check_End, Output_End_Deleted, Output_End_Expected,
	Output_End_Missing): Add error-recovery code for the new
	extended_return_statement syntax; that is, the new E_Return entry on
	the scope stack.

	* s-auxdec-vms_64.ads, s-auxdec.ads (AST_Handler): Change type from
	limited to nonlimited, because otherwise we violate the new Ada 2005
	rules about returning limited types in function Create_AST_Handler in
	s-asthan.adb.

	* sem.adb (Analyze): Add cases for new node kinds
	N_Extended_Return_Statement and N_Return_Object_Declaration.

	* sem_aggr.adb (Aggregate_Constraint_Checks): Verify that component
	type is in the same category as type of context before applying check,
	to prevent anomalies in instantiations.
	(Resolve_Aggregate): Remove test for limited components in aggregates.
	It's unnecessary in Ada 95, because if it has limited components, then
	it must be limited. It's wrong in Ada 2005, because limited aggregates
	are now allowed.
	(Resolve_Record_Aggregate): Move check for limited types later, because
	OK_For_Limited_Init requires its argument to have been resolved.
	(Get_Value): When copying the component default expression for a
	defaulted association in an aggregate, use the sloc of the aggregate
	and not that of the original expression, to prevent spurious
	elaboration errors, when the expression includes function calls.
	(Check_Non_Limited_Type): Correct code for AI-287, extension aggregates
	were missing. We also didn't handle qualified expressions. Now also
	allow function calls. Use new common routine OK_For_Limited_Init.
	(Resolve_Extension_Aggregate): Minor fix to bad error message (started
	with space can upper case letter).

        * sem_ch3.ads, sem_ch3.adb (Create_Constrained_Components): Set
	Has_Static_Discriminants flag
        (Record_Type_Declaration): Diagnose an attempt to declare an interface
        type with discriminants.
        (Process_Range_Expr_In_Decl): Do validity checks on range
	(Build_Discriminant_Constraints): Use updated form of
	Denotes_Discriminant.
	(Process_Subtype): If the subtype is a private subtype whose full view
	is a concurrent subtype, introduce an itype reference to prevent scope
	anomalies in gigi.
	(Build_Derived_Record_Type, Collect_Interface_Primitives,
	Record_Type_Declaration):  The functionality of the subprograms
	Collect_Abstract_Interfaces and Collect_All_Abstract_Interfaces
	is now performed by a single routine.
	(Build_Derived_Record_Type): If the type definition includes an explicit
	indication of limitedness, then the type must be marked as limited here
	to ensure that any access discriminants will not be treated as having
	a local anonymous access type.
	(Check_Abstract_Overriding): Issue a detailed error message when an
	abstract subprogram was not overridden due to incorrect mode of its
	first parameter.
	(Analyze_Private_Extension_Declaration): Add support for the analysis of
	synchronized private extension declarations. Verify that the ancestor is
	a limited or synchronized interface or in the generic case, the ancestor
	is a tagged limited type or synchronized interface and all progenitors
	are either limited or synchronized interfaces.
	Derived_Type_Declaration): Check for presence of private extension when
	dealing with synchronized formal derived types.
	Process_Full_View): Enchance the check done on the usage of "limited" by
	testing whether the private view is synchronized.
	Verify that a synchronized private view is completed by a protected or
	task type.
	(OK_For_Limited_Init_In_05): New function.
	(Analyze_Object_Declaration): Move check for limited types later,
	because OK_For_Limited_Init requires its argument to have been resolved.
	Add -gnatd.l --Use Ada 95 semantics for limited function returns,
	in order to alleviate the upward compatibility introduced by AI-318.
	(Constrain_Corresponding_Record): If the constraint is for a component
	subtype, mark the itype as frozen, to avoid out-of-scope references to
	discriminants in the back-end.
	(Collect_Implemented_Interfaces): Protect the recursive algorithm of
	this subprogram against wrong sources.
	(Get_Discr_Value, Is_Discriminant): Handle properly references to a
	discriminant of limited type completed with a protected type, when the
	discriminant is used to constrain a private component of the type, and
	expansion is disabled.
	(Find_Type_Of_Object): Do not treat a return subtype that is an
	anonymous subtype as a local_anonymous_type, because its accessibility
	level is the return type of the enclosing function.
	(Check_Initialization): In -gnatg mode, turn the error "cannot
	initialize entities of limited type" into a warning.
	(OK_For_Limited_Init): Return true for generated nodes, since it
	sometimes violates the legality rules.
	(Make_Incomplete_Declaration): If the type for which an incomplete
	declaration is created happens to be the currently visible entity,
	preserve the homonym chain when removing it from visibility.
	(Check_Conventions): Add support for Ada 2005 (AI-430): Conventions of
	inherited subprograms.
	(Access_Definition): If this is an access to function that is the return
	type of an access_to_function definition, context is a type declaration
	and the scope of the anonymous type is the current one.
	(Analyze_Subtype_Declaration): Add the defining identifier of a regular
	incomplete subtype to the set of private dependents of the original
	incomplete type.
	(Constrain_Discriminated_Type): Emit an error message whenever an
	incomplete subtype is being constrained.
	(Process_Incomplete_Dependents): Transform an incomplete subtype into a
	corresponding subtype of the full view of the original incomplete type.
	(Check_Incomplete): Properly detect invalid usage of incomplete types
	and subtypes.

From-SVN: r118273
parent bae7876b
......@@ -6,7 +6,7 @@
-- --
-- B o d y --
-- --
-- Copyright (C) 2000-2005, AdaCore --
-- Copyright (C) 2000-2006, AdaCore --
-- --
-- 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- --
......@@ -40,20 +40,39 @@ package body GNAT.Most_Recent_Exception is
-- Occurrence --
----------------
function Occurrence
return Ada.Exceptions.Exception_Occurrence
is
function Occurrence return Ada.Exceptions.Exception_Occurrence is
EOA : constant Ada.Exceptions.Exception_Occurrence_Access :=
GNAT.Most_Recent_Exception.Occurrence_Access;
use type Ada.Exceptions.Exception_Occurrence_Access;
begin
pragma Warnings (Off);
if EOA = null then
return Ada.Exceptions.Null_Occurrence;
else
return EOA.all;
end if;
pragma Warnings (On);
-- ???Note that both of the above return statements violate the Ada
-- 2005 rule forbidding copying of limited objects (see RM-7.5(2.8/2)).
-- When compiled with -gnatg, the compiler gives a warning instead of
-- an error, so we can turn it off.
-- To fix this, remove the pragmas Warnings above, and use the following
-- code. We can't do that yet, because AI-318 is not yet implemented.
--
-- return Result : Ada.Exceptions.Exception_Occurrence do
-- if EOA = null then
-- Ada.Exceptions.Save_Occurrence
-- (Target => Result,
-- Source => Ada.Exceptions.Null_Occurrence);
-- else
-- Ada.Exceptions.Save_Occurrence
-- (Target => Result,
-- Source => EOA.all);
-- end if;
-- end return;
end Occurrence;
-----------------------
......
......@@ -6,7 +6,7 @@
-- --
-- S p e c --
-- --
-- Copyright (C) 1998-2005, Free Software Foundation, Inc. --
-- Copyright (C) 1998-2006, 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- --
......@@ -441,30 +441,32 @@ package Lib.Xref is
E_Limited_Private_Subtype => '+',
E_Incomplete_Type => '+',
E_Incomplete_Subtype => '+',
E_Task_Type => 'T',
E_Task_Subtype => 'T',
E_Protected_Type => 'W',
E_Protected_Subtype => 'W',
E_Protected_Subtype => 'W',
E_Exception_Type => ' ',
E_Subprogram_Type => ' ',
E_Enumeration_Literal => 'n',
E_Function => 'V',
E_Operator => 'V',
E_Operator => 'V',
E_Procedure => 'U',
E_Entry => 'Y',
E_Entry_Family => 'Y',
E_Block => 'q',
E_Entry_Index_Parameter => '*',
E_Entry_Index_Parameter => '*',
E_Exception => 'X',
E_Generic_Function => 'v',
E_Generic_Package => 'k',
E_Generic_Procedure => 'u',
E_Label => 'L',
E_Label => 'L',
E_Loop => 'l',
E_Return_Statement => ' ',
E_Package => 'K',
-- The following entities are not ones to which we gather
......
......@@ -6,7 +6,7 @@
-- --
-- B o d y --
-- --
-- Copyright (C) 1992-2005, Free Software Foundation, Inc. --
-- Copyright (C) 1992-2006, 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- --
......@@ -1247,12 +1247,12 @@ package body Ch4 is
-- Expression case
elsif Token = Tok_Right_Paren or else Token in Token_Class_Eterm then
if Nkind (Expr_Node) = N_Attribute_Reference
and then Attribute_Name (Expr_Node) = Name_Range
then
Bad_Range_Attribute (Sloc (Expr_Node));
return Error;
Error_Msg
("|parentheses not allowed for range attribute", Lparen_Sloc);
return Expr_Node;
end if;
-- Bump paren count of expression, note that if the paren count
......@@ -1563,6 +1563,8 @@ package body Ch4 is
-- called in all contexts where a right parenthesis cannot legitimately
-- follow an expression.
-- Error recovery: can raise Error_Resync
function P_Expression_No_Right_Paren return Node_Id is
begin
return No_Right_Paren (P_Expression);
......
......@@ -37,6 +37,12 @@ package body Ch6 is
function P_Defining_Designator return Node_Id;
function P_Defining_Operator_Symbol return Node_Id;
function P_Return_Object_Declaration return Node_Id;
procedure P_Return_Subtype_Indication (Decl_Node : Node_Id);
-- Decl_Node is a N_Object_Declaration.
-- Set the Null_Exclusion_Present and Object_Definition fields of
-- Decl_Node.
procedure Check_Junk_Semicolon_Before_Return;
......@@ -1285,36 +1291,209 @@ package body Ch6 is
-- 6.5 Return Statement --
---------------------------
-- SIMPLE_RETURN_STATEMENT ::= return [EXPRESSION];
--
-- EXTENDED_RETURN_STATEMENT ::=
-- return DEFINING_IDENTIFIER : [aliased] RETURN_SUBTYPE_INDICATION
-- [:= EXPRESSION] [do
-- HANDLED_SEQUENCE_OF_STATEMENTS
-- end return];
--
-- RETURN_SUBTYPE_INDICATION ::= SUBTYPE_INDICATION | ACCESS_DEFINITION
-- RETURN_STATEMENT ::= return [EXPRESSION];
-- The caller has checked that the initial token is RETURN
-- Error recovery: can raise Error_Resync
procedure P_Return_Subtype_Indication (Decl_Node : Node_Id) is
-- Note: We don't need to check Ada_Version here, because this is
-- only called in >= Ada 2005 cases anyway.
Not_Null_Present : constant Boolean := P_Null_Exclusion;
begin
Set_Null_Exclusion_Present (Decl_Node, Not_Null_Present);
if Token = Tok_Access then
Set_Object_Definition
(Decl_Node, P_Access_Definition (Not_Null_Present));
else
Set_Object_Definition
(Decl_Node, P_Subtype_Indication (Not_Null_Present));
end if;
end P_Return_Subtype_Indication;
-- Error recovery: can raise Error_Resync
function P_Return_Object_Declaration return Node_Id is
Return_Obj : Node_Id;
Decl_Node : Node_Id;
begin
Return_Obj := Token_Node;
Change_Identifier_To_Defining_Identifier (Return_Obj);
Decl_Node := New_Node (N_Object_Declaration, Token_Ptr);
Set_Defining_Identifier (Decl_Node, Return_Obj);
Scan; -- past identifier
Scan; -- past :
-- First an error check, if we have two identifiers in a row, a likely
-- possibility is that the first of the identifiers is an incorrectly
-- spelled keyword. See similar check in P_Identifier_Declarations.
if Token = Tok_Identifier then
declare
SS : Saved_Scan_State;
I2 : Boolean;
begin
Save_Scan_State (SS);
Scan; -- past initial identifier
I2 := (Token = Tok_Identifier);
Restore_Scan_State (SS);
if I2
and then
(Bad_Spelling_Of (Tok_Access) or else
Bad_Spelling_Of (Tok_Aliased) or else
Bad_Spelling_Of (Tok_Constant))
then
null;
end if;
end;
end if;
-- We allow "constant" here (as in "return Result : constant
-- T..."). This is not in the latest RM, but the ARG is considering an
-- AI on the subject (see AI05-0015-1), which we expect to be approved.
if Token = Tok_Constant then
Scan; -- past CONSTANT
Set_Constant_Present (Decl_Node);
if Token = Tok_Aliased then
Error_Msg_SC ("ALIASED should be before CONSTANT");
Scan; -- past ALIASED
Set_Aliased_Present (Decl_Node);
end if;
elsif Token = Tok_Aliased then
Scan; -- past ALIASED
Set_Aliased_Present (Decl_Node);
if Token = Tok_Constant then
Scan; -- past CONSTANT
Set_Constant_Present (Decl_Node);
end if;
end if;
P_Return_Subtype_Indication (Decl_Node);
if Token = Tok_Colon_Equal then
Scan; -- past :=
Set_Expression (Decl_Node, P_Expression_No_Right_Paren);
end if;
return Decl_Node;
end P_Return_Object_Declaration;
-- Error recovery: can raise Error_Resync
function P_Return_Statement return Node_Id is
-- The caller has checked that the initial token is RETURN
function Is_Simple return Boolean;
-- Scan state is just after RETURN (and is left that way).
-- Determine whether this is a simple or extended return statement
-- by looking ahead for "identifier :", which implies extended.
---------------
-- Is_Simple --
---------------
function Is_Simple return Boolean is
Scan_State : Saved_Scan_State;
Result : Boolean := True;
begin
if Token = Tok_Identifier then
Save_Scan_State (Scan_State); -- at identifier
Scan; -- past identifier
if Token = Tok_Colon then
Result := False; -- It's an extended_return_statement.
end if;
Restore_Scan_State (Scan_State); -- to identifier
end if;
return Result;
end Is_Simple;
Return_Sloc : constant Source_Ptr := Token_Ptr;
Return_Node : Node_Id;
-- Start of processing for P_Return_Statement
begin
Return_Node := New_Node (N_Return_Statement, Token_Ptr);
Scan; -- past RETURN
-- Sloc points to RETURN
-- Expression (Op3)
-- Simple_return_statement, no expression, return an N_Return_Statement
-- node with the expression field left Empty.
Scan; -- past RETURN
if Token = Tok_Semicolon then
Scan; -- past ;
Return_Node := New_Node (N_Return_Statement, Return_Sloc);
if Token /= Tok_Semicolon then
-- Non-simple case
-- If no semicolon, then scan an expression, except that
-- we avoid trying to scan an expression if we are at an
else
-- Simple_return_statement with expression
-- We avoid trying to scan an expression if we are at an
-- expression terminator since in that case the best error
-- message is probably that we have a missing semicolon.
if Token not in Token_Class_Eterm then
Set_Expression (Return_Node, P_Expression_No_Right_Paren);
if Is_Simple then
Return_Node := New_Node (N_Return_Statement, Return_Sloc);
if Token not in Token_Class_Eterm then
Set_Expression (Return_Node, P_Expression_No_Right_Paren);
end if;
-- Extended_return_statement (Ada 2005 only -- AI-318):
else
if Ada_Version < Ada_05 then
Error_Msg_SP
(" extended_return_statement is an Ada 2005 extension");
Error_Msg_SP ("\unit must be compiled with -gnat05 switch");
end if;
Return_Node := New_Node (N_Extended_Return_Statement, Return_Sloc);
Set_Return_Object_Declarations
(Return_Node, New_List (P_Return_Object_Declaration));
if Token = Tok_Do then
Push_Scope_Stack;
Scope.Table (Scope.Last).Etyp := E_Return;
Scope.Table (Scope.Last).Ecol := Start_Column;
Scope.Table (Scope.Last).Sloc := Return_Sloc;
Scan; -- past DO
Set_Handled_Statement_Sequence
(Return_Node, P_Handled_Sequence_Of_Statements);
End_Statements;
-- Do we need to handle Error_Resync here???
end if;
end if;
TF_Semicolon;
end if;
TF_Semicolon;
return Return_Node;
end P_Return_Statement;
......
......@@ -219,6 +219,10 @@ package body Endh is
End_Type := E_Record;
Scan; -- past RECORD
elsif Token = Tok_Return then
End_Type := E_Return;
Scan; -- past RETURN
elsif Token = Tok_Select then
End_Type := E_Select;
Scan; -- past SELECT
......@@ -800,6 +804,9 @@ package body Endh is
elsif End_Type = E_Record then
Error_Msg_SC ("no RECORD for this `END RECORD`!");
elsif End_Type = E_Return then
Error_Msg_SC ("no RETURN for this `END RETURN`!");
elsif End_Type = E_Select then
Error_Msg_SC ("no SELECT for this `END SELECT`!");
......@@ -859,6 +866,10 @@ package body Endh is
Error_Msg_SC
("`END RECORD;` expected@ for RECORD#!");
elsif End_Type = E_Return then
Error_Msg_SC
("`END RETURN;` expected@ for RETURN#!");
elsif End_Type = E_Select then
Error_Msg_SC
("`END SELECT;` expected@ for SELECT#!");
......@@ -924,6 +935,10 @@ package body Endh is
Error_Msg_SC
("missing `END RECORD;` for RECORD#!");
elsif End_Type = E_Return then
Error_Msg_SC
("missing `END RETURN;` for RETURN#!");
elsif End_Type = E_Select then
Error_Msg_BC
("missing `END SELECT;` for SELECT#!");
......
......@@ -6,7 +6,7 @@
-- --
-- B o d y --
-- --
-- Copyright (C) 1992-2005, Free Software Foundation, Inc. --
-- Copyright (C) 1992-2006, 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- --
......@@ -433,6 +433,7 @@ is
E_If, -- END IF;
E_Loop, -- END LOOP;
E_Record, -- END RECORD;
E_Return, -- END RETURN;
E_Select, -- END SELECT;
E_Name, -- END [name];
E_Suspicious_Is, -- END [name]; (case of suspicious IS)
......@@ -604,13 +605,16 @@ is
-- declaration of this type for details.
function P_Interface_Type_Definition
(Is_Synchronized : Boolean) return Node_Id;
-- Ada 2005 (AI-251): Parse the interface type definition part. The
-- parameter Is_Synchronized is True in case of task interfaces,
-- protected interfaces, and synchronized interfaces; it is used to
-- generate a record_definition node. In the rest of cases (limited
-- interfaces and interfaces) we generate a record_definition node if
-- the list of interfaces is empty; otherwise we generate a
(Abstract_Present : Boolean;
Is_Synchronized : Boolean) return Node_Id;
-- Ada 2005 (AI-251): Parse the interface type definition part. Abstract
-- Present indicates if the reserved word "abstract" has been previously
-- found. It is used to report an error message because interface types
-- are by definition abstract tagged. Is_Synchronized is True in case of
-- task interfaces, protected interfaces, and synchronized interfaces;
-- it is used to generate a record_definition node. In the rest of cases
-- (limited interfaces and interfaces) we generate a record_definition
-- node if the list of interfaces is empty; otherwise we generate a
-- derived_type_definition node (the first interface in this list is the
-- ancestor interface).
......@@ -1349,7 +1353,7 @@ begin
Uname : constant String :=
Get_Name_String
(Unit_Name (Current_Source_Unit));
Name : String (1 .. Uname'Length - 2);
Name : String (1 .. Uname'Length - 2);
begin
-- Because Unit_Name includes "%s" or "%b", we need to
......
......@@ -6,7 +6,7 @@
-- --
-- S p e c --
-- --
-- Copyright (C) 1996-2005 Free Software Foundation, Inc. --
-- Copyright (C) 1996-2006 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- --
......@@ -76,7 +76,7 @@ package System.Aux_DEC is
type Largest_Integer is range Min_Int .. Max_Int;
type AST_Handler is limited private;
type AST_Handler is private;
No_AST_Handler : constant AST_Handler;
......@@ -298,17 +298,17 @@ package System.Aux_DEC is
procedure Clear_Interlocked
(Bit : in out Boolean;
Old_Value : out Boolean;
Retry_Count : in Natural;
Retry_Count : Natural;
Success_Flag : out Boolean);
procedure Set_Interlocked
(Bit : in out Boolean;
Old_Value : out Boolean;
Retry_Count : in Natural;
Retry_Count : Natural;
Success_Flag : out Boolean);
procedure Add_Interlocked
(Addend : in Short_Integer;
(Addend : Short_Integer;
Augend : in out Aligned_Word;
Sign : out Integer);
......@@ -332,67 +332,67 @@ package System.Aux_DEC is
procedure Add_Atomic
(To : in out Aligned_Integer;
Amount : in Integer);
Amount : Integer);
procedure Add_Atomic
(To : in out Aligned_Integer;
Amount : in Integer;
Retry_Count : in Natural;
Amount : Integer;
Retry_Count : Natural;
Old_Value : out Integer;
Success_Flag : out Boolean);
procedure Add_Atomic
(To : in out Aligned_Long_Integer;
Amount : in Long_Integer);
Amount : Long_Integer);
procedure Add_Atomic
(To : in out Aligned_Long_Integer;
Amount : in Long_Integer;
Retry_Count : in Natural;
Amount : Long_Integer;
Retry_Count : Natural;
Old_Value : out Long_Integer;
Success_Flag : out Boolean);
procedure And_Atomic
(To : in out Aligned_Integer;
From : in Integer);
From : Integer);
procedure And_Atomic
(To : in out Aligned_Integer;
From : in Integer;
Retry_Count : in Natural;
From : Integer;
Retry_Count : Natural;
Old_Value : out Integer;
Success_Flag : out Boolean);
procedure And_Atomic
(To : in out Aligned_Long_Integer;
From : in Long_Integer);
From : Long_Integer);
procedure And_Atomic
(To : in out Aligned_Long_Integer;
From : in Long_Integer;
Retry_Count : in Natural;
From : Long_Integer;
Retry_Count : Natural;
Old_Value : out Long_Integer;
Success_Flag : out Boolean);
procedure Or_Atomic
(To : in out Aligned_Integer;
From : in Integer);
From : Integer);
procedure Or_Atomic
(To : in out Aligned_Integer;
From : in Integer;
Retry_Count : in Natural;
From : Integer;
Retry_Count : Natural;
Old_Value : out Integer;
Success_Flag : out Boolean);
procedure Or_Atomic
(To : in out Aligned_Long_Integer;
From : in Long_Integer);
From : Long_Integer);
procedure Or_Atomic
(To : in out Aligned_Long_Integer;
From : in Long_Integer;
Retry_Count : in Natural;
From : Long_Integer;
Retry_Count : Natural;
Old_Value : out Long_Integer;
Success_Flag : out Boolean);
......@@ -417,22 +417,22 @@ package System.Aux_DEC is
OK_Empty => +2);
procedure Insqhi
(Item : in Address;
Header : in Address;
(Item : Address;
Header : Address;
Status : out Insq_Status);
procedure Remqhi
(Header : in Address;
(Header : Address;
Item : out Address;
Status : out Remq_Status);
procedure Insqti
(Item : in Address;
Header : in Address;
(Item : Address;
Header : Address;
Status : out Insq_Status);
procedure Remqti
(Header : in Address;
(Header : Address;
Item : out Address;
Status : out Remq_Status);
......
......@@ -66,7 +66,7 @@ package System.Aux_DEC is
type Largest_Integer is range Min_Int .. Max_Int;
type AST_Handler is limited private;
type AST_Handler is private;
No_AST_Handler : constant AST_Handler;
......
......@@ -6,7 +6,7 @@
-- --
-- B o d y --
-- --
-- Copyright (C) 1992-2005, Free Software Foundation, Inc. --
-- Copyright (C) 1992-2006, 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- --
......@@ -184,6 +184,9 @@ package body Sem is
when N_Explicit_Dereference =>
Analyze_Explicit_Dereference (N);
when N_Extended_Return_Statement =>
Analyze_Extended_Return_Statement (N);
when N_Extension_Aggregate =>
Analyze_Aggregate (N);
......
......@@ -40,6 +40,7 @@ with Nlists; use Nlists;
with Opt; use Opt;
with Sem; use Sem;
with Sem_Cat; use Sem_Cat;
with Sem_Ch3; use Sem_Ch3;
with Sem_Ch8; use Sem_Ch8;
with Sem_Ch13; use Sem_Ch13;
with Sem_Eval; use Sem_Eval;
......@@ -450,8 +451,12 @@ package body Sem_Aggr is
Apply_Scalar_Range_Check (Exp, Check_Typ);
end if;
-- Verify that target type is also scalar, to prevent view anomalies
-- in instantiations.
elsif (Is_Scalar_Type (Exp_Typ)
or else Nkind (Exp) = N_String_Literal)
or else Nkind (Exp) = N_String_Literal)
and then Is_Scalar_Type (Check_Typ)
and then Exp_Typ /= Check_Typ
then
if Is_Entity_Name (Exp)
......@@ -782,19 +787,6 @@ package body Sem_Aggr is
elsif Nkind (V) /= N_Integer_Literal then
return;
elsif Is_Access_Type (Etype (Disc)) then
null;
-- If the bounds of the discriminant type are not compile time known,
-- the back-end will treat this as a variable-size object.
elsif not
(Compile_Time_Known_Value (Type_Low_Bound (Etype (Disc)))
and then
Compile_Time_Known_Value (Type_High_Bound (Etype (Disc))))
then
return;
end if;
Comp := First_Component (T);
......@@ -899,15 +891,9 @@ package body Sem_Aggr is
Error_Msg_CRT ("aggregate", N);
end if;
if Is_Limited_Composite (Typ) then
Error_Msg_N ("aggregate type cannot have limited component", N);
Explain_Limited_Type (Typ, N);
-- Ada 2005 (AI-287): Limited aggregates allowed
elsif Is_Limited_Type (Typ)
and Ada_Version < Ada_05
then
if Is_Limited_Type (Typ) and then Ada_Version < Ada_05 then
Error_Msg_N ("aggregate type cannot be limited", N);
Explain_Limited_Type (Typ, N);
......@@ -2114,7 +2100,7 @@ package body Sem_Aggr is
end if;
else
Error_Msg_N (" No unique type for this aggregate", A);
Error_Msg_N ("no unique type for this aggregate", A);
end if;
end Resolve_Extension_Aggregate;
......@@ -2329,40 +2315,6 @@ package body Sem_Aggr is
Expr : Node_Id := Empty;
Selector_Name : Node_Id;
procedure Check_Non_Limited_Type;
-- Relax check to allow the default initialization of limited types.
-- For example:
-- record
-- C : Lim := (..., others => <>);
-- end record;
----------------------------
-- Check_Non_Limited_Type --
----------------------------
procedure Check_Non_Limited_Type is
begin
if Is_Limited_Type (Etype (Compon))
and then Comes_From_Source (Compon)
and then not In_Instance_Body
then
-- Ada 2005 (AI-287): Limited aggregates are allowed
if Ada_Version >= Ada_05
and then Present (Expression (Assoc))
and then Nkind (Expression (Assoc)) = N_Aggregate
then
null;
else
Error_Msg_N
("initialization not allowed for limited types", N);
Explain_Limited_Type (Etype (Compon), Compon);
end if;
end if;
end Check_Non_Limited_Type;
-- Start of processing for Get_Value
begin
Is_Box_Present := False;
......@@ -2387,21 +2339,25 @@ package body Sem_Aggr is
-- Ada 2005 (AI-287): In case of default initialization
-- of components, we duplicate the corresponding default
-- expression (from the record type declaration).
-- expression (from the record type declaration). The
-- copy must carry the sloc of the association (not the
-- original expression) to prevent spurious elaboration
-- checks when the default includes function calls.
if Box_Present (Assoc) then
Others_Box := True;
Is_Box_Present := True;
if Expander_Active then
return New_Copy_Tree (Expression (Parent (Compon)));
return
New_Copy_Tree
(Expression (Parent (Compon)),
New_Sloc => Sloc (Assoc));
else
return Expression (Parent (Compon));
end if;
else
Check_Non_Limited_Type;
if Present (Others_Etype) and then
Base_Type (Others_Etype) /= Base_Type (Etype
(Compon))
......@@ -2451,8 +2407,6 @@ package body Sem_Aggr is
end if;
else
Check_Non_Limited_Type;
if Present (Next (Selector_Name)) then
Expr := New_Copy_Tree (Expression (Assoc));
else
......@@ -2479,6 +2433,31 @@ package body Sem_Aggr is
return Expr;
end Get_Value;
procedure Check_Non_Limited_Type (Expr : Node_Id);
-- Relax check to allow the default initialization of limited types.
-- For example:
-- record
-- C : Lim := (..., others => <>);
-- end record;
----------------------------
-- Check_Non_Limited_Type --
----------------------------
procedure Check_Non_Limited_Type (Expr : Node_Id) is
begin
if Is_Limited_Type (Etype (Expr))
and then Comes_From_Source (Expr)
and then not In_Instance_Body
then
if not OK_For_Limited_Init (Expr) then
Error_Msg_N
("initialization not allowed for limited types", N);
Explain_Limited_Type (Etype (Expr), Expr);
end if;
end if;
end Check_Non_Limited_Type;
-----------------------
-- Resolve_Aggr_Expr --
-----------------------
......@@ -2602,6 +2581,7 @@ package body Sem_Aggr is
end if;
Analyze_And_Resolve (Expr, Expr_Type);
Check_Non_Limited_Type (Expr);
Check_Non_Static_Context (Expr);
Check_Unset_Reference (Expr);
......
This source diff could not be displayed because it is too large. You can view the blob instead.
......@@ -6,7 +6,7 @@
-- --
-- S p e c --
-- --
-- Copyright (C) 1992-2005, Free Software Foundation, Inc. --
-- Copyright (C) 1992-2006, 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- --
......@@ -28,23 +28,30 @@ with Nlists; use Nlists;
with Types; use Types;
package Sem_Ch3 is
procedure Analyze_Component_Declaration (N : Node_Id);
procedure Analyze_Incomplete_Type_Decl (N : Node_Id);
procedure Analyze_Itype_Reference (N : Node_Id);
procedure Analyze_Number_Declaration (N : Node_Id);
procedure Analyze_Object_Declaration (N : Node_Id);
procedure Analyze_Others_Choice (N : Node_Id);
procedure Analyze_Private_Extension_Declaration (N : Node_Id);
procedure Analyze_Subtype_Declaration (N : Node_Id);
procedure Analyze_Subtype_Indication (N : Node_Id);
procedure Analyze_Type_Declaration (N : Node_Id);
procedure Analyze_Variant_Part (N : Node_Id);
procedure Analyze_Component_Declaration (N : Node_Id);
procedure Analyze_Incomplete_Type_Decl (N : Node_Id);
procedure Analyze_Itype_Reference (N : Node_Id);
procedure Analyze_Number_Declaration (N : Node_Id);
procedure Analyze_Object_Declaration (N : Node_Id);
procedure Analyze_Others_Choice (N : Node_Id);
procedure Analyze_Private_Extension_Declaration (N : Node_Id);
procedure Analyze_Subtype_Indication (N : Node_Id);
procedure Analyze_Type_Declaration (N : Node_Id);
procedure Analyze_Variant_Part (N : Node_Id);
procedure Analyze_Subtype_Declaration
(N : Node_Id;
Skip : Boolean := False);
-- Called to analyze a subtype declaration. The parameter Skip is used for
-- Ada 2005 (AI-412). We set to True in order to avoid reentering the
-- defining identifier of N when analyzing a rewritten incomplete subtype
-- declaration.
function Access_Definition
(Related_Nod : Node_Id;
N : Node_Id) return Entity_Id;
-- An access definition defines a general access type for a formal
-- parameter. The procedure is called when processing formals, when
-- parameter. The procedure is called when processing formals, when
-- the current scope is the subprogram. The Implicit type is attached
-- to the Related_Nod put into the enclosing scope, so that the only
-- entities defined in the spec are the formals themselves.
......@@ -100,15 +107,6 @@ package Sem_Ch3 is
-- rather than on the declarations that require completion in the package
-- declaration.
procedure Collect_Interfaces
(N : Node_Id;
Derived_Type : Entity_Id);
-- Ada 2005 (AI-251): Subsidiary procedure to Build_Derived_Record_Type
-- and Analyze_Formal_Interface_Type.
-- Collect the list of interfaces that are not already implemented by the
-- ancestors. This is the list of interfaces for which we must provide
-- additional tag components.
procedure Derive_Subprogram
(New_Subp : in out Entity_Id;
Parent_Subp : Entity_Id;
......@@ -125,8 +123,7 @@ package Sem_Ch3 is
procedure Derive_Subprograms
(Parent_Type : Entity_Id;
Derived_Type : Entity_Id;
Generic_Actual : Entity_Id := Empty;
No_Predefined_Prims : Boolean := False);
Generic_Actual : Entity_Id := Empty);
-- To complete type derivation, collect/retrieve the primitive operations
-- of the parent type, and replace the subsidiary subtypes with the derived
-- type, to build the specs of the inherited ops. For generic actuals, the
......@@ -183,10 +180,25 @@ package Sem_Ch3 is
procedure Make_Class_Wide_Type (T : Entity_Id);
-- A Class_Wide_Type is created for each tagged type definition. The
-- attributes of a class wide type are inherited from those of the type
-- T. If T is introduced by a private declaration, the corresponding
-- class wide type is created at the same time, and therefore there is
-- a private and a full declaration for the class wide type type as well.
-- attributes of a class wide type are inherited from those of the type T.
-- If T is introduced by a private declaration, the corresponding class
-- wide type is created at the same time, and therefore there is a private
-- and a full declaration for the class wide type type as well.
function OK_For_Limited_Init_In_05 (Exp : Node_Id) return Boolean;
-- Presuming Exp is an expression of an inherently limited type, returns
-- True if the expression is allowed in an initialization context by the
-- rules of Ada 2005. We use the rule in RM-7.5(2.1/2), "...it is an
-- aggregate, a function_call, or a parenthesized expression or
-- qualified_expression whose operand is permitted...". Note that in Ada
-- 95 mode, we sometimes wish to give warnings based on whether the
-- program _would_ be legal in Ada 2005. Note that Exp must already have
-- been resolved, so we can know whether it's a function call (as opposed
-- to an indexed component, for example).
function OK_For_Limited_Init (Exp : Node_Id) return Boolean;
-- Always False in Ada 95 mode. Equivalent to OK_For_Limited_Init_In_05 in
-- Ada 2005 mode.
procedure Process_Full_View (N : Node_Id; Full_T, Priv_T : Entity_Id);
-- Process some semantic actions when the full view of a private type is
......@@ -213,8 +225,8 @@ package Sem_Ch3 is
-- pointer of R so that the types get properly frozen. The Check_List
-- parameter is used when the subprogram is called from
-- Build_Record_Init_Proc and is used to return a set of constraint
-- checking statements generated by the Checks package. R_Check_Off is
-- set to True when the call to Range_Check is to be skipped.
-- checking statements generated by the Checks package. R_Check_Off is set
-- to True when the call to Range_Check is to be skipped.
function Process_Subtype
(S : Node_Id;
......
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