]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
back_end.adb (Call_Back_End): Pass the maximum logical line number instead of the...
authorEric Botcazou <ebotcazou@adacore.com>
Thu, 20 Oct 2011 10:56:08 +0000 (10:56 +0000)
committerEric Botcazou <ebotcazou@gcc.gnu.org>
Thu, 20 Oct 2011 10:56:08 +0000 (10:56 +0000)
* back_end.adb (Call_Back_End): Pass the maximum logical line number
instead of the maximum physical line number to gigi.
* gcc-interface/trans.c (Sloc_to_locus): Cope with line zero.

From-SVN: r180242

gcc/ada/ChangeLog
gcc/ada/back_end.adb
gcc/ada/gcc-interface/trans.c
gcc/testsuite/ChangeLog
gcc/testsuite/gnat.dg/source_ref1.adb [new file with mode: 0644]
gcc/testsuite/gnat.dg/source_ref2.adb [new file with mode: 0644]

index ff41f8e5f1aa916a5d9fa34780e90e9301c734d1..8b0c58a2258c23ab52d5ca29b4713ec9e12f5b15 100644 (file)
@@ -1,3 +1,9 @@
+2011-10-20  Eric Botcazou  <ebotcazou@adacore.com>
+
+       * back_end.adb (Call_Back_End): Pass the maximum logical line number
+       instead of the maximum physical line number to gigi.
+       * gcc-interface/trans.c (Sloc_to_locus): Cope with line zero.
+
 2011-10-16  Tom Tromey  <tromey@redhat.com>
            Dodji Seketeli  <dodji@redhat.com>
 
index a089f3862c4a6b473f5de556168e9cbb28a5f1e4..b6ad263c232d8470b073391b4ba422aaf14c82e8 100644 (file)
@@ -114,9 +114,13 @@ package body Back_End is
          return;
       end if;
 
+      --  The back end needs to know the maximum line number that can appear
+      --  in a Sloc, in other words the maximum logical line number.
+
       for J in 1 .. Last_Source_File loop
          File_Info_Array (J).File_Name        := Full_Debug_Name (J);
-         File_Info_Array (J).Num_Source_Lines := Num_Source_Lines (J);
+         File_Info_Array (J).Num_Source_Lines :=
+           Nat (Physical_To_Logical (Last_Source_Line (J), J));
       end loop;
 
       if Generate_SCIL then
index 69c66d1b15077258a54969f5ba1eb1a33f9f44a0..ba47a7e373ebca4d22d4d51d40e64a1a08664adf 100644 (file)
@@ -8393,6 +8393,10 @@ Sloc_to_locus (Source_Ptr Sloc, location_t *locus)
       Column_Number column = Get_Column_Number (Sloc);
       struct line_map *map = LINEMAPS_ORDINARY_MAP_AT (line_table, file - 1);
 
+      /* We can have zero if pragma Source_Reference is in effect.  */
+      if (line < 1)
+       line = 1;
+
       /* Translate the location.  */
       *locus = linemap_position_for_line_and_column (map, line, column);
     }
index 709fae4848c453929a92e10ce07f877dd9957b83..654beee233e5cade14210196d931b18a74d543c2 100644 (file)
@@ -1,3 +1,8 @@
+2011-10-20  Eric Botcazou  <ebotcazou@adacore.com>
+
+       * gnat.dg/source_ref1.adb: New test.
+       * gnat.dg/source_ref2.adb: Likewise.
+
 2011-10-19  Paolo Carlini  <paolo.carlini@oracle.com>
 
        PR c++/13657
diff --git a/gcc/testsuite/gnat.dg/source_ref1.adb b/gcc/testsuite/gnat.dg/source_ref1.adb
new file mode 100644 (file)
index 0000000..fd450cc
--- /dev/null
@@ -0,0 +1,6 @@
+pragma Source_Reference (3, "p1.adb");
+
+procedure Source_Ref1 is
+begin
+   null;
+end;
diff --git a/gcc/testsuite/gnat.dg/source_ref2.adb b/gcc/testsuite/gnat.dg/source_ref2.adb
new file mode 100644 (file)
index 0000000..cc2d576
--- /dev/null
@@ -0,0 +1,7 @@
+pragma Source_Reference (1, "p2.adb");
+
+procedure Source_Ref2 is
+pragma Source_Reference (2, "p2.adb");
+begin
+   null;
+end;