diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog index 02ee59319c3..5900b63f162 100644 --- a/gcc/fortran/ChangeLog +++ b/gcc/fortran/ChangeLog @@ -1,3 +1,11 @@ +2011-09-26 Janus Weil + + 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 PR fortran/41733 diff --git a/gcc/fortran/interface.c b/gcc/fortran/interface.c index 7cbe16319b4..f65087baff1 100644 --- a/gcc/fortran/interface.c +++ b/gcc/fortran/interface.c @@ -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; } diff --git a/gcc/fortran/resolve.c b/gcc/fortran/resolve.c index 62750af850b..13ecf1c2bf6 100644 --- a/gcc/fortran/resolve.c +++ b/gcc/fortran/resolve.c @@ -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); diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 56233c0a64a..c973b423f30 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,16 @@ +2011-09-26 Janus Weil + + 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 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 index 00000000000..20694fd143b --- /dev/null +++ b/gcc/testsuite/gfortran.dg/common_15.f90 @@ -0,0 +1,9 @@ +! { dg-do compile } +! +! PR 50515: gfortran should not accept an external that is a common (r178939) +! +! Contributed by Vittorio Zecca + +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 index 00000000000..0133cbf7d1f --- /dev/null +++ b/gcc/testsuite/gfortran.dg/dummy_procedure_5.f90 @@ -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 + +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 diff --git a/gcc/testsuite/gfortran.dg/interface_26.f90 b/gcc/testsuite/gfortran.dg/interface_26.f90 index c51dbd093c4..54ede6d53eb 100644 --- a/gcc/testsuite/gfortran.dg/interface_26.f90 +++ b/gcc/testsuite/gfortran.dg/interface_26.f90 @@ -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 ) diff --git a/gcc/testsuite/gfortran.dg/proc_ptr_11.f90 b/gcc/testsuite/gfortran.dg/proc_ptr_11.f90 index 4e8b3c25314..d1c7b4869df 100644 --- a/gcc/testsuite/gfortran.dg/proc_ptr_11.f90 +++ b/gcc/testsuite/gfortran.dg/proc_ptr_11.f90 @@ -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 diff --git a/gcc/testsuite/gfortran.dg/proc_ptr_15.f90 b/gcc/testsuite/gfortran.dg/proc_ptr_15.f90 index 3d37ee2d995..f5a748660e5 100644 --- a/gcc/testsuite/gfortran.dg/proc_ptr_15.f90 +++ b/gcc/testsuite/gfortran.dg/proc_ptr_15.f90 @@ -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 diff --git a/gcc/testsuite/gfortran.dg/proc_ptr_comp_20.f90 b/gcc/testsuite/gfortran.dg/proc_ptr_comp_20.f90 index 57660c7b70e..e38e6545370 100644 --- a/gcc/testsuite/gfortran.dg/proc_ptr_comp_20.f90 +++ b/gcc/testsuite/gfortran.dg/proc_ptr_comp_20.f90 @@ -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 diff --git a/gcc/testsuite/gfortran.dg/proc_ptr_result_5.f90 b/gcc/testsuite/gfortran.dg/proc_ptr_result_5.f90 index 0e60cbb2a81..de035233675 100644 --- a/gcc/testsuite/gfortran.dg/proc_ptr_result_5.f90 +++ b/gcc/testsuite/gfortran.dg/proc_ptr_result_5.f90 @@ -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