re PR fortran/33917 (Rejects valid PROCEDURE declarations)
authorTobias Burnus <burnus@net-b.de>
Thu, 8 Nov 2007 15:28:30 +0000 (16:28 +0100)
committerTobias Burnus <burnus@gcc.gnu.org>
Thu, 8 Nov 2007 15:28:30 +0000 (16:28 +0100)
2007-11-08  Tobias Burnus  <burnus@net-b.de>

        PR fortran/33917
        * interface.c (check_sym_interfaces): Disallow PROCEDURE-declared
        procedures for MODULE PROCEDURE.
        * decl.c (match_procedure_in_interface): Do not mark as procedure.

2007-11-08  Tobias Burnus  <burnus@net-b.de>

        PR fortran/33917
        * gfortran.dg/proc_decl_5.f90: New.
        * gfortran.dg/proc_decl_6.f90: New.

From-SVN: r130002

gcc/fortran/ChangeLog
gcc/fortran/decl.c
gcc/fortran/interface.c
gcc/testsuite/ChangeLog
gcc/testsuite/gfortran.dg/proc_decl_5.f90 [new file with mode: 0644]
gcc/testsuite/gfortran.dg/proc_decl_6.f90 [new file with mode: 0644]

index 42c726c48af9d6da67b118aa547c28b4655dde4e..8103821dde15d266ee30b101b9ff2d90310f49d0 100644 (file)
@@ -1,3 +1,10 @@
+2007-11-08  Tobias Burnus  <burnus@net-b.de>
+
+       PR fortran/33917
+       * interface.c (check_sym_interfaces): Disallow PROCEDURE-declared
+       procedures for MODULE PROCEDURE.
+       * decl.c (match_procedure_in_interface): Do not mark as procedure.
+
 2007-11-03  Francois-Xavier Coudert  <fxcoudert@gcc.gnu.org>
 
        PR fortran/33881
index dacfe4a318ab8745e5ed57a06a2cc57ef3f7937a..74c655d0792156a1707c25fb7b4c9b481905e3b0 100644 (file)
@@ -4091,8 +4091,6 @@ match_procedure_in_interface (void)
       if (gfc_add_interface (sym) == FAILURE)
        return MATCH_ERROR;
 
-      sym->attr.procedure = 1;
-
       if (gfc_match_eos () == MATCH_YES)
        break;
       if (gfc_match_char (',') != MATCH_YES)
index 39f4e9283a2b639542328bf8ed8b415167cc96ac..7f6406a94e62cc0b605262c54dd1f836b60fd2a0 100644 (file)
@@ -1137,7 +1137,9 @@ check_sym_interfaces (gfc_symbol *sym)
 
       for (p = sym->generic; p; p = p->next)
        {
-         if (p->sym->attr.mod_proc && p->sym->attr.if_source != IFSRC_DECL)
+         if (p->sym->attr.mod_proc
+             && (p->sym->attr.if_source != IFSRC_DECL
+                 || p->sym->attr.procedure))
            {
              gfc_error ("'%s' at %L is not a module procedure",
                         p->sym->name, &p->where);
index 676fb88bd7b057363ca59047c643d3f9c561b6c5..b07ada0da4e1adbe111aae58ff68028e3c8f1cb5 100644 (file)
@@ -1,3 +1,9 @@
+2007-11-08  Tobias Burnus  <burnus@net-b.de>
+
+       PR fortran/33917
+       * gfortran.dg/proc_decl_5.f90: New.
+       * gfortran.dg/proc_decl_6.f90: New.
+
 2007-11-08  Jakub Jelinek  <jakub@redhat.com>
 
        PR tree-optimization/32575
diff --git a/gcc/testsuite/gfortran.dg/proc_decl_5.f90 b/gcc/testsuite/gfortran.dg/proc_decl_5.f90
new file mode 100644 (file)
index 0000000..b327d5c
--- /dev/null
@@ -0,0 +1,28 @@
+! { dg-do run }
+! PR fortran/33945
+!
+! PROCEDURE in the interface was wrongly rejected
+module modproc
+  implicit none
+  interface bar
+    procedure x
+  end interface bar
+  procedure(sub) :: x
+  interface
+    integer function sub()
+    end function sub
+  end interface
+end module modproc
+
+integer function x()
+  implicit none
+  x = -5
+end function x
+
+program test
+  use modproc
+  implicit none
+  if(x() /= -5) call abort()
+end program test
+
+! { dg-final { cleanup-modules "modproc" } }
diff --git a/gcc/testsuite/gfortran.dg/proc_decl_6.f90 b/gcc/testsuite/gfortran.dg/proc_decl_6.f90
new file mode 100644 (file)
index 0000000..d2a6a1d
--- /dev/null
@@ -0,0 +1,17 @@
+! { dg-do compile }
+! PR fortran/33945
+!
+! MODULE PROCEDURE in the interface was wrongly accepted
+module modproc2
+  implicit none
+  interface
+    subroutine x
+    end subroutine x
+  end interface
+  procedure(x) :: y
+  interface bar
+    module procedure y ! { dg-error "not a module procedure" }
+  end interface bar
+end module modproc2
+
+end