aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorJanus Weil <janus@gcc.gnu.org>2010-03-08 10:35:04 +0100
committerJanus Weil <janus@gcc.gnu.org>2010-03-08 10:35:04 +0100
commitb3d286bac21f41e1680e2f364e0733c8ebf2c9ad (patch)
treeeaa65acb0a14fd9bdf95330dcf09127481313e87 /gcc
parent196c8bc8a319d0be3018c66339e00985857bd627 (diff)
downloadgcc-b3d286bac21f41e1680e2f364e0733c8ebf2c9ad.zip
gcc-b3d286bac21f41e1680e2f364e0733c8ebf2c9ad.tar.gz
gcc-b3d286bac21f41e1680e2f364e0733c8ebf2c9ad.tar.bz2
re PR fortran/43256 ([OOP] TBP with missing optional arg)
2010-03-08 Janus Weil <janus@gcc.gnu.org> PR fortran/43256 * resolve.c (resolve_compcall): Don't set 'value.function.name' here for TBPs, otherwise they will not be resolved properly. (resolve_function): Use 'value.function.esym' instead of 'value.function.name' to check if we're dealing with a TBP. (check_class_members): Set correct type of passed object for all TBPs, not only generic ones, except if the type is abstract. 2010-03-08 Janus Weil <janus@gcc.gnu.org> PR fortran/43256 * gfortran.dg/typebound_call_13.f03: New. From-SVN: r157272
Diffstat (limited to 'gcc')
-rw-r--r--gcc/fortran/ChangeLog10
-rw-r--r--gcc/fortran/resolve.c25
-rw-r--r--gcc/testsuite/ChangeLog5
-rw-r--r--gcc/testsuite/gfortran.dg/typebound_call_13.f0343
4 files changed, 70 insertions, 13 deletions
diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog
index 4067599..8165bb1 100644
--- a/gcc/fortran/ChangeLog
+++ b/gcc/fortran/ChangeLog
@@ -1,3 +1,13 @@
+2010-03-08 Janus Weil <janus@gcc.gnu.org>
+
+ PR fortran/43256
+ * resolve.c (resolve_compcall): Don't set 'value.function.name' here
+ for TBPs, otherwise they will not be resolved properly.
+ (resolve_function): Use 'value.function.esym' instead of
+ 'value.function.name' to check if we're dealing with a TBP.
+ (check_class_members): Set correct type of passed object for all TBPs,
+ not only generic ones, except if the type is abstract.
+
2010-03-04 Janus Weil <janus@gcc.gnu.org>
PR fortran/43244
diff --git a/gcc/fortran/resolve.c b/gcc/fortran/resolve.c
index 10d8807..16661fd 100644
--- a/gcc/fortran/resolve.c
+++ b/gcc/fortran/resolve.c
@@ -2556,8 +2556,8 @@ resolve_function (gfc_expr *expr)
}
/* If this ia a deferred TBP with an abstract interface (which may
- of course be referenced), expr->value.function.name will be set. */
- if (sym && sym->attr.abstract && !expr->value.function.name)
+ of course be referenced), expr->value.function.esym will be set. */
+ if (sym && sym->attr.abstract && !expr->value.function.esym)
{
gfc_error ("ABSTRACT INTERFACE '%s' must not be referenced at %L",
sym->name, &expr->where);
@@ -5124,7 +5124,7 @@ resolve_compcall (gfc_expr* e, bool fcn)
return FAILURE;
e->value.function.actual = newactual;
- e->value.function.name = e->value.compcall.name;
+ e->value.function.name = NULL;
e->value.function.esym = target->n.sym;
e->value.function.class_esym = NULL;
e->value.function.isym = NULL;
@@ -5178,18 +5178,17 @@ check_class_members (gfc_symbol *derived)
return;
}
- if (tbp->n.tb->is_generic)
+ /* If we have to match a passed class member, force the actual
+ expression to have the correct type. */
+ if (!tbp->n.tb->nopass)
{
- /* If we have to match a passed class member, force the actual
- expression to have the correct type. */
- if (!tbp->n.tb->nopass)
- {
- if (e->value.compcall.base_object == NULL)
- e->value.compcall.base_object =
- extract_compcall_passed_object (e);
+ if (e->value.compcall.base_object == NULL)
+ e->value.compcall.base_object = extract_compcall_passed_object (e);
- e->value.compcall.base_object->ts.type = BT_DERIVED;
- e->value.compcall.base_object->ts.u.derived = derived;
+ if (!derived->attr.abstract)
+ {
+ e->value.compcall.base_object->ts.type = BT_DERIVED;
+ e->value.compcall.base_object->ts.u.derived = derived;
}
}
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 8f81bb0..edd3648 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,8 @@
+2010-03-08 Janus Weil <janus@gcc.gnu.org>
+
+ PR fortran/43256
+ * gfortran.dg/typebound_call_13.f03: New.
+
2010-03-05 Eric Botcazou <ebotcazou@adacore.com>
* lib/plugin-support.exp (plugin-test-execute): Use PLUGINCC in lieu
diff --git a/gcc/testsuite/gfortran.dg/typebound_call_13.f03 b/gcc/testsuite/gfortran.dg/typebound_call_13.f03
new file mode 100644
index 0000000..0800ba5
--- /dev/null
+++ b/gcc/testsuite/gfortran.dg/typebound_call_13.f03
@@ -0,0 +1,43 @@
+! { dg-do run }
+!
+! PR 43256: [OOP] TBP with missing optional arg
+!
+! Contributed by Janus Weil
+
+module module_myobj
+
+ implicit none
+
+ type :: myobj
+ contains
+ procedure, nopass :: myfunc
+ end type
+
+contains
+
+ integer function myfunc(status)
+ integer, optional :: status
+ if (present(status)) then
+ myfunc = 1
+ else
+ myfunc = 2
+ end if
+ end function
+
+end module
+
+
+program test_optional
+
+ use :: module_myobj
+ implicit none
+
+ integer :: res = 0
+ type(myobj) :: myinstance
+
+ res = myinstance%myfunc()
+ if (res /= 2) call abort()
+
+end program
+
+! { dg-final { cleanup-modules "module_myobj" } }