aboutsummaryrefslogtreecommitdiff
path: root/gcc/fortran/interface.c
diff options
context:
space:
mode:
authorJanus Weil <janus@gcc.gnu.org>2010-10-27 23:41:52 +0200
committerJanus Weil <janus@gcc.gnu.org>2010-10-27 23:41:52 +0200
commit5ac13b8e0c688dcf1251aee3f90eddfc1e5ba43f (patch)
treed6cfcfe21cfcf637625c5a369106662858f5d290 /gcc/fortran/interface.c
parentcfc839a4b23ef56b53de632a713b1e6d1f2b89d4 (diff)
downloadgcc-5ac13b8e0c688dcf1251aee3f90eddfc1e5ba43f.zip
gcc-5ac13b8e0c688dcf1251aee3f90eddfc1e5ba43f.tar.gz
gcc-5ac13b8e0c688dcf1251aee3f90eddfc1e5ba43f.tar.bz2
re PR fortran/46161 ([OOP] Invalid: Passing non-polymorphic to allocatable polymorphic dummy)
2010-10-27 Janus Weil <janus@gcc.gnu.org> PR fortran/46161 * interface.c (compare_allocatable): Handle polymorphic allocatables. (compare_parameter): Add two error messages for polymorphic dummies. 2010-10-27 Janus Weil <janus@gcc.gnu.org> PR fortran/46161 * gfortran.dg/class_dummy_3.f03: New. From-SVN: r166018
Diffstat (limited to 'gcc/fortran/interface.c')
-rw-r--r--gcc/fortran/interface.c25
1 files changed, 24 insertions, 1 deletions
diff --git a/gcc/fortran/interface.c b/gcc/fortran/interface.c
index 6ae36c2..16b941c 100644
--- a/gcc/fortran/interface.c
+++ b/gcc/fortran/interface.c
@@ -1375,7 +1375,8 @@ compare_allocatable (gfc_symbol *formal, gfc_expr *actual)
{
symbol_attribute attr;
- if (formal->attr.allocatable)
+ if (formal->attr.allocatable
+ || (formal->ts.type == BT_CLASS && CLASS_DATA (formal)->attr.allocatable))
{
attr = gfc_expr_attr (actual);
if (!attr.allocatable)
@@ -1519,6 +1520,28 @@ compare_parameter (gfc_symbol *formal, gfc_expr *actual,
gfc_typename (&formal->ts));
return 0;
}
+
+ /* F2003, 12.5.2.5. */
+ if (formal->ts.type == BT_CLASS
+ && (CLASS_DATA (formal)->attr.class_pointer
+ || CLASS_DATA (formal)->attr.allocatable))
+ {
+ if (actual->ts.type != BT_CLASS)
+ {
+ if (where)
+ gfc_error ("Actual argument to '%s' at %L must be polymorphic",
+ formal->name, &actual->where);
+ return 0;
+ }
+ if (CLASS_DATA (actual)->ts.u.derived
+ != CLASS_DATA (formal)->ts.u.derived)
+ {
+ if (where)
+ gfc_error ("Actual argument to '%s' at %L must have the same "
+ "declared type", formal->name, &actual->where);
+ return 0;
+ }
+ }
if (formal->attr.codimension)
{