From: Janus Weil Date: Sat, 1 Jun 2013 21:36:33 +0000 (+0200) Subject: re PR fortran/57217 ([OOP] Accepts invalid TBP overriding - lacking arguments check) X-Git-Tag: releases/gcc-4.7.4~637 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=9a1935f63e10b5c78aab1bea2bc3f12d96b8ebd3;p=thirdparty%2Fgcc.git re PR fortran/57217 ([OOP] Accepts invalid TBP overriding - lacking arguments check) 2013-06-01 Janus Weil Tobias Burnus PR fortran/57217 * interface.c (check_dummy_characteristics): Symmetrize type check. 2013-06-01 Janus Weil Tobias Burnus PR fortran/57217 * gfortran.dg/typebound_override_4.f90: New. Co-Authored-By: Tobias Burnus From-SVN: r199586 --- diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog index 97893b97950e..7f6fa7a3e7cf 100644 --- a/gcc/fortran/ChangeLog +++ b/gcc/fortran/ChangeLog @@ -1,3 +1,9 @@ +2013-06-01 Janus Weil + Tobias Burnus + + PR fortran/57217 + * interface.c (check_dummy_characteristics): Symmetrize type check. + 2013-05-22 Janne Blomqvist * intrinsic.texi (RANDOM_SEED): Improve example. diff --git a/gcc/fortran/interface.c b/gcc/fortran/interface.c index e1f0cb6b2f8f..0278995ba520 100644 --- a/gcc/fortran/interface.c +++ b/gcc/fortran/interface.c @@ -987,7 +987,8 @@ check_dummy_characteristics (gfc_symbol *s1, gfc_symbol *s2, bool type_must_agree, char *errmsg, int err_len) { /* Check type and rank. */ - if (type_must_agree && !compare_type_rank (s2, s1)) + if (type_must_agree && + (!compare_type_rank (s1, s2) || !compare_type_rank (s2, s1))) { if (errmsg != NULL) snprintf (errmsg, err_len, "Type/rank mismatch in argument '%s'", diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index e8b54e4fb14b..d156c635db75 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,9 @@ +2013-06-01 Janus Weil + Tobias Burnus + + PR fortran/57217 + * gfortran.dg/typebound_override_4.f90: New. + 2013-05-26 Eric Botcazou * gnat.dg/specs/last_bit.ads: New test. diff --git a/gcc/testsuite/gfortran.dg/typebound_override_4.f90 b/gcc/testsuite/gfortran.dg/typebound_override_4.f90 new file mode 100644 index 000000000000..2b747a87b6e1 --- /dev/null +++ b/gcc/testsuite/gfortran.dg/typebound_override_4.f90 @@ -0,0 +1,34 @@ +! { dg-do compile } +! +! PR 57217: [4.7/4.8/4.9 Regression][OOP] Accepts invalid TBP overriding - lacking arguments check +! +! Contributed by Salvatore Filippone + +module base_mod + implicit none + type base_type + contains + procedure, pass(map) :: clone => base_clone + end type +contains + subroutine base_clone(map,mapout) + class(base_type) :: map + class(base_type) :: mapout + end subroutine +end module + +module r_mod + use base_mod + implicit none + type, extends(base_type) :: r_type + contains + procedure, pass(map) :: clone => r_clone ! { dg-error "Type/rank mismatch in argument" } + end type +contains + subroutine r_clone(map,mapout) + class(r_type) :: map + class(r_type) :: mapout + end subroutine +end module + +! { dg-final { cleanup-modules "base_mod r_mod" } }