[PATCH] PR 14203: Use DECL_RTL_SET_P in uninitialized_vars_warning

Roger Sayle roger@eyesopen.com
Sat Feb 28 22:33:00 GMT 2004


Hi Mark,

Alas I'd bootstrapped and regression tested the following fix for
PR middle-end/14203 before I noticed that you'd recently assigned
this PR to yourself.  Is this the fix you're investigating?

The problem is that uninitialized_vars_warning is using DECL_RTL to
check whether a declaration has RTL, instead of DECL_RTL_SET_P.
The former has the unfortunate side-effect of actually attempting to
generate RTL, which then leads to an ICE.  My guess is that this is
unintentional in a routine intended to issue compiler warnings.

The following patch has been tested on i686-pc-linux-gnu with a full
"make bootstrap", all languages except treelang, and regression tested
with a top-level "make -k check" with no new failures.

Ok for mainline and 3.4?


2004-02-28  Roger Sayle  <roger@eyesopen.com>

	PR middle-end/14203
	* function.c (uninitialized_vars_warning): Use DECL_RTL_SET_P
	instead of testing whether DECL_RTL is not NULL.

	* g++.dg/warn/Wunused-6.C: New test case.


Index: function.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/function.c,v
retrieving revision 1.498
diff -c -3 -p -r1.498 function.c
*** function.c	27 Feb 2004 12:02:55 -0000	1.498
--- function.c	28 Feb 2004 17:22:32 -0000
*************** uninitialized_vars_warning (tree block)
*** 5702,5708 ****
  	     flow.c that the entire aggregate was initialized.
  	     Unions are troublesome because members may be shorter.  */
  	  && ! AGGREGATE_TYPE_P (TREE_TYPE (decl))
! 	  && DECL_RTL (decl) != 0
  	  && GET_CODE (DECL_RTL (decl)) == REG
  	  /* Global optimizations can make it difficult to determine if a
  	     particular variable has been initialized.  However, a VAR_DECL
--- 5702,5708 ----
  	     flow.c that the entire aggregate was initialized.
  	     Unions are troublesome because members may be shorter.  */
  	  && ! AGGREGATE_TYPE_P (TREE_TYPE (decl))
! 	  && DECL_RTL_SET_P (decl)
  	  && GET_CODE (DECL_RTL (decl)) == REG
  	  /* Global optimizations can make it difficult to determine if a
  	     particular variable has been initialized.  However, a VAR_DECL
*************** uninitialized_vars_warning (tree block)
*** 5717,5723 ****
  		 decl, decl);
        if (extra_warnings
  	  && TREE_CODE (decl) == VAR_DECL
! 	  && DECL_RTL (decl) != 0
  	  && GET_CODE (DECL_RTL (decl)) == REG
  	  && regno_clobbered_at_setjmp (REGNO (DECL_RTL (decl))))
  	warning ("%Jvariable '%D' might be clobbered by `longjmp' or `vfork'",
--- 5717,5723 ----
  		 decl, decl);
        if (extra_warnings
  	  && TREE_CODE (decl) == VAR_DECL
! 	  && DECL_RTL_SET_P (decl)
  	  && GET_CODE (DECL_RTL (decl)) == REG
  	  && regno_clobbered_at_setjmp (REGNO (DECL_RTL (decl))))
  	warning ("%Jvariable '%D' might be clobbered by `longjmp' or `vfork'",


/* PR middle-end/14203 */
/* { dg-do compile } */
/* { dg-options "-Wall" } */

void foo()
{
  if (false)
    if (int i=0)  // { dg-warning "unused" "" }
      int j=0;    // { dg-warning "unused" "" }
}


Roger
--
Roger Sayle,                         E-mail: roger@eyesopen.com
OpenEye Scientific Software,         WWW: http://www.eyesopen.com/
Suite 1107, 3600 Cerrillos Road,     Tel: (+1) 505-473-7385
Santa Fe, New Mexico, 87507.         Fax: (+1) 505-473-0833



More information about the Gcc-patches mailing list