]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
sem_util.adb, [...]: Correct false positive warnings.
authorRobert Dewar <dewar@adacore.com>
Fri, 24 Jan 2014 14:03:19 +0000 (14:03 +0000)
committerArnaud Charlet <charlet@gcc.gnu.org>
Fri, 24 Jan 2014 14:03:19 +0000 (15:03 +0100)
2014-01-24  Robert Dewar  <dewar@adacore.com>

* sem_util.adb, lib-xref.adb: Correct false positive warnings.

From-SVN: r207031

gcc/ada/ChangeLog
gcc/ada/lib-xref.adb
gcc/ada/sem_util.adb

index a21fe7cdd2b45442f508aa81c46422c6afd0160c..cabedee249ac935e6e5e331ead39ff647de85357 100644 (file)
@@ -1,3 +1,7 @@
+2014-01-24  Robert Dewar  <dewar@adacore.com>
+
+       * sem_util.adb, lib-xref.adb: Correct false positive warnings.
+
 2014-01-24  Vincent Celier  <celier@adacore.com>
 
        * projects.texi: Document that aggregate projects are only
index a01bbab6a3158fcae248cb492edddacf80f796fa..67739211abca3308c5a76b5397a639f279e3d48f 100644 (file)
@@ -432,6 +432,7 @@ package body Lib.Xref is
       --  ??? There are several routines here and there that perform a similar
       --      (but subtly different) computation, which should be factored:
 
+      --      Sem_Util.Is_LHS
       --      Sem_Util.May_Be_Lvalue
       --      Sem_Util.Known_To_Be_Assigned
       --      Exp_Ch2.Expand_Entry_Parameter.In_Assignment_Context
@@ -473,20 +474,27 @@ package body Lib.Xref is
 
             --  ??? case of a slice assignment?
 
-            --  ??? Note that in some cases this is called too early
-            --  (see comments in Sem_Ch8.Find_Direct_Name), at a point where
-            --  the tree is not fully typed yet. In that case we may lack
-            --  an Etype for N, and we must disable the check for an implicit
-            --  dereference. If the dereference is on an LHS, this causes a
-            --  false positive.
-
             elsif (K = N_Selected_Component or else K = N_Indexed_Component)
               and then Prefix (P) = N
-              and then not (Present (Etype (N))
-                              and then
-                            Is_Access_Type (Etype (N)))
             then
-               N := P;
+               --  Check for access type. First a kludge, In some cases this is
+               --  called too early (see comments in Sem_Ch8.Find_Direct_Name),
+               --  at a point where the tree is not fully typed yet. In that
+               --  case we may lack an Etype for N, and we can't check the
+               --  Etype. For now, we always return False in such a case,
+               --  but this is clearly not right in all cases ???
+
+               if No (Etype (N)) then
+                  return False;
+
+               elsif Is_Access_Type (Etype (N)) then
+                  return False;
+
+               --  Access type case dealt with, keep going
+
+               else
+                  N := P;
+               end if;
 
             --  All other cases, definitely not on left side
 
index b5bb307e8e5dc78b8efaf6d0462ec348ade4e7ed..422e462112950b6fa8b4d50474fda3aa89a2ba2b 100644 (file)
@@ -9882,7 +9882,12 @@ package body Sem_Util is
          --  a reference as a modification. It is not clear if there are any
          --  other bad consequences. ???
 
-         if Present (Etype (N)) and then Is_Access_Type (Etype (N)) then
+         if No (Etype (N)) then
+            return False;
+
+         --  We have an Etype set, so we can check it
+
+         elsif Is_Access_Type (Etype (N)) then
             return False;
 
          --  OK, not access type case, so just test whole expression