From: Arnaud Charlet Date: Thu, 16 Apr 2009 10:20:04 +0000 (+0200) Subject: [multiple changes] X-Git-Tag: releases/gcc-4.5.0~6557 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=a8e65aa5f2a310aa949081a9423acb55affc210d;p=thirdparty%2Fgcc.git [multiple changes] 2009-04-16 Robert Dewar * gnat_rm.texi: Document effect of Assume_No_Invalid_Values and -gnatVa used together. 2009-04-16 Ed Schonberg * sem_ch4.adb (Find_Equality_Types): Filter out types that are not usable before calling Add_One_Interp, to resolve spurious ambiguities. From-SVN: r146163 --- diff --git a/gcc/ada/ChangeLog b/gcc/ada/ChangeLog index 62b1f18e9ad6..465aea161060 100644 --- a/gcc/ada/ChangeLog +++ b/gcc/ada/ChangeLog @@ -1,3 +1,13 @@ +2009-04-16 Robert Dewar + + * gnat_rm.texi: Document effect of Assume_No_Invalid_Values and -gnatVa + used together. + +2009-04-16 Ed Schonberg + + * sem_ch4.adb (Find_Equality_Types): Filter out types that are not + usable before calling Add_One_Interp, to resolve spurious ambiguities. + 2009-04-16 Robert Dewar * Makefile.rtl: Add entries for s-conca? diff --git a/gcc/ada/gnat_rm.texi b/gcc/ada/gnat_rm.texi index fe463550ae18..3c45af2dd025 100644 --- a/gcc/ada/gnat_rm.texi +++ b/gcc/ada/gnat_rm.texi @@ -1041,7 +1041,15 @@ value, and the loop above will be optimized away. The use of @code{Assume_No_Invalid_Values (On)} is appropriate if you know your code is free of uninitialized variables and other possible sources of invalid representations, and may result in -more efficient code. +more efficient code. A program that accesses an invalid representation +with this pragma in effect is erroneous, so no guarantees can be made +about its behavior. + +It is peculiar though permissible to use this pragma in conjunction +with validity checking (-gnatVa). In such cases, accessing invalid +values will generally give an exception, though formally the program +is erroneous so there are no guarantees that this will always be the +case, and it is recommended that these two options not be used together. @node Pragma Ast_Entry @unnumberedsec Pragma Ast_Entry diff --git a/gcc/ada/sem_ch4.adb b/gcc/ada/sem_ch4.adb index e9a20c5a70d4..2f0ce9ac763b 100644 --- a/gcc/ada/sem_ch4.adb +++ b/gcc/ada/sem_ch4.adb @@ -4697,17 +4697,19 @@ package body Sem_Ch4 is Scop : Entity_Id := Empty; procedure Try_One_Interp (T1 : Entity_Id); - -- The context of the operator plays no role in resolving the - -- arguments, so that if there is more than one interpretation - -- of the operands that is compatible with equality, the construct - -- is ambiguous and an error can be emitted now, after trying to - -- disambiguate, i.e. applying preference rules. + -- The context of the equality operator plays no role in resolving the + -- arguments, so that if there is more than one interpretation of the + -- operands that is compatible with equality, the construct is ambiguous + -- and an error can be emitted now, after trying to disambiguate, i.e. + -- applying preference rules. -------------------- -- Try_One_Interp -- -------------------- procedure Try_One_Interp (T1 : Entity_Id) is + Bas : constant Entity_Id := Base_Type (T1); + begin -- If the operator is an expanded name, then the type of the operand -- must be defined in the corresponding scope. If the type is @@ -4725,7 +4727,7 @@ package body Sem_Ch4 is or else T1 = Any_String or else T1 = Any_Composite or else (Ekind (T1) = E_Access_Subprogram_Type - and then not Comes_From_Source (T1)) + and then not Comes_From_Source (T1)) then null; @@ -4739,6 +4741,32 @@ package body Sem_Ch4 is return; end if; + + -- If we have infix notation, the operator must be usable. + -- Within an instance, if the type is already established we + -- know it is correct. + -- In Ada 2005, the equality on anonymous access types is declared + -- in Standard, and is always visible. + + elsif In_Open_Scopes (Scope (Bas)) + or else Is_Potentially_Use_Visible (Bas) + or else In_Use (Bas) + or else (In_Use (Scope (Bas)) + and then not Is_Hidden (Bas)) + or else (In_Instance + and then First_Subtype (T1) = First_Subtype (Etype (R))) + or else Ekind (T1) = E_Anonymous_Access_Type + then + null; + + else + -- Save candidate type for subsquent error message, if any. + + if not Is_Limited_Type (T1) then + Candidate_Type := T1; + end if; + + return; end if; -- Ada 2005 (AI-230): Keep restriction imposed by Ada 83 and 95: