aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorArnaud Charlet <charlet@gcc.gnu.org>2014-06-13 12:03:43 +0200
committerArnaud Charlet <charlet@gcc.gnu.org>2014-06-13 12:03:43 +0200
commit446ebdbbd062cec9a8db76dcd5882683268d00a8 (patch)
tree78623ddf8772ac78c5814c15f74fe937c361bd95
parentc86cf71483eb73bf8d637e4c9d6caef3b67b09a2 (diff)
downloadgcc-446ebdbbd062cec9a8db76dcd5882683268d00a8.zip
gcc-446ebdbbd062cec9a8db76dcd5882683268d00a8.tar.gz
gcc-446ebdbbd062cec9a8db76dcd5882683268d00a8.tar.bz2
[multiple changes]
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
-rw-r--r--gcc/ada/ChangeLog13
-rw-r--r--gcc/ada/layout.adb18
-rw-r--r--gcc/ada/sem_attr.adb85
-rw-r--r--gcc/ada/sem_ch3.adb21
4 files changed, 77 insertions, 60 deletions
diff --git a/gcc/ada/ChangeLog b/gcc/ada/ChangeLog
index 595d430..3d1113c 100644
--- a/gcc/ada/ChangeLog
+++ b/gcc/ada/ChangeLog
@@ -1,5 +1,18 @@
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):
Removed.
* opt.ads (Compiler_Unit): New flag.
diff --git a/gcc/ada/layout.adb b/gcc/ada/layout.adb
index f1a833b..618b0f8 100644
--- a/gcc/ada/layout.adb
+++ b/gcc/ada/layout.adb
@@ -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
diff --git a/gcc/ada/sem_attr.adb b/gcc/ada/sem_attr.adb
index b1a7ee5..fa66799 100644
--- a/gcc/ada/sem_attr.adb
+++ b/gcc/ada/sem_attr.adb
@@ -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))
diff --git a/gcc/ada/sem_ch3.adb b/gcc/ada/sem_ch3.adb
index 2748a83..938c28e 100644
--- a/gcc/ada/sem_ch3.adb
+++ b/gcc/ada/sem_ch3.adb
@@ -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