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]

fold casted const variables


Hi,
the following testcase does not get current simplified as it should.

Bootstrapped/regtested on i386.  OK?
Honza
void link_error (void);
const double one=1.0;
t()
{
	if ((int)one != 1)
		link_error ();
}
Sun Feb 16 17:34:30 CET 2003  Jan Hubicka  <jh@suse.cz>

	* c-typeck.c (build_c_cast):  Fold constant variables into
	initial values.

Index: c-typeck.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/c-typeck.c,v
retrieving revision 1.213.2.2
diff -c -3 -p -r1.213.2.2 c-typeck.c
*** c-typeck.c	9 Jan 2003 12:11:34 -0000	1.213.2.2
--- c-typeck.c	16 Feb 2003 17:23:09 -0000
*************** build_c_cast (type, expr)
*** 3775,3782 ****
  		    get_alias_set (TREE_TYPE (type))))
  	    warning ("dereferencing type-punned pointer will break strict-aliasing rules");
  	}
!       
        ovalue = value;
        value = convert (type, value);
  
        /* Ignore any integer overflow caused by the cast.  */
--- 3775,3785 ----
  		    get_alias_set (TREE_TYPE (type))))
  	    warning ("dereferencing type-punned pointer will break strict-aliasing rules");
  	}
! 
        ovalue = value;
+       /* Replace a nonvolatile const static variable with its value.  */
+       if (optimize && TREE_CODE (value) == VAR_DECL)
+ 	value = decl_constant_value (value);
        value = convert (type, value);
  
        /* Ignore any integer overflow caused by the cast.  */


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