aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYannick Moy <moy@adacore.com>2011-08-02 13:46:38 +0000
committerArnaud Charlet <charlet@gcc.gnu.org>2011-08-02 15:46:38 +0200
commit4c60de0c970a2b152748ec3c65f65328b4689471 (patch)
tree9a6536a6f1657333941661904bed92489a6d8938
parentf5afb270e6dae6d56ddad1fb2b8661dffe03259c (diff)
downloadgcc-4c60de0c970a2b152748ec3c65f65328b4689471.zip
gcc-4c60de0c970a2b152748ec3c65f65328b4689471.tar.gz
gcc-4c60de0c970a2b152748ec3c65f65328b4689471.tar.bz2
errout.adb (First_Node): minor renaming
2011-08-02 Yannick Moy <moy@adacore.com> * errout.adb (First_Node): minor renaming * restrict.adb (Check_Formal_Restriction): put restriction warning on first node. From-SVN: r177155
-rw-r--r--gcc/ada/ChangeLog6
-rw-r--r--gcc/ada/errout.adb24
-rw-r--r--gcc/ada/restrict.adb10
3 files changed, 24 insertions, 16 deletions
diff --git a/gcc/ada/ChangeLog b/gcc/ada/ChangeLog
index 0308954..1acadb7 100644
--- a/gcc/ada/ChangeLog
+++ b/gcc/ada/ChangeLog
@@ -1,5 +1,11 @@
2011-08-02 Yannick Moy <moy@adacore.com>
+ * errout.adb (First_Node): minor renaming
+ * restrict.adb (Check_Formal_Restriction): put restriction warning on
+ first node.
+
+2011-08-02 Yannick Moy <moy@adacore.com>
+
* sem_res.adb (Resolve_Logical_Op): ensure N is a binary operator
before accessing operands.
* sem_util.adb (Is_SPARK_Initialization_Expr): follow original nodes to
diff --git a/gcc/ada/errout.adb b/gcc/ada/errout.adb
index 076fec2..169540e 100644
--- a/gcc/ada/errout.adb
+++ b/gcc/ada/errout.adb
@@ -1307,9 +1307,9 @@ package body Errout is
----------------
function First_Node (C : Node_Id) return Node_Id is
- L : constant Source_Ptr := Sloc (Original_Node (C));
Orig : constant Node_Id := Original_Node (C);
- Sfile : constant Source_File_Index := Get_Source_File_Index (L);
+ Loc : constant Source_Ptr := Sloc (Orig);
+ Sfile : constant Source_File_Index := Get_Source_File_Index (Loc);
Earliest : Node_Id;
Eloc : Source_Ptr;
@@ -1324,20 +1324,26 @@ package body Errout is
------------------
function Test_Earlier (N : Node_Id) return Traverse_Result is
- Loc : constant Source_Ptr := Sloc (Original_Node (N));
+ Norig : constant Node_Id := Original_Node (N);
+ Loc : constant Source_Ptr := Sloc (Norig);
begin
- -- Check for earlier. The tests for being in the same file ensures
- -- against strange cases of foreign code somehow being present. We
- -- don't want wild placement of messages if that happens, so it is
- -- best to just ignore this situation.
+ -- Check for earlier
if Loc < Eloc
+
+ -- Ignore nodes with no useful location information
+
and then Loc /= Standard_Location
and then Loc /= No_Location
+
+ -- Ignore nodes from a different file. This ensures against cases
+ -- of strange foreign code somehow being present. We don't want
+ -- wild placement of messages if that happens.
+
and then Get_Source_File_Index (Loc) = Sfile
then
- Earliest := Original_Node (N);
+ Earliest := Norig;
Eloc := Loc;
end if;
@@ -1349,7 +1355,7 @@ package body Errout is
begin
if Nkind (Orig) in N_Subexpr then
Earliest := Orig;
- Eloc := Sloc (Earliest);
+ Eloc := Loc;
Search_Tree_First (Orig);
return Earliest;
diff --git a/gcc/ada/restrict.adb b/gcc/ada/restrict.adb
index 08af7e6..883128a 100644
--- a/gcc/ada/restrict.adb
+++ b/gcc/ada/restrict.adb
@@ -123,18 +123,14 @@ package body Restrict is
-- Error_Msg_Sloc to the location of the pragma restriction, save and
-- restore the previous value of the global variable around the call.
- -- ??? N in call to Check_Restriction should be First_Node (N), but
- -- this causes an exception to be raised when analyzing osint.adb.
- -- To be modified together with the calls to Error_Msg_N.
-
Save_Error_Msg_Sloc := Error_Msg_Sloc;
- Check_Restriction (Msg_Issued, SPARK, N); -- N -> First_Node (N)
+ Check_Restriction (Msg_Issued, SPARK, First_Node (N));
Error_Msg_Sloc := Save_Error_Msg_Sloc;
if Msg_Issued then
- Error_Msg_N ("\\| " & Msg, N); -- Error_Msg_N -> Error_Msg_F
+ Error_Msg_F ("\\| " & Msg, N);
elsif SPARK_Mode then
- Error_Msg_N ("|~~" & Msg, N); -- Error_Msg_N -> Error_Msg_F
+ Error_Msg_F ("|~~" & Msg, N);
end if;
end if;
end Check_Formal_Restriction;