[11/13] ada: don't map NULL decl to locus

Message ID orr0wlea1j.fsf@lxoliva.fsfla.org
State Accepted
Headers
Series [01/13] scoped tables: insert before further lookups |

Checks

Context Check Description
snail/gcc-patch-check success Github commit url

Commit Message

Alexandre Oliva Dec. 27, 2022, 4:38 a.m. UTC
  When decl is NULL, don't record its mapping in the
decl_to_instance_map.

Regstrapped on x86_64-linux-gnu.  Ok to install?


for  gcc/ada/ChangeLog

	* gcc-interface/trans.cc (Sloc_to_locus): Don't map NULL decl.
---
 gcc/ada/gcc-interface/trans.cc |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
  

Comments

Jeff Law Dec. 27, 2022, 3:33 p.m. UTC | #1
On 12/26/22 21:38, Alexandre Oliva via Gcc-patches wrote:
> 
> When decl is NULL, don't record its mapping in the
> decl_to_instance_map.
> 
> Regstrapped on x86_64-linux-gnu.  Ok to install?
> 
> 
> for  gcc/ada/ChangeLog
> 
> 	* gcc-interface/trans.cc (Sloc_to_locus): Don't map NULL decl.
OK assuming that a NULL "decl" is valid -- you're in a much better 
position than me to assess validity of a NULL "decl" here.

jeff
  
Arnaud Charlet Dec. 27, 2022, 4:54 p.m. UTC | #2
>> When decl is NULL, don't record its mapping in the
>> decl_to_instance_map.
>> Regstrapped on x86_64-linux-gnu.  Ok to install?
>> for  gcc/ada/ChangeLog
>>    * gcc-interface/trans.cc (Sloc_to_locus): Don't map NULL decl.
> OK assuming that a NULL "decl" is valid -- you're in a much better position than me to assess validity of a NULL "decl" here.

I confirm that this is OK and expected.

Arno
  

Patch

diff --git a/gcc/ada/gcc-interface/trans.cc b/gcc/ada/gcc-interface/trans.cc
index 59332f93614a9..6579ad11cc284 100644
--- a/gcc/ada/gcc-interface/trans.cc
+++ b/gcc/ada/gcc-interface/trans.cc
@@ -10564,7 +10564,7 @@  Sloc_to_locus (Source_Ptr Sloc, location_t *locus, bool clear_column,
   *locus
     = linemap_position_for_line_and_column (line_table, map, line, column);
 
-  if (file_map && file_map[file - 1].Instance)
+  if (decl && file_map && file_map[file - 1].Instance)
     decl_to_instance_map->put (decl, file_map[file - 1].Instance);
 
   return true;