This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC 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]

[PATCH] Fix PRs 42119/38530


This fixes mentioned PRs by making sure we properly expand an
address of a CONST_DECL.  The "fix" for broken FEs works for them
though I'm not sure what the issue is with that brokeness and
why refering to the address of a constant pool entry can be wrong.

Well - bootstrapped and tested on x86_64-unknown-linux-gnu.

Ok for trunk?

Thanks,
Richard.

2009-11-23  Richard Guenther  <rguenther@suse.de>

	PR middle-end/42119
	PR fortran/38530
	* expr.c (expand_expr_addr_expr_1): Properly expand the initializer
	of CONST_DECLs.

	* gfortran.dg/pr42119.f90: New testcase.

Index: gcc/expr.c
===================================================================
*** gcc/expr.c	(revision 154432)
--- gcc/expr.c	(working copy)
*************** expand_expr_addr_expr_1 (tree exp, rtx t
*** 6845,6853 ****
        return expand_expr (TREE_OPERAND (exp, 0), target, tmode, modifier);
  
      case CONST_DECL:
!       /* Recurse and make the output_constant_def clause above handle this.  */
!       return expand_expr_addr_expr_1 (DECL_INITIAL (exp), target,
! 				      tmode, modifier, as);
  
      case REALPART_EXPR:
        /* The real part of the complex number is always first, therefore
--- 6845,6852 ----
        return expand_expr (TREE_OPERAND (exp, 0), target, tmode, modifier);
  
      case CONST_DECL:
!       /* Expand the initializer like constants above.  */
!       return XEXP (expand_expr_constant (DECL_INITIAL (exp), 0, modifier), 0);
  
      case REALPART_EXPR:
        /* The real part of the complex number is always first, therefore
Index: gcc/testsuite/gfortran.dg/pr42119.f90
===================================================================
*** gcc/testsuite/gfortran.dg/pr42119.f90	(revision 0)
--- gcc/testsuite/gfortran.dg/pr42119.f90	(revision 0)
***************
*** 0 ****
--- 1,24 ----
+ ! { dg-do compile }
+ 
+ module Test
+ use ISO_C_BINDING
+ 
+ contains
+ 
+ subroutine Callback(arg) bind(C)
+   integer(C_INT)  :: arg
+ end subroutine Callback
+ 
+ subroutine Check(proc)
+   type(C_FUNPTR)  :: proc
+ end subroutine Check
+ 
+ end module Test
+ 
+ 
+ program Main
+   use Test
+   type(C_FUNPTR)  :: proc
+ 
+   call Check(C_FUNLOC(Callback))
+ end program Main


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