[multiple changes]
authorArnaud Charlet <charlet@gcc.gnu.org>
Mon, 22 Jun 2009 13:15:08 +0000 (15:15 +0200)
committerArnaud Charlet <charlet@gcc.gnu.org>
Mon, 22 Jun 2009 13:15:08 +0000 (15:15 +0200)
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

gcc/ada/ChangeLog
gcc/ada/exp_ch3.adb
gcc/ada/freeze.adb
gcc/ada/sem_ch3.adb
gcc/ada/sem_ch6.adb

index 343de41a157dd2758ce818e7b80508a2f18a869f..3fd0df3391296e159a3e62dcb34992704cd0376d 100644 (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>
 
        * sem_ch6.adb (Check_Overriding_Indicator): Clean up code, make warning
index 3b2cc64a0bd4d6fdb9048140ecfddd9feeedaadb..219175b5a14e3fb5e35cc51c221c0c0c14184ade 100644 (file)
@@ -1565,14 +1565,17 @@ package body Exp_Ch3 is
             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,
index e68086cdc98f8179efc25ca824f3b1d1f29db680..5a7d0ef47dee7d358c187e00a635f1fcd739a5ac 100644 (file)
@@ -2670,6 +2670,28 @@ package body Freeze is
 
             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
index 3e334686b738905de57d9424ebbb95378c05f1a8..47616825e35929c4d6cec7bc813431e0a0f846aa 100644 (file)
@@ -2657,24 +2657,9 @@ package body Sem_Ch3 is
          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
 
index 1b4abcb6e6fe64e2bb40d89cd726deca6bf86198..bb0da6d7538085230509531f59f0b243246d510c 100644 (file)
@@ -4376,7 +4376,7 @@ package body Sem_Ch6 is
 
       --  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.
@@ -4394,9 +4394,13 @@ package body Sem_Ch6 is
 
             --  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;