]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
[multiple changes]
authorArnaud Charlet <charlet@gcc.gnu.org>
Fri, 13 Jun 2014 10:03:43 +0000 (12:03 +0200)
committerArnaud Charlet <charlet@gcc.gnu.org>
Fri, 13 Jun 2014 10:03:43 +0000 (12:03 +0200)
2014-06-13  Robert Dewar  <dewar@adacore.com>

* layout.adb (Layout_Type): Anonymous access types designating
unconstrained arrays are always thin pointers.
* sem_ch3.adb (Replace_Type): Anonymous access types designating
unconstrained arrays are always thin pointers.

2014-06-13  Ed Schonberg  <schonberg@adacore.com>

* sem_attr.adb (Analyze_Attribute): Use Check_Parameterless_Call
to resolve the prefix of an attribute that is an entity name
and may be a parameterless call.  Minor code reorganization.

From-SVN: r211618

gcc/ada/ChangeLog
gcc/ada/layout.adb
gcc/ada/sem_attr.adb
gcc/ada/sem_ch3.adb

index 595d430cb5317eaffc7ad4dae55a69247a7bd8f6..3d1113cfe20f71b68da25b373eba6387f3ee1d04 100644 (file)
@@ -1,3 +1,16 @@
+2014-06-13  Robert Dewar  <dewar@adacore.com>
+
+       * layout.adb (Layout_Type): Anonymous access types designating
+       unconstrained arrays are always thin pointers.
+       * sem_ch3.adb (Replace_Type): Anonymous access types designating
+       unconstrained arrays are always thin pointers.
+
+2014-06-13  Ed Schonberg  <schonberg@adacore.com>
+
+       * sem_attr.adb (Analyze_Attribute): Use Check_Parameterless_Call
+       to resolve the prefix of an attribute that is an entity name
+       and may be a parameterless call.  Minor code reorganization.
+
 2014-06-13  Robert Dewar  <dewar@adacore.com>
 
        * lib.ads, lib.adb, lib-writ.adb, lib-load.adb (Is_Compiler_Unit):
index f1a833bdb48f1e1121c6ee95b17379973b3ed713..618b0f8d78f648a3ecf48cdd001a237e639b17cc 100644 (file)
@@ -2462,19 +2462,11 @@ package body Layout is
             Set_Size_Info (E, Base_Type (E));
             Set_RM_Size   (E, RM_Size (Base_Type (E)));
 
-         --  Anonymous access types in subprogram specifications are always
-         --  thin. In the unconstrained case we always use thin pointers for
-         --  anonymous access types, because otherwise we get into strange
-         --  conformance problems between two types, one of which can see
-         --  that something is unconstrained and one of which cannot. The
-         --  object of an extended return is treated similarly.
-
-         elsif Ekind (E) = E_Anonymous_Access_Type
-           and then (Nkind_In (Associated_Node_For_Itype (E),
-                               N_Function_Specification,
-                               N_Procedure_Specification)
-                      or else Ekind (Scope (E))  = E_Return_Statement)
-         then
+         --  Anonymous access types are always thin, because otherwise we get
+         --  into strange conformance problems between two types, one of which
+         --  can see that something is unconstrained and one of which cannot.
+
+         elsif Ekind (E) = E_Anonymous_Access_Type then
             Init_Size (E, System_Address_Size);
 
          --  For other access types, we use either address size, or, if a fat
index b1a7ee56b4734499722797babc4390003a2bb8c0..fa667991748bcb2c5bede194a2e41d1d17063897 100644 (file)
@@ -2412,57 +2412,64 @@ package body Sem_Attr is
       --  Ada 2005 (AI-345): Ensure that the compiler gives exactly the current
       --  output compiling in Ada 95 mode for the case of ambiguous prefixes.
 
-      if Ada_Version < Ada_2005
-        and then Is_Overloaded (P)
-        and then Aname /= Name_Access
-        and then Aname /= Name_Address
-        and then Aname /= Name_Code_Address
-        and then Aname /= Name_Count
-        and then Aname /= Name_Result
-        and then Aname /= Name_Unchecked_Access
-      then
-         Error_Attr ("ambiguous prefix for % attribute", P);
+      --  Is this comment right??? What is "the current output"??? If this
+      --  is only about Ada 95 mode, why no test for Ada 95 at this point???
 
-      elsif Ada_Version >= Ada_2005
-        and then Is_Overloaded (P)
+      if Is_Overloaded (P)
         and then Aname /= Name_Access
         and then Aname /= Name_Address
         and then Aname /= Name_Code_Address
         and then Aname /= Name_Result
         and then Aname /= Name_Unchecked_Access
       then
-         --  Ada 2005 (AI-345): Since protected and task types have primitive
-         --  entry wrappers, the attributes Count, Caller and AST_Entry require
-         --  a context check
+         --  The prefix must be resolvble by itself, without reference to the
+         --  attribute. One case that requires special handling is a prefix
+         --  that is a function name, where one interpretation may be a
+         --  parameterless call. Entry attributes are handled specially below.
 
