]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
Fix error-recovery ICE in check_proc_interface
authorTobias Burnus <burnus@net-b.de>
Fri, 12 Oct 2018 18:13:25 +0000 (20:13 +0200)
committerTobias Burnus <burnus@gcc.gnu.org>
Fri, 12 Oct 2018 18:13:25 +0000 (20:13 +0200)
        PR fortran/58787
        * decl.c (get_proc_name): Return with error before
        creating sym_tree.

        PR fortran/58787
        * gfortran.dg/goacc/pr77765.f90: Modify dg-error.
        * gfortran.dg/interface_42.f90: Ditto.
        * gfortran.dg/internal_references_1.f90: Ditto.
        * gfortran.dg/invalid_procedure_name.f90: Ditto.
        * gfortran.dg/pr65453.f90: Ditto.
        * gfortran.dg/pr77414.f90: Ditto.
        * gfortran.dg/pr78741.f90: Ditto.
        * gfortran.dg/same_name_2.f90: Ditto.

From-SVN: r265125

gcc/fortran/ChangeLog
gcc/fortran/decl.c
gcc/testsuite/ChangeLog
gcc/testsuite/gfortran.dg/goacc/pr77765.f90
gcc/testsuite/gfortran.dg/interface_42.f90
gcc/testsuite/gfortran.dg/internal_references_1.f90
gcc/testsuite/gfortran.dg/invalid_procedure_name.f90
gcc/testsuite/gfortran.dg/pr65453.f90
gcc/testsuite/gfortran.dg/pr77414.f90
gcc/testsuite/gfortran.dg/pr78741.f90
gcc/testsuite/gfortran.dg/same_name_2.f90

index ac2bf3a49ef6ec421176e4717ce875ca1d36b9c3..21813638bf308decd20427e49f9b89e239acdd7d 100644 (file)
@@ -1,3 +1,9 @@
+2018-10-12  Tobias Burnus <burnus@net-b.de>
+
+       PR fortran/58787
+       * decl.c (get_proc_name): Return with error before
+       creating sym_tree.
+
 2018-10-11  Tobias Burnus <burnus@net-b.de>
 
        Revert:
index 7f79811d1529c4e720b9847fc811e3c2d54349e5..87c736fb2dbc44b9c3c308bd5430daa06383697f 100644 (file)
@@ -1231,28 +1231,39 @@ get_proc_name (const char *name, gfc_symbol **result, bool module_fcn_entry)
          && sym->attr.proc != 0
          && (sym->attr.subroutine || sym->attr.function || sym->attr.entry)
          && sym->attr.if_source != IFSRC_UNKNOWN)
-       gfc_error_now ("Procedure %qs at %C is already defined at %L",
-                      name, &sym->declared_at);
-
+       {
+         gfc_error_now ("Procedure %qs at %C is already defined at %L",
+                        name, &sym->declared_at);
+         return true;
+       }
       if (sym->attr.flavor != 0
          && sym->attr.entry && sym->attr.if_source != IFSRC_UNKNOWN)
-       gfc_error_now ("Procedure %qs at %C is already defined at %L",
-                      name, &sym->declared_at);
+       {
+         gfc_error_now ("Procedure %qs at %C is already defined at %L",
+                        name, &sym->declared_at);
+         return true;
+       }
 
       if (sym->attr.external && sym->attr.procedure
          && gfc_current_state () == COMP_CONTAINS)
-       gfc_error_now ("Contained procedure %qs at %C clashes with "
-                       "procedure defined at %L",
-                      name, &sym->declared_at);
+       {
+         gfc_error_now ("Contained procedure %qs at %C clashes with "
+                        "procedure defined at %L",
+                        name, &sym->declared_at);
+         return true;
+       }
 
       /* Trap a procedure with a name the same as interface in the
         encompassing scope.  */
       if (sym->attr.generic != 0
          && (sym->attr.subroutine || sym->attr.function)
          && !sym->attr.mod_proc)
