[PATCH RFA]: Patch for PR middle-end/13127

Ian Lance Taylor ian@airs.com
Mon Jan 17 02:53:00 GMT 2005


PR 13127 is about a case in which a function which does not return a
value is inlined into another function:

static int foo (int a) { } 
int main (void) { return foo (0); } 

gcc should issue a warning about the function not returning a value,
but does not; that is PR 13000.  PR 13127 is about a bogus warning
indicating that the variable to which the result of the inlined
function is assigned is not initialized.  In this particular example,
that variable has no name, leading to the particularly bogus warning

pr13127.c:2: warning: '({anonymous})' is used uninitialized in this function

This patch fixes that warning by setting TREE_NO_WARNING on the
variable to which the result of an inlined function is assigned.

I'm running a testsuite run and a bootstrap on i686-pc-linux-gnu.  Is
this patch OK to commit if they complete successfully?

Ian


gcc/ChangeLog:
2005-01-16  Ian Lance Taylor  <ian@airs.com>

	PR middle-end/13127:
	* tree-inline.c (expand_call_inline): Set TREE_NO_WARNING on
	a variable set to the return value of the inlined function.


testsuite/ChangeLog:
2005-01-16  Ian Lance Taylor  <ian@c2micro.com>

	PR middle-end/13127
	* gcc.dg/20040206-1.c: Remove xfail on bogus warning which is no
	longer emitted.


Index: tree-inline.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/tree-inline.c,v
retrieving revision 1.162
diff -p -u -r1.162 tree-inline.c
--- tree-inline.c	4 Jan 2005 01:54:25 -0000	1.162
+++ tree-inline.c	17 Jan 2005 02:31:55 -0000
@@ -1580,7 +1580,18 @@ expand_call_inline (tree *tp, int *walk_
   /* Find the lhs to which the result of this call is assigned.  */
   modify_dest = tsi_stmt (id->tsi);
   if (TREE_CODE (modify_dest) == MODIFY_EXPR)
-    modify_dest = TREE_OPERAND (modify_dest, 0);
+    {
+      modify_dest = TREE_OPERAND (modify_dest, 0);
+
+      /* The function which we are inlining might not return a value,
+	 in which case we should issue a warning that the function
+	 does not return a value.  In that case the optimizers will
+	 see that the variable to which the value is assigned was not
+	 initialized.  We do not want to issue a warning about that
+	 uninitialized variable.  */
+      if (DECL_P (modify_dest))
+	TREE_NO_WARNING (modify_dest) = 1;
+    }
   else
     modify_dest = NULL;
 
Index: testsuite/gcc.dg/20040206-1.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/testsuite/gcc.dg/20040206-1.c,v
retrieving revision 1.3
diff -u -r1.3 20040206-1.c
--- testsuite/gcc.dg/20040206-1.c	18 Aug 2004 07:46:33 -0000	1.3
+++ testsuite/gcc.dg/20040206-1.c	17 Jan 2005 02:50:55 -0000
@@ -8,4 +8,4 @@
     returning non-void" is PR 13000. */
 
 static int foo (int a __attribute__((unused)) ) { }  /* { dg-warning "return" "" { xfail *-*-* } } */
-int main (void) { return foo (0); } /* { dg-bogus "uninitialized" "" { xfail *-*-* } } */
+int main (void) { return foo (0); }



More information about the Gcc-patches mailing list