+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>
* sem_ch6.adb (Check_Overriding_Indicator): Clean up code, make warning
end if;
-- Ada 2005 (AI-287): In case of default initialized components,
- -- we need to generate the corresponding selected component node
- -- to access the discriminant value. In other cases this is not
- -- required because we are inside the init proc and we use the
- -- corresponding formal.
+ -- if the component is constrained with a discriminant of the
+ -- enclosing type, we need to generate the corresponding selected
+ -- component node to access the discriminant value. In other cases
+ -- 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
and then Nkind (Id_Ref) = N_Selected_Component
and then Nkind (Arg) = N_Identifier
+ and then Ekind (Entity (Arg)) = E_Discriminant
then
Append_To (Args,
Make_Selected_Component (Loc,
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
-- categorization (preelaborate and pure) checks. Defer these
-- checks to freeze time since pragma Import inhibits default
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
- elsif Is_Indefinite_Subtype (T) then
+ if Is_Indefinite_Subtype (T) then
-- Nothing to do in deferred constant case
-- The overriding operation is type conformant with the overridden one,
-- 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
-- often carry names that reflect the type, and it is not worthwhile
-- requiring that their names match.
-- If the overriding operation is a synchronized operation, skip
-- 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);
end if;