2011-09-26 Janus Weil <janus@gcc.gnu.org>
authorjanus <janus@138bc75d-0d04-0410-961f-82ee72b054a4>
Mon, 26 Sep 2011 20:05:43 +0000 (20:05 +0000)
committerjanus <janus@138bc75d-0d04-0410-961f-82ee72b054a4>
Mon, 26 Sep 2011 20:05:43 +0000 (20:05 +0000)
PR fortran/50515
* resolve.c (resolve_common_blocks): Check for EXTERNAL attribute.

PR fortran/50517
* interface.c (gfc_compare_interfaces): Bugfix in check for result type.

2011-09-26  Janus Weil  <janus@gcc.gnu.org>

PR fortran/50515
* gfortran.dg/common_15.f90: New.

PR fortran/50517
* gfortran.dg/dummy_procedure_5.f90: New.
* gfortran.dg/interface_26.f90: Modified error message.
* gfortran.dg/proc_ptr_11.f90: Ditto.
* gfortran.dg/proc_ptr_15.f90: Ditto.
* gfortran.dg/proc_ptr_comp_20.f90: Ditto.
* gfortran.dg/proc_ptr_result_5.f90: Ditto.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@179213 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/fortran/ChangeLog
gcc/fortran/interface.c
gcc/fortran/resolve.c
gcc/testsuite/ChangeLog
gcc/testsuite/gfortran.dg/common_15.f90 [new file with mode: 0644]
gcc/testsuite/gfortran.dg/dummy_procedure_5.f90 [new file with mode: 0644]
gcc/testsuite/gfortran.dg/interface_26.f90
gcc/testsuite/gfortran.dg/proc_ptr_11.f90
gcc/testsuite/gfortran.dg/proc_ptr_15.f90
gcc/testsuite/gfortran.dg/proc_ptr_comp_20.f90
gcc/testsuite/gfortran.dg/proc_ptr_result_5.f90

index 02ee593..5900b63 100644 (file)
@@ -1,3 +1,11 @@
+2011-09-26  Janus Weil  <janus@gcc.gnu.org>
+
+       PR fortran/50515
+       * resolve.c (resolve_common_blocks): Check for EXTERNAL attribute.
+
+       PR fortran/50517
+       * interface.c (gfc_compare_interfaces): Bugfix in check for result type.
+
 2011-09-22  Janus Weil  <janus@gcc.gnu.org>
 
        PR fortran/41733
