[Bug fortran/38152] ICE for procedure pointer assignment
--- Comment #8 from janus at gcc dot gnu dot org 2009-01-15 22:56 --- Created an attachment (id=17110) -- (http://gcc.gnu.org/bugzilla/attachment.cgi?id=17110action=view) patch Here is a patch which fixes the testcases in comment #0, #1 and #7. Dominique: Maybe you could check whether the problems from comment #4 and #5 still persist. Can we still get this into 4.4? In a way the ICE is a regression, since 4.3 just gave an error message (stating that procedure pointers are not implemented) but no ICE. -- janus at gcc dot gnu dot org changed: What|Removed |Added AssignedTo|unassigned at gcc dot gnu |janus at gcc dot gnu dot org |dot org | Status|NEW |ASSIGNED http://gcc.gnu.org/bugzilla/show_bug.cgi?id=38152
[Bug fortran/38152] ICE for procedure pointer assignment
--- Comment #7 from domob at gcc dot gnu dot org 2009-01-13 19:47 --- Created an attachment (id=17090) -- (http://gcc.gnu.org/bugzilla/attachment.cgi?id=17090action=view) Another test case This seems to be yet another test triggering this ICE. -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=38152
[Bug fortran/38152] ICE for procedure pointer assignment
--- Comment #6 from burnus at gcc dot gnu dot org 2008-11-22 21:42 --- See also test cases at: http://groups.google.com/group/comp.lang.fortran/browse_thread/thread/e0d04d755453a2a5 -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=38152
[Bug fortran/38152] ICE for procedure pointer assignment
--- Comment #5 from dominiq at lps dot ens dot fr 2008-11-19 16:29 --- On powerpc-apple-darwin9 I have the same kind of error as reported in comment #4: /var/folders/FK/FKCVPmNbH5SNynFQmqGomk+++TI/-Tmp-//cctJDhJw.s:21:non-relocatable subtraction expression, _procptr minus L001$pb /var/folders/FK/FKCVPmNbH5SNynFQmqGomk+++TI/-Tmp-//cctJDhJw.s:21:symbol: _procptr can't be undefined in a subtraction expression /var/folders/FK/FKCVPmNbH5SNynFQmqGomk+++TI/-Tmp-//cctJDhJw.s:19:non-relocatable subtraction expression, _procptr minus L001$pb /var/folders/FK/FKCVPmNbH5SNynFQmqGomk+++TI/-Tmp-//cctJDhJw.s:19:symbol: _procptr can't be undefined in a subtraction expression in this case for 32 and 64 bit modes. The errors disappear if I compile with -fno-PIC (ppc/intel). -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=38152
[Bug fortran/38152] ICE for procedure pointer assignment
--- Comment #4 from dominiq at lps dot ens dot fr 2008-11-18 19:54 --- With the patches in comment #2 and #3, compiling the test in comment #0 on i686-apple-darwin9 in 32 bit mode gives: /var/tmp//ccMx60VC.s:13:non-relocatable subtraction expression, _procptr minus L001$pb /var/tmp//ccMx60VC.s:13:symbol: _procptr can't be undefined in a subtraction expression Note that g95 compiles the test while ifort 11 returns: pr38152.f90(4): error #8169: The specified interface is not declared. [TEST] PROCEDURE(test), POINTER :: procptr ^ pr38152.f90(11): error #6437: A subroutine or function is calling itself recursively. [TEST] CALL bar (test) --^ pr38152.f90(12): error #8191: The procedure target must be a procedure or a procedure pointer. [TEST] procptr = test ---^ compilation aborted for pr38152.f90 (code 1) -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=38152
[Bug fortran/38152] ICE for procedure pointer assignment
--- Comment #1 from domob at gcc dot gnu dot org 2008-11-16 09:27 --- Daniel Kraft wrote: I'm working out a test-case for PR 37779 and came across the following program, which ICEs for today's trunk gfortran: SUBROUTINE test () IMPLICIT NONE procptr = test If one moves the procedure-pointer declaration in the subroutine, it works. The difference of the -fdump-tree-original/gimple is: + void (*T62) (void) procptr; The failing assert in make_decl_rtl is: /* A weak alias has TREE_PUBLIC set but not the other bits. */ gcc_assert (TREE_CODE (decl) != VAR_DECL || TREE_STATIC (decl) || TREE_PUBLIC (decl) || DECL_EXTERNAL (decl) || DECL_REGISTER (decl)); Is this already a known bug? Sorry that I don't have an overview... If not, I'll file a report. Please do so, I think it is not known. By the way, the following also fails: module m procedure(), pointer :: procptr end module m use m external foo procptr = foo end with Error: 'procptr' in the pointer assignment at (1) cannot be an l-value since it is a procedure I think the proc_ptr attribute is not properly saved in the .mod file. Tobias -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=38152
[Bug fortran/38152] ICE for procedure pointer assignment
--- Comment #2 from janus at gcc dot gnu dot org 2008-11-16 18:59 --- (In reply to comment #1) By the way, the following also fails: module m procedure(), pointer :: procptr end module m use m external foo procptr = foo end with Error: 'procptr' in the pointer assignment at (1) cannot be an l-value since it is a procedure I think the proc_ptr attribute is not properly saved in the .mod file. Actually this is not the problem. All attributes are saved properly. The error is fixed by the following trivial patch: Index: gcc/fortran/expr.c === --- gcc/fortran/expr.c (revision 141915) +++ gcc/fortran/expr.c (working copy) @@ -3034,7 +3034,8 @@ gfc_check_pointer_assign (gfc_expr *lval } if (lvalue-symtree-n.sym-attr.flavor == FL_PROCEDURE - lvalue-symtree-n.sym-attr.use_assoc) + lvalue-symtree-n.sym-attr.use_assoc + !lvalue-symtree-n.sym-attr.proc_pointer) { gfc_error ('%s' in the pointer assignment at %L cannot be an l-value since it is a procedure, -- janus at gcc dot gnu dot org changed: What|Removed |Added Status|UNCONFIRMED |NEW Ever Confirmed|0 |1 Last reconfirmed|-00-00 00:00:00 |2008-11-16 18:59:41 date|| http://gcc.gnu.org/bugzilla/show_bug.cgi?id=38152
[Bug fortran/38152] ICE for procedure pointer assignment
--- Comment #3 from burnus at gcc dot gnu dot org 2008-11-17 00:01 --- (In reply to comment #2) By the way, the following also fails: The error is fixed by the following trivial patch: Janus, do you plan to submit it? * * * Regarding the ICE, the following patch seems to work; one probably still needs to take care of mangling of the name etc. Also there needs to be a check for use-/host- association (cf. a few lines down and in gfc_finish_var_decl), adding those flags unconditionally is surely wrong. --- trans-decl.c(revision 141928) +++ trans-decl.c(working copy) @@ -1021,2 +1021,7 @@ gfc_get_symbol_decl (gfc_symbol * sym) decl = gfc_get_extern_function_decl (sym); + if (sym-attr.proc_pointer) + { + TREE_PUBLIC (decl) = 1; + TREE_STATIC (decl) = 1; +} return decl; -- burnus at gcc dot gnu dot org changed: What|Removed |Added CC||burnus at gcc dot gnu dot ||org http://gcc.gnu.org/bugzilla/show_bug.cgi?id=38152