]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
[multiple changes]
authorArnaud Charlet <charlet@gcc.gnu.org>
Thu, 16 Apr 2009 10:20:04 +0000 (12:20 +0200)
committerArnaud Charlet <charlet@gcc.gnu.org>
Thu, 16 Apr 2009 10:20:04 +0000 (12:20 +0200)
2009-04-16  Robert Dewar  <dewar@adacore.com>

* gnat_rm.texi: Document effect of Assume_No_Invalid_Values and -gnatVa
used together.

2009-04-16  Ed Schonberg  <schonberg@adacore.com>

* 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

gcc/ada/ChangeLog
gcc/ada/gnat_rm.texi
gcc/ada/sem_ch4.adb

index 62b1f18e9ad6e2a76cb2ce46ef4ec17e9042cb20..465aea16106019fae5aa28b1a4daa75a1264e94f 100644 (file)
@@ -1,3 +1,13 @@
+2009-04-16  Robert Dewar  <dewar@adacore.com>
+
+       * gnat_rm.texi: Document effect of Assume_No_Invalid_Values and -gnatVa
+       used together.
+
+2009-04-16  Ed Schonberg  <schonberg@adacore.com>
+
+       * 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  <dewar@adacore.com>
 
        * Makefile.rtl: Add entries for s-conca?
index fe463550ae181e2777bdf4c14f9a8b19c52a90cb..3c45af2dd0254ddf0cd8e5f4c5bc3e588978ac6a 100644 (file)
@@ -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
index e9a20c5a70d4bb931290f052d395b26578822da8..2f0ce9ac763b7afe4eea1ff162daf13af53c0034 100644 (file)
@@ -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: