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 PR39829


This fixes PR39829 where we fail to recognize an address-taking
operation inside a VIEW_CONVERT_EXPR.  (yes we should better fold
this ... see PR39744)

Bootstrapped and tested on x86_64-unknown-linux-gnu, applied to trunk.

Richard.

2009-04-21  Richard Guenther  <rguenther@suse.de>

	PR middle-end/39829
	* gimple.c (walk_stmt_load_store_addr_ops): Catch addresses
	inside VIEW_CONVERT_EXPRs.

	* gcc.dg/torture/pr39829.c: New testcase.

Index: gcc/gimple.c
===================================================================
*** gcc/gimple.c	(revision 146514)
--- gcc/gimple.c	(working copy)
*************** walk_stmt_load_store_addr_ops (gimple st
*** 3231,3236 ****
--- 3231,3238 ----
  	    ret |= visit_store (stmt, lhs, data);
  	}
        rhs = gimple_assign_rhs1 (stmt);
+       while (handled_component_p (rhs))
+ 	rhs = TREE_OPERAND (rhs, 0);
        if (visit_addr)
  	{
  	  if (TREE_CODE (rhs) == ADDR_EXPR)
Index: gcc/testsuite/gcc.dg/torture/pr39829.c
===================================================================
*** gcc/testsuite/gcc.dg/torture/pr39829.c	(revision 0)
--- gcc/testsuite/gcc.dg/torture/pr39829.c	(revision 0)
***************
*** 0 ****
--- 1,27 ----
+ /* { dg-do compile } */
+ /* { dg-options "-w" } */
+ 
+ void foo (void * DAG_temp117584)
+ {
+   char  uA;
+   void* pA;
+   void* pB;
+   void* pC;
+   do {
+       int DAG_temp117585;
+       int DAG_temp117586;
+       void ** __indir_union1 = (void**)DAG_temp117584;
+       DAG_temp117585 = (long)*__indir_union1;
+       DAG_temp117586 = DAG_temp117585;
+       if ( DAG_temp117586 != (int)268435456 )
+ 	pA = (void*)&uA;
+       pB = (void*)&pA;
+       pC = pB;
+       union __block_indir0_u {  struct {  long val; }  __indir_struct; }
+       * __indir_union = (union __block_indir0_u*)pC;
+       f(__indir_union->__indir_struct.val);
+ 
+       DAG_temp117584 += 64;
+   } while (1);
+ }
+ 


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