index 7cbe163..f65087b 100644 (file)
@@ -1121,13 +1121,13 @@ gfc_compare_interfaces (gfc_symbol *s1, gfc_symbol *s2, const char *name2,
     {
       if (s1->attr.function && s2->attr.function)
        {
-         /* If both are functions, check type and kind.  */
+         /* If both are functions, check result type.  */
          if (s1->ts.type == BT_UNKNOWN)
            return 1;
-         if ((s1->ts.type != s2->ts.type) || (s1->ts.kind != s2->ts.kind))
+         if (!compare_type_rank (s1,s2))
            {
              if (errmsg != NULL)
-               snprintf (errmsg, err_len, "Type/kind mismatch in return value "
+               snprintf (errmsg, err_len, "Type/rank mismatch in return value "
                          "of '%s'", name2);
              return 0;
            }
index 62750af..13ecf1c 100644 (file)
@@ -905,6 +905,10 @@ resolve_common_blocks (gfc_symtree *common_root)
     gfc_error ("COMMON block '%s' at %L is used as PARAMETER at %L",
               sym->name, &common_root->n.common->where, &sym->declared_at);
 
+  if (sym->attr.external)
+    gfc_error ("COMMON block '%s' at %L can not have the EXTERNAL attribute",
+              sym->name, &common_root->n.common->where);
+
   if (sym->attr.intrinsic)
     gfc_error ("COMMON block '%s' at %L is also an intrinsic procedure",
               sym->name, &common_root->n.common->where);
index 56233c0..c973b42 100644 (file)
@@ -1,3 +1,16 @@
+2011-09-26  Janus Weil  <janus@gcc.gnu.org>
+
+       PR fortran/50515
+       * gfortran.dg/common_15.f90: New.
+
+       PR fortran/50517
+       * gfortran.dg/dummy_procedure_5.f90: New.
+       * gfortran.dg/interface_26.f90: Modified error message.
+       * gfortran.dg/proc_ptr_11.f90: Ditto.
+       * gfortran.dg/proc_ptr_15.f90: Ditto.
+       * gfortran.dg/proc_ptr_comp_20.f90: Ditto.
+       * gfortran.dg/proc_ptr_result_5.f90: Ditto.
+
 2011-09-26  Jason Merrill  <jason@redhat.com>
 
        PR c++/50512
diff --git a/gcc/testsuite/gfortran.dg/common_15.f90 b/gcc/testsuite/gfortran.dg/common_15.f90
new file mode 100644 (file)
index 0000000..20694fd
--- /dev/null
@@ -0,0 +1,9 @@
+! { dg-do compile }
+!
+! PR 50515: gfortran should not accept an external that is a common (r178939)
+!
+! Contributed by Vittorio Zecca <zeccav@gmail.com>
+
+common/sub/ a  ! { dg-error "can not have the EXTERNAL attribute" }
+external sub
+end
diff --git a/gcc/testsuite/gfortran.dg/dummy_procedure_5.f90 b/gcc/testsuite/gfortran.dg/dummy_procedure_5.f90
new file mode 100644 (file)
index 0000000..0133cbf
--- /dev/null
@@ -0,0 +1,26 @@
+! { dg-do compile }
+!
+! PR 50517: gfortran must detect that actual argument type is different from dummy argument type (r178939)
+!
+! Contributed by Vittorio Zecca <zeccav@gmail.com>
+
+program main
+
+  type t
+    integer g
+  end type
+
+  type u
+    integer g
+  end type
+
+  type(u), external :: ufunc
+  call sub(ufunc)            ! { dg-error "Type/rank mismatch in return value" }
+
+contains
+
+  subroutine sub(tfunc)
+    type(t), external :: tfunc
+  end subroutine
+
+end program 
index c51dbd0..54ede6d 100644 (file)
@@ -37,7 +37,7 @@ CONTAINS
     END INTERFACE
     INTEGER, EXTERNAL :: UserOp 
 
-    res = UserFunction( a,b, UserOp ) ! { dg-error "Type/kind mismatch in return value" }
+    res = UserFunction( a,b, UserOp ) ! { dg-error "Type/rank mismatch in return value" }
 
     if( res .lt. 10 ) then
        res = recSum( a, res, UserFunction, UserOp ) 
index 4e8b3c2..d1c7b48 100644 (file)
@@ -40,11 +40,11 @@ program bsp
   p2 => p1
   p1 => p2
 
-  p1 => abs   ! { dg-error "Type/kind mismatch in return value" }
-  p2 => abs   ! { dg-error "Type/kind mismatch in return value" }
+  p1 => abs   ! { dg-error "Type/rank mismatch in return value" }
+  p2 => abs   ! { dg-error "Type/rank mismatch in return value" }
 
   p3 => dsin
-  p3 => sin   ! { dg-error "Type/kind mismatch in return value" }
+  p3 => sin   ! { dg-error "Type/rank mismatch in return value" }
 
   contains
 
index 3d37ee2..f5a7486 100644 (file)
@@ -19,10 +19,10 @@ p4 => p3
 p6 => p1
 
 ! invalid
-p1 => iabs   ! { dg-error "Type/kind mismatch in return value" }
-p1 => p2     ! { dg-error "Type/kind mismatch in return value" }
-p1 => p5     ! { dg-error "Type/kind mismatch in return value" }
-p6 => iabs   ! { dg-error "Type/kind mismatch in return value" }
+p1 => iabs   ! { dg-error "Type/rank mismatch in return value" }
+p1 => p2     ! { dg-error "Type/rank mismatch in return value" }
+p1 => p5     ! { dg-error "Type/rank mismatch in return value" }
+p6 => iabs   ! { dg-error "Type/rank mismatch in return value" }
 p4 => p2     ! { dg-error "is not a subroutine" }
 
 contains
index 57660c7..e38e654 100644 (file)
@@ -27,11 +27,11 @@ type(t2) :: o2
 procedure(logical),pointer :: pp1
 procedure(complex),pointer :: pp2
 
-pp1 => pp2        ! { dg-error "Type/kind mismatch" }
-pp2 => o2%ppc     ! { dg-error "Type/kind mismatch" }
+pp1 => pp2        ! { dg-error "Type/rank mismatch" }
+pp2 => o2%ppc     ! { dg-error "Type/rank mismatch" }
 
-o1%ppc => pp1     ! { dg-error "Type/kind mismatch" }
-o1%ppc => o2%ppc  ! { dg-error "Type/kind mismatch" }
+o1%ppc => pp1     ! { dg-error "Type/rank mismatch" }
+o1%ppc => o2%ppc  ! { dg-error "Type/rank mismatch" }
 
 contains
 
index 0e60cbb..de03523 100644 (file)
@@ -6,7 +6,7 @@
 
 program test
   procedure(real), pointer :: p
-  p => f()  ! { dg-error "Type/kind mismatch in return value" }
+  p => f()  ! { dg-error "Type/rank mismatch in return value" }
 contains
  function f()
    pointer :: f