Hi all,

I'm getting a warning when building genrecog that 'label' may be used 
uninitialised in:

      uint64_t label = 0;

      if (d->test.kind == rtx_test::CODE
      && d->if_statement_p (&label)
      && label == CONST_INT)

This is because if_statement_p looks like this:
 inline bool
 decision::if_statement_p (uint64_t *label) const
 {
   if (singleton () && first->labels.length () == 1)
     {
       if (label)
         *label = first->labels[0];
       return true;
     }
   return false;
 }

It's not guaranteed to write label.
This patch initialises label to 0 to fix the warning.
Is this the right thing to do?

Bootstrapped and tested on aarch64-none-linux-gnu and arm-none-linux-gnueabihf.

Thanks,
Kyrill

2016-04-29  Kyrylo Tkachov  <kyrylo.tkac...@arm.com>

    * genrecog.c (simplify_tests): Initialize label to 0.
diff --git a/gcc/genrecog.c b/gcc/genrecog.c
index 47e42660fcc854e5da3eba4bee2bb4b06a7352b1..0e62c61a8a756766c12138b51498229f442f44d0 100644
--- a/gcc/genrecog.c
+++ b/gcc/genrecog.c
@@ -1583,7 +1583,7 @@ simplify_tests (state *s)
 {
   for (decision *d = s->first; d; d = d->next)
     {
-      uint64_t label;
+      uint64_t label = 0;
       /* Convert checks for GET_CODE (x) == CONST_INT and XWINT (x, 0) == N
 	 into checks for const_int_rtx[N'], if N is suitably small.  */
       if (d->test.kind == rtx_test::CODE

Reply via email to