From: Paul Thomas Date: Fri, 29 Jul 2016 05:16:05 +0000 (+0000) Subject: [multiple changes] X-Git-Tag: releases/gcc-5.5.0~936 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=57f10c54711f2caafebeaf151db55fab530f552b;p=thirdparty%2Fgcc.git [multiple changes] 2016-07-29 Steven G. Kargl Thomas Koenig PR fortran/71883 * frontend-passes.c (gfc_run_passes): Bail out if there are any errors. * error.c (gfc_internal_error): If there are any errors in the buffer, exit with EXIT_FAILURE. 2016-07-29 Paul Thomas PR fortran/71883 * gfortran.dg/pr71883.f90 : New test. From-SVN: r238848 --- diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog index 31986cf04729..a8a80cc7b152 100644 --- a/gcc/fortran/ChangeLog +++ b/gcc/fortran/ChangeLog @@ -1,3 +1,13 @@ +2016-07-29 Steven G. Kargl + Thomas Koenig + + Backport from trunk: + PR fortran/71883 + * frontend-passes.c (gfc_run_passes): Bail out if there are any + errors. + * error.c (gfc_internal_error): If there are any errors in the + buffer, exit with EXIT_FAILURE. + 2016-07-22 Andre Vehreschild Backport from trunk: diff --git a/gcc/fortran/error.c b/gcc/fortran/error.c index 0d292eafb758..18e127f8748f 100644 --- a/gcc/fortran/error.c +++ b/gcc/fortran/error.c @@ -344,7 +344,7 @@ show_locus (locus *loc, int c1, int c2) error_string (f->filename); error_char (':'); - + error_integer (LOCATION_LINE (lb->location)); if ((c1 > 0) || (c2 > 0)) @@ -394,7 +394,7 @@ show_locus (locus *loc, int c1, int c2) 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]); @@ -412,7 +412,7 @@ show_locus (locus *loc, int c1, int c2) 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; @@ -477,7 +477,7 @@ show_loci (locus *l1, locus *l2) 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) @@ -504,11 +504,11 @@ show_loci (locus *l1, locus *l2) 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. */ @@ -724,11 +724,11 @@ error_print (const char *type, const char *format0, va_list argp) /* This is a position specifier. See comment above. */ while (ISDIGIT (*format)) format++; - + /* Skip over the dollar sign. */ format++; } - + switch (*format) { case '%': @@ -782,7 +782,7 @@ error_printf (const char *gmsgid, ...) } -/* 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 @@ -883,10 +883,10 @@ gfc_warning (int opt, const char *gmsgid, va_list ap) ++werrorcount; else if (diagnostic.kind == DK_ERROR) ++werrorcount_buffered; - else + else ++werrorcount, --warningcount, ++warningcount_buffered; } - + va_end (argp); return ret; } @@ -952,7 +952,7 @@ gfc_notify_std_1 (int std, const char *gmsgid, ...) msg1 = _("Warning:"); else msg1 = _("Error:"); - + switch (std) { case GFC_STD_F2008_TS: @@ -1210,7 +1210,7 @@ gfc_diagnostic_starter (diagnostic_context *context, locus. */ pp_set_prefix (context->printer, prefix); } - else + else { /* Otherwise, start again. */ pp_clear_output_area(context->printer); @@ -1320,8 +1320,8 @@ gfc_warning_check (void) 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; } @@ -1488,9 +1488,14 @@ gfc_error_now_1 (const char *gmsgid, ...) 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); @@ -1516,7 +1521,7 @@ gfc_clear_error (void) bool gfc_error_flag_test (void) { - return error_buffer.flag + return error_buffer.flag || !gfc_output_buffer_empty_p (pp_error_buffer); } diff --git a/gcc/fortran/frontend-passes.c b/gcc/fortran/frontend-passes.c index a7635393df5c..92a1f9b75eb2 100644 --- a/gcc/fortran/frontend-passes.c +++ b/gcc/fortran/frontend-passes.c @@ -105,6 +105,7 @@ gfc_run_passes (gfc_namespace *ns) doloop_level = 0; doloop_warn (ns); doloop_list.release (); + int w, e; if (flag_frontend_optimize) { @@ -116,6 +117,10 @@ gfc_run_passes (gfc_namespace *ns) expr_array.release (); } + gfc_get_errors (&w, &e); + if (e > 0) + return; + if (flag_realloc_lhs) realloc_strings (ns); } diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 1e991aeb0c39..20670c4377c0 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,9 @@ +2016-07-29 Paul Thomas + + Backport from trunk: + PR fortran/71883 + * gfortran.dg/pr71883.f90 : New test. + 2016-07-22 Andre Vehreschild Backport from trunk: @@ -140,7 +146,7 @@ * c-c++-common/ubsan/bounds-13.c: New test. 2016-04-13 Jakub Jelinek - + PR c++/70641 * g++.dg/opt/pr70641.C: New test. diff --git a/gcc/testsuite/gfortran.dg/pr71883.f90 b/gcc/testsuite/gfortran.dg/pr71883.f90 new file mode 100644 index 000000000000..23ed6a680bde --- /dev/null +++ b/gcc/testsuite/gfortran.dg/pr71883.f90 @@ -0,0 +1,38 @@ +! { dg-do compile } +! +! Test the fix for pr71883, in which an ICE would follow the error. +! +! Contributed by Gerhard Steinmetz +! +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