[multiple changes]

2009-06-22  Javier Miranda  <miranda@adacore.com>

	* sem_ch3.adb (Analyze_Object_Declaration, Freeze_Entity): Move to the
	freezing point the check on the use of abstract types in object
	declarations. Done to allow the declaration of C++ imported variables
	or constants whose type corresponds with an imported C++ classes for
	which the constructor is not imported.

2009-06-22  Thomas Quinot  <quinot@adacore.com>

	* sem_ch6.adb: Minor reformatting

2009-06-22  Ed Schonberg  <schonberg@adacore.com>

	* exp_ch3.adb (Build_Initialization_Call): If a discriminated record
	component is constrained with an expression rather than with a
	discriminant of the enclosing type, use that expression when building
	the call to default-initialize the component, when the call is part of
	an aggregate with box initialization.

From-SVN: r148793
This commit is contained in:
Arnaud Charlet 2009-06-22 15:15:08 +02:00
parent c9e7bd8efb
commit 6823270cb9
5 changed files with 57 additions and 23 deletions

View File

@ -1,3 +1,23 @@
2009-06-22 Javier Miranda <miranda@adacore.com>
* sem_ch3.adb (Analyze_Object_Declaration, Freeze_Entity): Move to the
freezing point the check on the use of abstract types in object
declarations. Done to allow the declaration of C++ imported variables
or constants whose type corresponds with an imported C++ classes for
which the constructor is not imported.
2009-06-22 Thomas Quinot <quinot@adacore.com>
* sem_ch6.adb: Minor reformatting
2009-06-22 Ed Schonberg <schonberg@adacore.com>
* exp_ch3.adb (Build_Initialization_Call): If a discriminated record
component is constrained with an expression rather than with a
discriminant of the enclosing type, use that expression when building
the call to default-initialize the component, when the call is part of
an aggregate with box initialization.
2009-06-22 Ed Schonberg <schonberg@adacore.com> 2009-06-22 Ed Schonberg <schonberg@adacore.com>
* sem_ch6.adb (Check_Overriding_Indicator): Clean up code, make warning * sem_ch6.adb (Check_Overriding_Indicator): Clean up code, make warning

View File

@ -1565,14 +1565,17 @@ package body Exp_Ch3 is
end if; end if;
-- Ada 2005 (AI-287): In case of default initialized components, -- Ada 2005 (AI-287): In case of default initialized components,
-- we need to generate the corresponding selected component node -- if the component is constrained with a discriminant of the
-- to access the discriminant value. In other cases this is not -- enclosing type, we need to generate the corresponding selected
-- required because we are inside the init proc and we use the -- component node to access the discriminant value. In other cases
-- corresponding formal. -- this is not required, either because we are inside the init
-- proc and we use the corresponding formal, or else because the
-- component is constrained by an expression.
if With_Default_Init if With_Default_Init
and then Nkind (Id_Ref) = N_Selected_Component and then Nkind (Id_Ref) = N_Selected_Component
and then Nkind (Arg) = N_Identifier and then Nkind (Arg) = N_Identifier
and then Ekind (Entity (Arg)) = E_Discriminant
then then
Append_To (Args, Append_To (Args,
Make_Selected_Component (Loc, Make_Selected_Component (Loc,

View File

@ -2670,6 +2670,28 @@ package body Freeze is
if Nkind (Declaration_Node (E)) = N_Object_Declaration then if Nkind (Declaration_Node (E)) = N_Object_Declaration then
-- Abstract type allowed only for C++ imported variables or
-- constants.
-- Note: we inhibit this check for objects that do not come
-- from source because there is at least one case (the
-- expansion of x'class'input where x is abstract) where we
-- legitimately generate an abstract object.
if Is_Abstract_Type (Etype (E))
and then Comes_From_Source (Parent (E))
and then not (Is_Imported (E)
and then Is_CPP_Class (Etype (E)))
then
Error_Msg_N ("type of object cannot be abstract",
Object_Definition (Parent (E)));
if Is_CPP_Class (Etype (E)) then
Error_Msg_NE ("\} may need a cpp_constructor",
Object_Definition (Parent (E)), Etype (E));
end if;
end if;
-- For object created by object declaration, perform required -- For object created by object declaration, perform required
-- categorization (preelaborate and pure) checks. Defer these -- categorization (preelaborate and pure) checks. Defer these
-- checks to freeze time since pragma Import inhibits default -- checks to freeze time since pragma Import inhibits default

View File

@ -2657,24 +2657,9 @@ package body Sem_Ch3 is
end if; end if;
end if; end if;
-- Abstract type is never permitted for a variable or constant.
-- Note: we inhibit this check for objects that do not come from
-- source because there is at least one case (the expansion of
-- x'class'input where x is abstract) where we legitimately
-- generate an abstract object.
if Is_Abstract_Type (T) and then Comes_From_Source (N) then
Error_Msg_N ("type of object cannot be abstract",
Object_Definition (N));
if Is_CPP_Class (T) then
Error_Msg_NE ("\} may need a cpp_constructor",
Object_Definition (N), T);
end if;
-- Case of unconstrained type -- Case of unconstrained type
elsif Is_Indefinite_Subtype (T) then if Is_Indefinite_Subtype (T) then
-- Nothing to do in deferred constant case -- Nothing to do in deferred constant case

View File

@ -4376,7 +4376,7 @@ package body Sem_Ch6 is
-- The overriding operation is type conformant with the overridden one, -- The overriding operation is type conformant with the overridden one,
-- but the names of the formals are not required to match. If the names -- but the names of the formals are not required to match. If the names
-- appear permuted in the overriding operation this is a possible -- appear permuted in the overriding operation, this is a possible
-- source of confusion that is worth diagnosing. Controlling formals -- source of confusion that is worth diagnosing. Controlling formals
-- often carry names that reflect the type, and it is not worthwhile -- often carry names that reflect the type, and it is not worthwhile
-- requiring that their names match. -- requiring that their names match.
@ -4394,9 +4394,13 @@ package body Sem_Ch6 is
-- If the overriding operation is a synchronized operation, skip -- If the overriding operation is a synchronized operation, skip
-- the first parameter of the overridden operation, which is -- the first parameter of the overridden operation, which is
-- implicit in the new one. -- implicit in the new one. If the operation is declared in the
-- body it is not primitive and all formals must match.
if Is_Concurrent_Type (Scope (Subp)) then if Is_Concurrent_Type (Scope (Subp))
and then Is_Tagged_Type (Scope (Subp))
and then not Has_Completion (Scope (Subp))
then
Form2 := Next_Formal (Form2); Form2 := Next_Formal (Form2);
end if; end if;