OSDN Git Service

2009-04-16 Robert Dewar <dewar@adacore.com>
authorcharlet <charlet@138bc75d-0d04-0410-961f-82ee72b054a4>
Thu, 16 Apr 2009 10:20:04 +0000 (10:20 +0000)
committercharlet <charlet@138bc75d-0d04-0410-961f-82ee72b054a4>
Thu, 16 Apr 2009 10:20:04 +0000 (10:20 +0000)
* 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.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@146163 138bc75d-0d04-0410-961f-82ee72b054a4

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

index 62b1f18..465aea1 100644 (file)
@@ -1,5 +1,15 @@
 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?
 
        * debug.adb: Add debug flags -gnatd.c and -gnatd.C to control behavior
index fe46355..3c45af2 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 e9a20c5..2f0ce9a 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: