This is the mail archive of the fortran@gcc.gnu.org mailing list for the GNU Fortran 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: problem with array of derived type with PPC


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


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