diff options
author | Ed Schonberg <schonberg@adacore.com> | 2020-01-23 11:00:46 -0500 |
---|---|---|
committer | Pierre-Marie de Rodat <derodat@adacore.com> | 2020-06-04 05:11:06 -0400 |
commit | 0b27ccce0849ef93b95aebae12c8a0e77929810e (patch) | |
tree | fa630c2b5ab9578d74d39631e14fe088246804bf /gcc | |
parent | 593627b4562814d2206e53e9ad6ce2e85295aa58 (diff) | |
download | gcc-0b27ccce0849ef93b95aebae12c8a0e77929810e.zip gcc-0b27ccce0849ef93b95aebae12c8a0e77929810e.tar.gz gcc-0b27ccce0849ef93b95aebae12c8a0e77929810e.tar.bz2 |
[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.
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/ada/sinput.adb | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/gcc/ada/sinput.adb b/gcc/ada/sinput.adb index 4c342d9..9f2669e 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); |