On 08/01/2019 17:33, Caio Marcelo de Oliveira Filho wrote:
Add unreachable case for invalid deref type. Fixes the warning below

     In file included from ../src/compiler/nir/nir_lower_io.c:34:
     ../src/compiler/nir/nir_lower_io.c: In function ‘nir_lower_explicit_io’:
     ../src/compiler/nir/nir.h:668:11: warning: ‘addr’ may be used 
uninitialized in this function [-Wmaybe-uninitialized]
         return src;
                ^~~
     ../src/compiler/nir/nir_lower_io.c:735:17: note: ‘addr’ was declared here
         nir_ssa_def *addr;
                      ^~~~
---
  src/compiler/nir/nir_lower_io.c | 4 ++++
  1 file changed, 4 insertions(+)

diff --git a/src/compiler/nir/nir_lower_io.c b/src/compiler/nir/nir_lower_io.c
index bcbfebdfa3b..4a322da609e 100644
--- a/src/compiler/nir/nir_lower_io.c
+++ b/src/compiler/nir/nir_lower_io.c
@@ -783,6 +783,10 @@ lower_explicit_io_deref(nir_builder *b, nir_deref_instr 
*deref,
        /* Nothing to do here */
        addr = parent_addr;
        break;
+
+   default:
+      unreachable("Invalid deref type");
+      break;


Just a thought, but you could rather set the addr variable to NULL before the switch so that if a new deref type is ever added, the compiler can find all the places we need to update.


-

Lionel

     }
nir_instr_remove(&deref->instr);


_______________________________________________
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev

Reply via email to