------- Comment #12 from dominiq at lps dot ens dot fr  2009-08-22 08:57 -------
In order to avoid the error reported in comment #8, I have tested the following
patches:

(1)

Index: gcc/fortran/trans-expr.c
===================================================================
--- ../_gcc_clean/gcc/fortran/trans-expr.c      2009-08-21 17:41:19.000000000
+0200
+++ gcc/fortran/trans-expr.c    2009-08-21 19:20:16.000000000 +0200
@@ -2679,6 +2679,7 @@ gfc_conv_procedure_call (gfc_se * se, gf
                }
              else if (e->expr_type == EXPR_FUNCTION
                       && e->symtree->n.sym->result
+                      && e->symtree->n.sym->result != e->symtree->n.sym
                       && e->symtree->n.sym->result->attr.proc_pointer)
                {
                  /* Functions returning procedure pointers.  */
@@ -3504,7 +3505,7 @@ gfc_conv_statement_function (gfc_se * se
 /* Return the backend_decl for a procedure pointer component.  */

 tree
-gfc_get_proc_ptr_comp (gfc_se *se, gfc_expr *e)
+gfc_get_proc_ptr_comp (__attribute__((unused)) gfc_se *se, gfc_expr *e)
 {
   gfc_se comp_se;
   gfc_expr *e2;
@@ -3512,8 +3513,7 @@ gfc_get_proc_ptr_comp (gfc_se *se, gfc_e
   e2 = gfc_copy_expr (e);
   e2->expr_type = EXPR_VARIABLE;
   gfc_conv_expr (&comp_se, e2);
-  comp_se.expr = build_fold_addr_expr_loc (input_location, comp_se.expr);
-  return gfc_evaluate_now (comp_se.expr, &se->pre);  
+  return build_fold_addr_expr_loc (input_location, comp_se.expr);
 }

(2)

Index: gcc/fortran/trans-expr.c
===================================================================
--- ../_gcc_clean/gcc/fortran/trans-expr.c      2009-08-21 11:46:44.000000000
+0200
+++ gcc/fortran/trans-expr.c    2009-08-21 21:38:04.000000000 +0200
@@ -1508,7 +1508,7 @@ conv_function_val (gfc_se * se, gfc_symb
   tree tmp;

   if (gfc_is_proc_ptr_comp (expr, NULL))
-    tmp = gfc_get_proc_ptr_comp (se, expr);
+    tmp = gfc_get_proc_ptr_comp (expr);
   else if (sym->attr.dummy)
     {
       tmp = gfc_get_symbol_decl (sym);
@@ -2679,6 +2679,7 @@ gfc_conv_procedure_call (gfc_se * se, gf
                }
              else if (e->expr_type == EXPR_FUNCTION
                       && e->symtree->n.sym->result
+                      && e->symtree->n.sym->result != e->symtree->n.sym
                       && e->symtree->n.sym->result->attr.proc_pointer)
                {
                  /* Functions returning procedure pointers.  */
@@ -3504,7 +3505,7 @@ gfc_conv_statement_function (gfc_se * se
 /* Return the backend_decl for a procedure pointer component.  */

 tree
-gfc_get_proc_ptr_comp (gfc_se *se, gfc_expr *e)
+gfc_get_proc_ptr_comp (gfc_expr *e)
 {
   gfc_se comp_se;
   gfc_expr *e2;
@@ -3512,8 +3513,7 @@ gfc_get_proc_ptr_comp (gfc_se *se, gfc_e
   e2 = gfc_copy_expr (e);
   e2->expr_type = EXPR_VARIABLE;
   gfc_conv_expr (&comp_se, e2);
-  comp_se.expr = build_fold_addr_expr_loc (input_location, comp_se.expr);
-  return gfc_evaluate_now (comp_se.expr, &se->pre);  
+  return build_fold_addr_expr_loc (input_location, comp_se.expr);
 }


Index: gcc/fortran/trans-tmt.h
===================================================================
--- ../_gcc_clean/gcc/fortran/trans-stmt.h      2009-05-10 12:01:34.000000000
+0200
+++ gcc/fortran/trans-stmt.h    2009-08-21 21:38:41.000000000 +0200
@@ -29,7 +29,7 @@ tree gfc_trans_code (gfc_code *);
 tree gfc_trans_assign (gfc_code *);
 tree gfc_trans_pointer_assign (gfc_code *);
 tree gfc_trans_init_assign (gfc_code *);
-tree gfc_get_proc_ptr_comp (gfc_se *, gfc_expr *);
+tree gfc_get_proc_ptr_comp (gfc_expr *);

 /* trans-stmt.c */
 tree gfc_trans_cycle (gfc_code *);

Both allow gfortran to be built, they fix the segmentation fault reported in
comment #2, but not the wrong code for comments #4 and #11.  With the second
patch, my tests passed and gfortran regtested fine (powerpc-apple-darwin9).


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=41139

Reply via email to