aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorArnaud Charlet <charlet@gcc.gnu.org>2009-04-16 12:20:04 +0200
committerArnaud Charlet <charlet@gcc.gnu.org>2009-04-16 12:20:04 +0200
commita8e65aa5f2a310aa949081a9423acb55affc210d (patch)
tree40871dae07483d2ff0c8618dff8c64185c33f089
parentfa702fbdb573639fa7b5011e2d1e20e94d25aa7a (diff)
downloadgcc-a8e65aa5f2a310aa949081a9423acb55affc210d.zip
gcc-a8e65aa5f2a310aa949081a9423acb55affc210d.tar.gz
gcc-a8e65aa5f2a310aa949081a9423acb55affc210d.tar.bz2
[multiple changes]
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
-rw-r--r--gcc/ada/ChangeLog10
-rw-r--r--gcc/ada/gnat_rm.texi10
-rw-r--r--gcc/ada/sem_ch4.adb40
3 files changed, 53 insertions, 7 deletions
diff --git a/gcc/ada/ChangeLog b/gcc/ada/ChangeLog
index 62b1f18..465aea1 100644
--- a/gcc/ada/ChangeLog
+++ b/gcc/ada/ChangeLog
@@ -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
diff --git a/gcc/ada/gnat_rm.texi b/gcc/ada/gnat_rm.texi
index fe46355..3c45af2 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 e9a20c5..2f0ce9a 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: