1 From 1c9148fe797f564821355a8976802689519324dd Mon Sep 17 00:00:00 2001
2 From: burnus <burnus@138bc75d-0d04-0410-961f-82ee72b054a4>
3 Date: Fri, 29 Apr 2011 21:26:07 +0000
4 Subject: [PATCH 198/200] 2011-04-29 Tobias Burnus <burnus@net-b.de>
7 * resolve.c (resolve_typebound_generic_call): Don't check access
8 flags of the specific function.
11 * resolve.c (resolve_formal_arglist): Don't change AS_DEFERRED
12 to AS_ASSUMED_SHAPE for function results.
13 (resolve_fl_var_and_proc): Print also for function results with
14 AS_DEFERRED an error, if they are not a pointer or allocatable.
15 (resolve_types): Make sure arguments of procedures in interface
18 2011-04-29 Tobias Burnus <burnus@net-b.de>
21 * gfortran.dg/typebound_proc_22.f90: New.
24 * gfortran.dg/interface_36.f90: New.
28 git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/branches/gcc-4_6-branch@173191 138bc75d-0d04-0410-961f-82ee72b054a4
30 index f661140..7618db9 100644
31 --- a/gcc/fortran/resolve.c
32 +++ b/gcc/fortran/resolve.c
33 @@ -315,7 +315,8 @@ resolve_formal_arglist (gfc_symbol *proc)
34 shape until we know if it has the pointer or allocatable attributes.
36 if (sym->as && sym->as->rank > 0 && sym->as->type == AS_DEFERRED
37 - && !(sym->attr.pointer || sym->attr.allocatable))
38 + && !(sym->attr.pointer || sym->attr.allocatable)
39 + && sym->attr.flavor != FL_PROCEDURE)
41 sym->as->type = AS_ASSUMED_SHAPE;
42 for (i = 0; i < sym->as->rank; i++)
43 @@ -5674,7 +5675,7 @@ success:
44 /* Make sure that we have the right specific instance for the name. */
45 derived = get_declared_from_expr (NULL, NULL, e);
47 - st = gfc_find_typebound_proc (derived, NULL, genname, false, &e->where);
48 + st = gfc_find_typebound_proc (derived, NULL, genname, true, &e->where);
50 e->value.compcall.tbp = st->n.tb;
52 @@ -9890,7 +9891,7 @@ resolve_fl_var_and_proc (gfc_symbol *sym, int mp_flag)
55 if (!mp_flag && !sym->attr.allocatable && !sym->attr.pointer
56 - && !sym->attr.dummy && sym->ts.type != BT_CLASS && !sym->assoc)
57 + && sym->ts.type != BT_CLASS && !sym->assoc)
59 gfc_error ("Array '%s' at %L cannot have a deferred shape",
60 sym->name, &sym->declared_at);
61 @@ -13505,6 +13506,10 @@ resolve_types (gfc_namespace *ns)
63 resolve_contained_functions (ns);
65 + if (ns->proc_name && ns->proc_name->attr.flavor == FL_PROCEDURE
66 + && ns->proc_name->attr.if_source == IFSRC_IFBODY)
67 + resolve_formal_arglist (ns->proc_name);
69 gfc_traverse_ns (ns, resolve_bind_c_derived_types);
71 for (cl = ns->cl_list; cl; cl = cl->next)
73 index 0000000..5032291
75 +++ b/gcc/testsuite/gfortran.dg/interface_36.f90
81 +! Contributed by Daniel Carrera
83 + pure function runge_kutta_step(t, r_, dr, h) result(res)
84 + real, intent(in) :: t, r_(:), h
85 + real, dimension(:), allocatable :: k1, k2, k3, k4, res
89 + pure function dr(t, r_) ! { dg-error "cannot have a deferred shape" }
90 + real, intent(in) :: t, r_(:)
96 + allocate(k1(N),k2(N),k3(N),k4(N),res(N))
99 + k2 = dr(t + h/2, r_ + k1*h/2)
100 + k3 = dr(t + h/2, r_ + k2*h/2)
101 + k4 = dr(t + h , r_ + k3*h)
103 + res = r_ + (k1 + 2*k2 + 2*k3 + k4) * h/6
105 diff --git a/gcc/testsuite/gfortran.dg/typebound_proc_22.f90 b/gcc/testsuite/gfortran.dg/typebound_proc_22.f90
107 index 0000000..f7691c5
109 +++ b/gcc/testsuite/gfortran.dg/typebound_proc_22.f90
115 +! Contributed by Andrew Baldwin
122 + procedure :: gimmex
123 + generic, public :: getx => gimmex
126 + function gimmex(foo)
127 + class (foobar) :: foo
130 + end function gimmex
138 + procedure :: gimmexPriv
139 + generic, private :: getxPriv => gimmexPriv
140 + end type foobarPriv
142 + function gimmexPriv(foo)
143 + class (foobarPriv) :: foo
146 + end function gimmexPriv
147 + end module qtestPriv
152 + type (foobar) :: foo
153 + type (foobarPriv) :: fooPriv
155 + bar = foo%getx() ! OK
156 + bar = fooPriv%getxPriv() ! { dg-error " is PRIVATE " }
157 + end program quicktest
159 +! { dg-final { cleanup-modules "qtest qtestpriv" } }