-         if Ada_Version >= Ada_2005
-           and then Nam_In (Aname, Name_Count, Name_Caller, Name_AST_Entry)
+         if Is_Entity_Name (P)
+           and then not Nam_In (Aname, Name_Count, Name_Caller, Name_AST_Entry)
          then
-            declare
-               Count : Natural := 0;
-               I     : Interp_Index;
-               It    : Interp;
+            Check_Parameterless_Call (P);
+         end if;
 
-            begin
-               Get_First_Interp (P, I, It);
-               while Present (It.Nam) loop
-                  if Comes_From_Source (It.Nam) then
-                     Count := Count + 1;
-                  else
-                     Remove_Interp (I);
-                  end if;
+         if Ada_Version < Ada_2005 then
+            if Is_Overloaded (P) then
 
-                  Get_Next_Interp (I, It);
-               end loop;
+               --  Ada 2005 (AI-345): Since protected and task types have
+               --  primitive entry wrappers, the attributes Count, Caller and
+               --  AST_Entry require a context check
 
-               if Count > 1 then
-                  Error_Attr ("ambiguous prefix for % attribute", P);
+               if Nam_In (Aname, Name_Count, Name_Caller, Name_AST_Entry) then
+                  declare
+                     Count : Natural := 0;
+                     I     : Interp_Index;
+                     It    : Interp;
+
+                  begin
+                     Get_First_Interp (P, I, It);
+                     while Present (It.Nam) loop
+                        if Comes_From_Source (It.Nam) then
+                           Count := Count + 1;
+                        else
+                           Remove_Interp (I);
+                        end if;
+
+                        Get_Next_Interp (I, It);
+                     end loop;
+
+                     if Count > 1 then
+                        Error_Attr ("ambiguous prefix for % attribute", P);
+                     else
+                        Set_Is_Overloaded (P, False);
+                     end if;
+                  end;
                else
-                  Set_Is_Overloaded (P, False);
+                  Error_Attr ("ambiguous prefix for % attribute", P);
                end if;
-            end;
+            end if;
 
-         else
+         elsif Is_Overloaded (P) then
             Error_Attr ("ambiguous prefix for % attribute", P);
          end if;
       end if;
@@ -2470,8 +2477,10 @@ package body Sem_Attr is
       --  In SPARK, attributes of private types are only allowed if the full
       --  type declaration is visible.
 
-      if Is_Entity_Name (P)
-        and then Present (Entity (P))  --  needed in some cases
+      --  Note: the check for Present (Entity (P)) defends against some error
+      --  conditions where the Entity field is not set.
+
+      if Is_Entity_Name (P) and then Present (Entity (P))
         and then Is_Type (Entity (P))
         and then Is_Private_Type (P_Type)
         and then not In_Open_Scopes (Scope (P_Type))
index 2748a838d442b779809bd83b9cffe7d6f8869995..938c28ea6b1185de93681e6578574668005f1fdf 100644 (file)
@@ -13562,21 +13562,23 @@ package body Sem_Ch3 is
                   --  interface primitives.
 
                  or else (Is_Interface (Desig_Typ)
-                          and then not Is_Class_Wide_Type (Desig_Typ))
+                           and then not Is_Class_Wide_Type (Desig_Typ))
                then
                   Acc_Type := New_Copy (Etype (Id));
                   Set_Etype (Acc_Type, Acc_Type);
                   Set_Scope (Acc_Type, New_Subp);
 
-                  --  Compute size of anonymous access type
+                  --  Set size of anonymous access type. Note that anonymous
+                  --  access to Unconstrained always uses thin pointers. This
+                  --  avoids confusion for the case where two types that should
+                  --  conform but end up differning, because in one case we can
+                  --  see the unconstrained designated type, and in the other
+                  --  case we can't see it yet (full type declaration not seen
+                  --  yet), so we default to thin in that case anyway.
 
-                  if Is_Array_Type (Desig_Typ)
-                    and then not Is_Constrained (Desig_Typ)
-                  then
-                     Init_Size (Acc_Type, 2 * System_Address_Size);
-                  else
-                     Init_Size (Acc_Type, System_Address_Size);
-                  end if;
+                  Init_Size (Acc_Type, System_Address_Size);
+
+                  --  Set remaining characterstics of anonymous access type
 
                   Init_Alignment (Acc_Type);
                   Set_Directly_Designated_Type (Acc_Type, Derived_Type);
@@ -13585,6 +13587,7 @@ package body Sem_Ch3 is
                   Set_Scope (New_Id, New_Subp);
 
                   --  Create a reference to it
+
                   Build_Itype_Reference (Acc_Type, Parent (Derived_Type));
 
                else