]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
[multiple changes]
authorPaul Thomas <pault@gcc.gnu.org>
Fri, 29 Jul 2016 05:16:05 +0000 (05:16 +0000)
committerPaul Thomas <pault@gcc.gnu.org>
Fri, 29 Jul 2016 05:16:05 +0000 (05:16 +0000)
2016-07-29  Steven G. Kargl  <kargl@gcc.gnu.org>
    Thomas Koenig  <tkoenig@gcc.gnu.org>

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  <pault@gcc.gnu.org>

PR fortran/71883
* gfortran.dg/pr71883.f90 : New test.

From-SVN: r238848

gcc/fortran/ChangeLog
gcc/fortran/error.c
gcc/fortran/frontend-passes.c
gcc/testsuite/ChangeLog
gcc/testsuite/gfortran.dg/pr71883.f90 [new file with mode: 0644]

index 31986cf04729ddc0b2fa11d1e3ba746cee7e896d..a8a80cc7b15201654181623dd88c0947ff17ca4e 100644 (file)
@@ -1,3 +1,13 @@
+2016-07-29  Steven G. Kargl  <kargl@gcc.gnu.org>
+           Thomas Koenig  <tkoenig@gcc.gnu.org>
+
+       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  <vehre@gcc.gnu.org>
 
        Backport from trunk:
index 0d292eafb7580e45cfbde62023cba5a90bfc7dd9..18e127f8748fa1bd241e2c450160da7dd7d1ce58 100644 (file)
@@ -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);
 }
 
index a7635393df5c5dc0095448bacdd715db8d7dd515..92a1f9b75eb258c2fa2301e44329cace588472a6 100644 (file)
@@ -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);
 }
index 1e991aeb0c39f60a991110a77b49cf6db4c0227d..20670c4377c05cbd217632c9980f6393e88faf4d 100644 (file)
@@ -1,3 +1,9 @@
+2016-07-29  Paul Thomas  <pault@gcc.gnu.org>
+
+       Backport from trunk:
+       PR fortran/71883
+       * gfortran.dg/pr71883.f90 : New test.
+
 2016-07-22  Andre Vehreschild  <vehre@gcc.gnu.org>
 
        Backport from trunk:
        * c-c++-common/ubsan/bounds-13.c: New test.
 
        2016-04-13  Jakub Jelinek  <jakub@redhat.com>
+
        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 (file)
index 0000000..23ed6a6
--- /dev/null
@@ -0,0 +1,38 @@
+! { 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