-       gfc_error_now ("Name %qs at %C is already defined"
-                      " as a generic interface at %L",
-                      name, &sym->declared_at);
+       {
+         gfc_error_now ("Name %qs at %C is already defined"
+                        " as a generic interface at %L",
+                        name, &sym->declared_at);
+         return true;
+       }
 
       /* Trap declarations of attributes in encompassing scope.  The
         signature for this is that ts.kind is set.  Legitimate
@@ -1263,8 +1274,11 @@ get_proc_name (const char *name, gfc_symbol **result, bool module_fcn_entry)
          && gfc_current_ns->parent != NULL
          && sym->attr.access == 0
          && !module_fcn_entry)
-       gfc_error_now ("Procedure %qs at %C has an explicit interface "
+       {
+         gfc_error_now ("Procedure %qs at %C has an explicit interface "
                       "from a previous declaration",  name);
+         return true;
+       }
     }
 
   /* C1246 (R1225) MODULE shall appear only in the function-stmt or
@@ -1276,17 +1290,23 @@ get_proc_name (const char *name, gfc_symbol **result, bool module_fcn_entry)
       && !current_attr.module_procedure
       && sym->attr.proc == PROC_MODULE
       && gfc_state_stack->state == COMP_CONTAINS)
-    gfc_error_now ("Procedure %qs defined in interface body at %L "
-                  "clashes with internal procedure defined at %C",
-                   name, &sym->declared_at);
+    {
+      gfc_error_now ("Procedure %qs defined in interface body at %L "
+                    "clashes with internal procedure defined at %C",
+                    name, &sym->declared_at);
+      return true;
+    }
 
   if (sym && !sym->gfc_new
       && sym->attr.flavor != FL_UNKNOWN
       && sym->attr.referenced == 0 && sym->attr.subroutine == 1
       && gfc_state_stack->state == COMP_CONTAINS
       && gfc_state_stack->previous->state == COMP_SUBROUTINE)
-    gfc_error_now ("Procedure %qs at %C is already defined at %L",
-                   name, &sym->declared_at);
+    {
+      gfc_error_now ("Procedure %qs at %C is already defined at %L",
+                    name, &sym->declared_at);
+      return true;
+    }
 
   if (gfc_current_ns->parent == NULL || *result == NULL)
     return rc;
index 964f4ea4c11f4177abbf04878f96c30081589c5b..4991c2ef54fbaeba3fd1cffdd5a8cfc2e7410d34 100644 (file)
@@ -1,3 +1,15 @@
+2018-10-12  Tobias Burnus <burnus@net-b.de>
+
+       PR fortran/58787
+       * gfortran.dg/goacc/pr77765.f90: Modify dg-error.
+       * gfortran.dg/interface_42.f90: Ditto.
+       * gfortran.dg/internal_references_1.f90: Ditto.
+       * gfortran.dg/invalid_procedure_name.f90: Ditto.
+       * gfortran.dg/pr65453.f90: Ditto.
+       * gfortran.dg/pr77414.f90: Ditto.
+       * gfortran.dg/pr78741.f90: Ditto.
+       * gfortran.dg/same_name_2.f90: Ditto.
+
 2018-10-12  Wilco Dijkstra  <wdijkstr@arm.com>
 
        * gcc.target/aarch64/popcnt.c: Test zero-extended popcount.
index 3819cf70c04b06319d92ff158a742758e5c83826..afa0a56a6324edb4ecc533c0d1ad0ff5b0034f4b 100644 (file)
@@ -13,7 +13,6 @@ contains
 end module m
 
 ! { dg-error "Procedure 'f' at .1. is already defined" "" { target *-*-* } 8 }
-! { dg-error "Duplicate RECURSIVE attribute specified" "" { target *-*-* } 8 }
 ! { dg-error ".1." "" { target *-*-* } 10 }
-! { dg-error "Unexpected ..ACC ROUTINE" "" { target *-*-* } 11 }
+! { dg-error "Syntax error in ..ACC ROUTINE . NAME . at .1., invalid function name f" "" { target *-*-* } 11 }
 ! { dg-error "Expecting END MODULE statement" "" { target *-*-* } 12 }
index 1fd47b920dfd0638419ffe02ed0e46e78897f3f7..d260755eb6a3612c7702607e44f28b81e860eb1c 100644 (file)
@@ -13,7 +13,7 @@ module copy
 
    contains
 
-      subroutine foo_da(da, copy) ! { dg-error "defined in interface body" }
+      subroutine foo_da(da, copy) ! { dg-error "defined in interface body|PROCEDURE attribute conflicts with PROCEDURE attribute" }
          integer, intent(in) :: da(:)
          integer, allocatable, intent(out) :: copy(:)
          allocate( copy( size(da) ) )
@@ -21,4 +21,4 @@ module copy
       end subroutine foo_da
 
 end module copy
-{ dg-prune-output "compilation terminated" }
+{ dg-prune-output "compilation terminated" }
index 2434e28d5e30f4c1e6bd659ec07012f5d55d477e..b53ab325aded6dca00c2c42b8957f557b1311dfa 100644 (file)
@@ -16,8 +16,8 @@ contains
   end subroutine
 
   subroutine p (i)   ! { dg-error "is already defined" }
-   integer :: i
-  end subroutine
+   integer :: i   ! { dg-error "Unexpected data declaration statement in CONTAINS section" }
+  end subroutine  ! { dg-error "Expecting END MODULE statement" }
 end module
 !
 ! PR25124 - would happily ignore the declaration of foo in the main program.
@@ -27,8 +27,8 @@ x = bar ()          ! This is OK because it is a regular reference.
 x = foo ()
 contains
     function foo () ! { dg-error "explicit interface from a previous" }
-      foo = 1.0
-    end function foo
+      foo = 1.0  ! { dg-error "Unexpected assignment statement in CONTAINS section" }
+    end function foo ! { dg-error "Expecting END PROGRAM statement" }
     function bar ()
       bar = 1.0
     end function bar
index dd319382b4d92b363cdfc6beac23ec2ff0e9175b..74eaa636ae0168593d4bbfbc6d279a105d8a6a5d 100644 (file)
@@ -9,6 +9,6 @@ INTERFACE I1 ! { dg-error "" }
 END INTERFACE I1
 CONTAINS
  SUBROUTINE I1(I) ! { dg-error "already defined as a generic" }
- END SUBROUTINE I1
+ END SUBROUTINE I1 ! { dg-error "Expecting END PROGRAM statement" }
 END
 
index 8d30116b79d02402a342c29a56f6210bf1868af9..9f40121b4432194daf8e9f523419bafcd0ae81ab 100644 (file)
@@ -5,4 +5,4 @@ procedure() :: foo   ! { dg-error "(1)" }
   contains
     subroutine foo() ! { dg-error "clashes with procedure" }
     end
-end
+end ! { dg-error "Two main PROGRAMs" }
index 222c1a315422fd55e21ae604e49cc85be956a46f..00f14e35a8d93ddc851fa58befdb8b027f1754bc 100644 (file)
@@ -4,6 +4,6 @@ subroutine a(x)               ! { dg-error "(1)" }
    character(*) :: x
    contains
       subroutine a(x)         ! { dg-error " is already defined at" }
-         character(*) :: x
+         character(*) :: x    ! { dg-error "Unexpected data declaration statement in CONTAINS section" }
       end subroutine a
-end subroutine a
+end subroutine a  ! { dg-error "Expecting END PROGRAM statement" }
index 6eb85789f942935d8247139b9668035b4dfa2f46..707b2996307aaa21ea44cf81e6a66c4c8f657ab5 100644 (file)
@@ -11,6 +11,6 @@ entry g(n, x)           ! { dg-error "is already defined" }
    x = 'b'
 contains
    subroutine g         ! { dg-error "(1)" }
-      z(1) = x(1:1)
+      z(1) = x(1:1) ! { dg-error "Unclassifiable statement" }
    end
 end
index 463ac8533f8b0dadade415a9091cd050ff0624ed..f37de55e651925329ab3f50dcd24138b2745211d 100644 (file)
@@ -10,6 +10,6 @@ subroutine aa ! { dg-error "Procedure" }
    write(*,*) 'AA'
 end subroutine aa
 subroutine aa ! { dg-error "is already defined" }
-   write(*,*) 'BB'
-end subroutine aa
+   write(*,*) 'BB' ! { dg-error "Unexpected WRITE statement in CONTAINS section" }
+end subroutine aa ! { dg-error "Expecting END MODULE statement" }
 end module