This is the mail archive of the
fortran@gcc.gnu.org
mailing list for the GNU Fortran project.
Re: problem with array of derived type with PPC
- From: Janus Weil <janus at gcc dot gnu dot org>
- To: Barron Bichon <barron dot bichon at swri dot org>
- Cc: fortran at gcc dot gnu dot org, John M McFarland <john dot mcfarland at swri dot org>
- Date: Fri, 15 May 2009 20:26:50 +0200
- Subject: Re: problem with array of derived type with PPC
- References: <4A0D7334.2080605@swri.org>
Hi Barron,
> First and foremost, many thanks to Janus and others for the recent progress
> on PPCs in gfortran.
Nice to hear it's useful for you :)
> However, I'm having
> some issues compiling with the latest version (r147544). One problem is when
> trying to create an "array of procedure pointers" by creating a derived type
> with a single PPC and then creating an array of that type. Consider the
> following example:
>
> PROGRAM test_prog
>
> ?TYPE ProcPointerArray
> ? ?PROCEDURE(add), POINTER, NOPASS :: f
> ?END TYPE ProcPointerArray
>
> ?TYPE (ProcPointerArray) :: f_array(1)
> ?PROCEDURE(add), POINTER :: f
>
> ?f_array(1)%f => add
> ?f => f_array(1)%f
> ?PRINT*, f(2.,4.)
>
> CONTAINS
>
> ?FUNCTION add(a,b) RESULT(sum)
> ? ?REAL, INTENT(in) :: a, b
> ? ?REAL :: sum
> ? ?sum = a + b
> ?END FUNCTION add
>
> END PROGRAM test_prog
>
> This code compiles with g95, but with gfortran I receive this message:
>
> ?f => f_array(1)%f
> ? ? ? ? ? ? ? ? 1
> Error: VARIABLE attribute of 'f_array' conflicts with PROCEDURE attribute at
> (1)
>
> I believe this code should be acceptable. Is this perhaps something in the
> current plans for PPCs?
First off: Thanks for reporting this. Your code indeed looks valid,
and I can reproduce your error message. I have to admit that I was
aware of this kind of PPC arrays, but missed to test my initial PPC
implementation with it. I'm glad you bring it up here, because I had
completely forgotten about it. Btw there is a nice paper about
creating an array of procedure pointers, which uses similar code:
http://portal.acm.org/citation.cfm?id=1520752.1520753
> BTW - this is my first time posting to this list. If there is something I
> should have done differently to be of more help, please let me know.
You're doing a great job :)
I filed a PR in bugzilla to keep track of this:
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=40164
Feel free to add yourself to the CC field, so that you get notified
when this gets fixed. I promise to take care of it soon.
Cheers,
Janus