[COMMITTED] ada: Make internal_error_function more robust
Checks
Commit Message
From: Eric Botcazou <ebotcazou@adacore.com>
gcc/ada/
* gcc-interface/misc.cc (internal_error_function): Be prepared for
an input_location set to UNKNOWN_LOCATION.
Tested on x86_64-pc-linux-gnu, committed on master.
---
gcc/ada/gcc-interface/misc.cc | 22 ++++++++++++++++------
1 file changed, 16 insertions(+), 6 deletions(-)
@@ -330,13 +330,23 @@ internal_error_function (diagnostic_context *context, const char *msgid,
sp.Bounds = &temp;
sp.Array = buffer;
- xloc = expand_location (input_location);
- if (context->show_column && xloc.column != 0)
- loc = xasprintf ("%s:%d:%d", xloc.file, xloc.line, xloc.column);
+ if (input_location == UNKNOWN_LOCATION)
+ {
+ loc = NULL;
+ temp_loc.Low_Bound = 1;
+ temp_loc.High_Bound = 0;
+ }
else
- loc = xasprintf ("%s:%d", xloc.file, xloc.line);
- temp_loc.Low_Bound = 1;
- temp_loc.High_Bound = strlen (loc);
+ {
+ xloc = expand_location (input_location);
+ if (context->show_column && xloc.column != 0)
+ loc = xasprintf ("%s:%d:%d", xloc.file, xloc.line, xloc.column);
+ else
+ loc = xasprintf ("%s:%d", xloc.file, xloc.line);
+ temp_loc.Low_Bound = 1;
+ temp_loc.High_Bound = strlen (loc);
+ }
+
sp_loc.Bounds = &temp_loc;
sp_loc.Array = loc;