error_string (f->filename);
error_char (':');
-
+
error_integer (LOCATION_LINE (lb->location));
if ((c1 > 0) || (c2 > 0))
offset = cmax - terminal_width + 5;
/* Show the line itself, taking care not to print more than what can
- show up on the terminal. Tabs are converted to spaces, and
+ show up on the terminal. Tabs are converted to spaces, and
nonprintable characters are converted to a "\xNN" sequence. */
p = &(lb->line[offset]);
error_char ('\n');
/* Show the '1' and/or '2' corresponding to the column of the error
- locus. Note that a value of -1 for c1 or c2 will simply cause
+ locus. Note that a value of -1 for c1 or c2 will simply cause
the relevant number not to be printed. */
c1 -= offset;
else
m = c1 - c2;
- /* Note that the margin value of 10 here needs to be less than the
+ /* Note that the margin value of 10 here needs to be less than the
margin of 5 used in the calculation of offset in show_locus. */
if (l1->lb != l2->lb || m > terminal_width - 10)
If a locus pointer is given, the actual source line is printed out
and the column is indicated. Since we want the error message at
the bottom of any source file information, we must scan the
- argument list twice -- once to determine whether the loci are
+ argument list twice -- once to determine whether the loci are
present and record this for printing, and once to print the error
message after and loci have been printed. A maximum of two locus
arguments are permitted.
-
+
This function is also called (recursively) by show_locus in the
case of included files; however, as show_locus does not resupply
any loci, the recursion is at most one level deep. */
/* This is a position specifier. See comment above. */
while (ISDIGIT (*format))
format++;
-
+
/* Skip over the dollar sign. */
format++;
}
-
+
switch (*format)
{
case '%':
}
-/* Increment the number of errors, and check whether too many have
+/* Increment the number of errors, and check whether too many have
been printed. */
static void
++werrorcount;
else if (diagnostic.kind == DK_ERROR)
++werrorcount_buffered;
- else
+ else
++werrorcount, --warningcount, ++warningcount_buffered;
}
-
+
va_end (argp);
return ret;
}
msg1 = _("Warning:");
else
msg1 = _("Error:");
-
+
switch (std)
{
case GFC_STD_F2008_TS:
locus. */
pp_set_prefix (context->printer, prefix);
}
- else
+ else
{
/* Otherwise, start again. */
pp_clear_output_area(context->printer);
warningcount += warningcount_buffered;
werrorcount += werrorcount_buffered;
gcc_assert (warningcount_buffered + werrorcount_buffered == 1);
- diagnostic_action_after_output (global_dc,
- warningcount_buffered
+ diagnostic_action_after_output (global_dc,
+ warningcount_buffered
? DK_WARNING : DK_ERROR);
pp->buffer = tmp_buffer;
}
void
gfc_internal_error (const char *gmsgid, ...)
{
+ int e, w;
va_list argp;
diagnostic_info diagnostic;
+ gfc_get_errors (&w, &e);
+ if (e > 0)
+ exit(EXIT_FAILURE);
+
va_start (argp, gmsgid);
diagnostic_set_info (&diagnostic, gmsgid, &argp, UNKNOWN_LOCATION, DK_ICE);
report_diagnostic (&diagnostic);
bool
gfc_error_flag_test (void)
{
- return error_buffer.flag
+ return error_buffer.flag
|| !gfc_output_buffer_empty_p (pp_error_buffer);
}
--- /dev/null
+! { dg-do compile }
+!
+! Test the fix for pr71883, in which an ICE would follow the error.
+!
+! Contributed by Gerhard Steinmetz <gerhard.steinmetz.fortran@t-online.de>
+!
+program p
+ character(3), allocatable :: z(:,:)
+ z(1:2,1:2) = 'abc'
+ z(2,1) = z(12) ! { dg-error "Rank mismatch in array reference" }
+ z(21) = z(1,2) ! { dg-error "Rank mismatch in array reference" }
+contains
+ subroutine a
+ character(3), allocatable :: z(:,:)
+ z(1:2,1:2) = 'abc'
+ z(2,1) = z(-1) ! { dg-error "Rank mismatch in array reference" }
+ z(2,1) = z(99) ! { dg-error "Rank mismatch in array reference" }
+ z(2,1) = z(huge(0)) ! { dg-error "Rank mismatch in array reference" }
+ z(2,1) = z(-huge(0)) ! { dg-error "Rank mismatch in array reference" }
+ z(-1) = z(2,1) ! { dg-error "Rank mismatch in array reference" }
+ z(99) = z(2,1) ! { dg-error "Rank mismatch in array reference" }
+ z(huge(0)) = z(2,1) ! { dg-error "Rank mismatch in array reference" }
+ z(-huge(0)) = z(2,1) ! { dg-error "Rank mismatch in array reference" }
+ end subroutine
+
+ subroutine b
+ character(:), allocatable :: z(:,:)
+ z(1:2,1:2) = 'abc'
+ z(2,1) = z(-1) ! { dg-error "Rank mismatch in array reference" }
+ z(2,1) = z(99) ! { dg-error "Rank mismatch in array reference" }
+ z(2,1) = z(huge(0)) ! { dg-error "Rank mismatch in array reference" }
+ z(2,1) = z(-huge(0)) ! { dg-error "Rank mismatch in array reference" }
+ z(-1) = z(2,1) ! { dg-error "Rank mismatch in array reference" }
+ z(99) = z(2,1) ! { dg-error "Rank mismatch in array reference" }
+ z(huge(0)) = z(2,1) ! { dg-error "Rank mismatch in array reference" }
+ z(-huge(0)) = z(2,1) ! { dg-error "Rank mismatch in array reference" }
+ end subroutine
+end