diff mbox

Fix PR78295

Message ID alpine.LSU.2.11.1611111335450.5294@t29.fhfr.qr
State New
Headers show

Commit Message

Richard Biener Nov. 11, 2016, 12:36 p.m. UTC
The following fixes an unwanted uninit warning.

Bootstrapped and tested on x86_64-unknown-linxu-gnu, applied.

Richard.

2016-11-11  Richard Biener  <rguenther@suse.de>

	PR middle-end/78295
	* tree-ssa-uninit.c (warn_uninitialized_vars): Do not warn
	about uninitialized destination arg of BIT_INSERT_EXPR.

	* gcc.dg/uninit-pr78295.c: New testcase.
diff mbox

Patch

Index: gcc/tree-ssa-uninit.c
===================================================================
--- gcc/tree-ssa-uninit.c	(revision 242004)
+++ gcc/tree-ssa-uninit.c	(working copy)
@@ -212,6 +212,14 @@  warn_uninitialized_vars (bool warn_possi
 	     can warn about.  */
 	  FOR_EACH_SSA_USE_OPERAND (use_p, stmt, op_iter, SSA_OP_USE)
 	    {
+	      /* BIT_INSERT_EXPR first operand should not be considered
+	         a use for the purpose of uninit warnings.  */
+	      if (gassign *ass = dyn_cast <gassign *> (stmt))
+		{
+		  if (gimple_assign_rhs_code (ass) == BIT_INSERT_EXPR
+		      && use_p->use == gimple_assign_rhs1_ptr (ass))
+		    continue;
+		}
 	      use = USE_FROM_PTR (use_p);
 	      if (always_executed)
 		warn_uninit (OPT_Wuninitialized, use, SSA_NAME_VAR (use),
Index: gcc/testsuite/gcc.dg/uninit-pr78295.c
===================================================================
--- gcc/testsuite/gcc.dg/uninit-pr78295.c	(revision 0)
+++ gcc/testsuite/gcc.dg/uninit-pr78295.c	(working copy)
@@ -0,0 +1,13 @@ 
+/* { dg-do compile } */
+/* { dg-options "-O2 -Wall" } */
+
+typedef double vectype __attribute__ ((__vector_size__ (16)));
+
+vectype
+f (double x)
+{
+  vectype t;
+  for (int i = 0; i < 2; i++)
+    t[i] = x; /* { dg-bogus "uninitialized" } */
+  return t;
+}