Procedure Pointers: a first patch
Steven Bosscher
stevenb.gcc@gmail.com
Sun May 4 19:22:00 GMT 2008
xf. http://gcc.gnu.org/ml/fortran/2008-05/msg00029.html
Hi Janus,
Just for comparison, look at the gimple for the following C test case
with your Fortran tree:
================
extern void foo (void);
void bar (void) {
typedef void (*funptr) (void);
funptr ptr = foo;
}
================
This gives the following statement to the gimplifier:
Breakpoint 5, gimplify_stmt (stmt_p=0x22c760) at
../../vanilla/gcc/gimplify.c:4660
4660 gimplify_expr (stmt_p, NULL, NULL, is_gimple_stmt, fb_none);
(gdb) p debug_tree(*stmt_p)
<init_expr 0x7ff40208
type <void_type 0x7ff81248 void VOID
align 8 symtab 0 alias set -1 canonical type 0x7ff81248
pointer_to_this <pointer_type 0x7ff812b0>>
side-effects
arg 0 <var_decl 0x7fdf0000 ptr
type <pointer_type 0x7ff8f908 funptr type <function_type 0x7ff837a8>
sizes-gimplified unsigned SI
size <integer_cst 0x7ff00700 constant 32>
unit size <integer_cst 0x7ff004a0 constant 4>
align 32 symtab 0 alias set -1 canonical type 0x7ff8f838>
unsigned SI file t.c line 6 col 10 size <integer_cst
0x7ff00700 32> unit size <integer_cst 0x7ff004a0 4>
align 32 context <function_decl 0x7fdbf340 bar>>
arg 1 <addr_expr 0x7fde2500
type <pointer_type 0x7ff8f838 type <function_type 0x7ff837a8>
sizes-gimplified unsigned SI size <integer_cst 0x7ff00700
32> unit size <integer_cst 0x7ff004a0 4>
align 32 symtab 0 alias set -1 canonical type 0x7ff8f838>
constant
arg 0 <function_decl 0x7fdbf2d0 foo type <function_type 0x7ff837a8>
addressable used public external decl_5 QI defer-output
file t.c line 1 col 13 align 8>>>
Note how the rhs of the assignment arg0 (INIT_EXPR is gimplified to a
simple assignment) is a var decl.
For your test case, otoh, I get an ADDR_EXPR on the rhs:
#4 0x007876cd in gimplify_stmt (stmt_p=0x7ff33c08) at
../../vanilla/gcc/gimplify.c:4660
4660 gimplify_expr (stmt_p, NULL, NULL, is_gimple_stmt, fb_none);
(gdb) p debug_tree(*stmt_p)
<modify_expr 0x7ff401e0
type <void_type 0x7ff808f0 void VOID
align 8 symtab 0 alias set -1 canonical type 0x7ff808f0
pointer_to_this <pointer_type 0x7ff80958>>
side-effects
arg 0 <addr_expr 0x7fdb0bc0
type <pointer_type 0x7ff82be0 type <function_type 0x7ff82b78>
unsigned SI
size <integer_cst 0x7ff006e0 constant 32>
unit size <integer_cst 0x7ff00480 constant 4>
align 32 symtab 0 alias set -1 canonical type 0x7ff82be0>
constant
arg 0 <function_decl 0x7ff9c1d0 ptr type <function_type 0x7ff82b78>
addressable public external QI file procptr.f90 line 13
col 0 align 8 chain <function_decl 0x7ff9c160 procptrtest>>>
arg 1 <addr_expr 0x7fdb0c00 type <pointer_type 0x7ff82be0>
constant
arg 0 <function_decl 0x7ff9c240 proc type <function_type 0x7ff82b78>
addressable public external QI file procptr.f90 line 13
col 0 align 8 chain <function_decl 0x7ff9c1d0 ptr>>>
procptr.f90:20:0>
Full GDB output is attached for your convenience.
Hope this helps!
Gr.
Steven
-------------- next part --------------
A non-text attachment was scrubbed...
Name: example_C
Type: application/octet-stream
Size: 3452 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/fortran/attachments/20080504/9590f39f/attachment.obj>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: example_Fortran
Type: application/octet-stream
Size: 4552 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/fortran/attachments/20080504/9590f39f/attachment-0001.obj>
More information about the Fortran
mailing list