public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc/devel/autopar_devel] [Ada] Incorrect source line range on subprogram body with contract
@ 2020-08-22 21:59 Giuliano Belinassi
0 siblings, 0 replies; only message in thread
From: Giuliano Belinassi @ 2020-08-22 21:59 UTC (permalink / raw)
To: gcc-cvs
https://gcc.gnu.org/g:71f82eb2db6653be8d8f341a49ad00531d3c58c3
commit 71f82eb2db6653be8d8f341a49ad00531d3c58c3
Author: Ed Schonberg <schonberg@adacore.com>
Date: Thu Jan 23 11:00:46 2020 -0500
[Ada] Incorrect source line range on subprogram body with contract
2020-06-04 Ed Schonberg <schonberg@adacore.com>
gcc/ada/
* sinput.adb (Sloc_Range): Ignore node in the tree if it appears
in a unit different from that of the node whose Sloc range we
are computing. This is necessary when computing the source range
of a subprogram body whose declaration includes a pre- or
postcondition, because declaration and body may appear in
different units, and the expanded code for the body includes
copies of the contract code.
Diff:
---
gcc/ada/sinput.adb | 10 ++++++++++
1 file changed, 10 insertions(+)
diff --git a/gcc/ada/sinput.adb b/gcc/ada/sinput.adb
index 4c342d97a33..9f2669edb55 100644
--- a/gcc/ada/sinput.adb
+++ b/gcc/ada/sinput.adb
@@ -937,6 +937,8 @@ package body Sinput is
procedure Sloc_Range (N : Node_Id; Min, Max : out Source_Ptr) is
+ Indx : constant Source_File_Index := Get_Source_File_Index (Sloc (N));
+
function Process (N : Node_Id) return Traverse_Result;
-- Process function for traversing the node tree
@@ -950,6 +952,14 @@ package body Sinput is
Orig : constant Node_Id := Original_Node (N);
begin
+ -- Skip nodes that may have been added during expansion and
+ -- that originate in other units, such as code for contracts
+ -- in subprogram bodies.
+
+ if Get_Source_File_Index (Sloc (Orig)) /= Indx then
+ return Skip;
+ end if;
+
if Sloc (Orig) < Min then
if Sloc (Orig) > No_Location then
Min := Sloc (Orig);
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2020-08-22 21:59 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-08-22 21:59 [gcc/devel/autopar_devel] [Ada] Incorrect source line range on subprogram body with contract Giuliano Belinassi
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).