This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [Patch, Fortran, OOP] PR 44044: SELECT TYPE with class-valued function


Hi all,

here is a follow-up patch, which fixes comment #1 in the PR.

The patch is very simple: It basically moves some CLASS error checking
into "resolve_fl_var_and_proc", where it will also be applied to
function return values (which are FL_PROCEDURE, not FL_VARIABLE). This
alone I would have committed as 'obious'.

The only nontriviality was given by the fact that the error message
then appeared twice (which is better than zero, but still not
optimal). Apparently this is so because all function symbols are
resolved twice: Once in their parent namespace, and once in their own
local namespace. This behavior I have observed in all gfortran
versions I tested (4.3 to 4.6), and can also be seen with other error
messages (see "fun2" in the test case).

To solve this, I made a small addition in resolve_symbol (only do the
resolution if it happens in the parent ns).

The patch was regtested on x86_64-unknown-linux-gnu. Ok for trunk?

Cheers,
Janus


2010-05-12 ?Janus Weil ?<janus@gcc.gnu.org>

? ? ? ?PR fortran/44044
? ? ? ?* resolve.c (resolve_fl_var_and_proc): Move error messages here from ...
? ? ? ?(resolve_fl_variable_derived): ... this place.
? ? ? ?(resolve_symbol): Make sure function symbols (and their result
? ? ? ?variables) are not resolved twice.

2010-05-12 ?Janus Weil ?<janus@gcc.gnu.org>

? ? ? ?PR fortran/44044
? ? ? ?* gfortran.dg/class_18.f03: New.




2010/5/9 Janus Weil <janus@gcc.gnu.org>:
> Hi all,
>
> here is my fix for a problem with SELECT TYPE. It basically moves an
> error message from parsing to resolution stage. For the test case in
> the PR the checking came too early, since the function's interface is
> not yet known when parsing the SELECT TYPE statement. As a consequence
> of the moved error message, I had to slightly modify two testcases.
>
> Btw, the patch only fixes comment #0 in the PR. I have started to work
> on comments #1 to #3, but have not yet fixed them fully (will do
> soon).
>
> The patch was regtested on x86_64-unknown-linux-gnu. Ok for trunk?
>
> Cheers,
> Janus
>
>
>
> 2010-05-09 ?Janus Weil ?<janus@gcc.gnu.org>
>
> ? ? ? ?PR fortran/44044
> ? ? ? ?* match.c (gfc_match_select_type): Move error message to
> ? ? ? ?resolve_select_type.
> ? ? ? ?* resolve.c (resolve_select_type): Error message moved here from
> ? ? ? ?gfc_match_select_type. Correctly set type of temporary.
>
>
> 2010-05-09 ?Janus Weil ?<janus@gcc.gnu.org>
>
> ? ? ? ?PR fortran/44044
> ? ? ? ?* gfortran.dg/class_7.f03: Modified.
> ? ? ? ?* gfortran.dg/select_type_1.f03: Modified.
> ? ? ? ?* gfortran.dg/select_type_12.f03: New.
>

Attachment: pr44044_c1.diff
Description: Binary data

Attachment: class_18.f03
Description: Binary data


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]