glsl: Replace most default cases in switches on GLSL type
authorIan Romanick <ian.d.romanick@intel.com>
Tue, 11 Dec 2012 20:56:03 +0000 (12:56 -0800)
committerIan Romanick <ian.d.romanick@intel.com>
Fri, 25 Jan 2013 14:07:32 +0000 (09:07 -0500)
This makes it easier to find switch-statements that need to be updated
after a new GLSL_TYPE_* is added because the compiler will generate a
warning.

Switch-statements that only had a small number of cases (e.g.,
everything in ir_constant_expression.cpp) were not modified.  I may
regret that decision when we eventually add support for doubles.

Signed-off-by: Ian Romanick <ian.d.romanick@intel.com>
Reviewed-by: Carl Worth <cworth@cworth.org>
Reviewed-by: Chad Versace <chad.versace@linux.intel.com>
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
src/glsl/ast_to_hir.cpp
src/glsl/glsl_types.cpp
src/glsl/ir_clone.cpp
src/glsl/link_uniform_initializers.cpp
src/mesa/drivers/dri/i965/brw_fs.cpp
src/mesa/drivers/dri/i965/brw_fs_visitor.cpp
src/mesa/drivers/dri/i965/brw_shader.cpp
src/mesa/drivers/dri/i965/brw_vec4_visitor.cpp
src/mesa/program/ir_to_mesa.cpp
src/mesa/state_tracker/st_glsl_to_tgsi.cpp

index 33e20a8208d2557fcfabe6b2868137b50c33e273..e76544a2c4c94e3ad550a1214605e74a33f5a18b 100644 (file)
@@ -861,10 +861,6 @@ do_comparison(void *mem_ctx, int operation, ir_rvalue *op0, ir_rvalue *op1)
        * ignores the sampler present in the type.
        */
       break;
-
-   default:
-      assert(!"Should not get here.");
-      break;
    }
 
    if (cmp == NULL)
index 71b1850278a784091d4c6d42e244d45a2273e9f6..7386760a1a26e5a6c01727367d6ec0872347155b 100644 (file)
@@ -672,9 +672,13 @@ glsl_type::component_slots() const
    case GLSL_TYPE_ARRAY:
       return this->length * this->fields.array->component_slots();
 
-   default:
-      return 0;
+   case GLSL_TYPE_SAMPLER:
+   case GLSL_TYPE_VOID:
+   case GLSL_TYPE_ERROR:
+      break;
    }
+
+   return 0;
 }
 
 bool
index c62c1fc20b2829176dcb599a210e02ad23607c37..9b7981b5622d0ca950c59c4c7f300e951812411b 100644 (file)
@@ -375,10 +375,14 @@ ir_constant::clone(void *mem_ctx, struct hash_table *ht) const
       return c;
    }
 
-   default:
+   case GLSL_TYPE_SAMPLER:
+   case GLSL_TYPE_VOID:
+   case GLSL_TYPE_ERROR:
       assert(!"Should not get here.");
-      return NULL;
+      break;
    }
+
+   return NULL;
 }
 
 
index 849e080970adffb5f2972a58d8089c7095b7f714..933df29449dbfd34f04affcc5e4ab8b04852a487 100644 (file)
@@ -67,7 +67,10 @@ copy_constant_to_storage(union gl_constant_value *storage,
       case GLSL_TYPE_BOOL:
         storage[i].b = int(val->value.b[i]);
         break;
-      default:
+      case GLSL_TYPE_ARRAY:
+      case GLSL_TYPE_STRUCT:
+      case GLSL_TYPE_VOID:
+      case GLSL_TYPE_ERROR:
         /* All other types should have already been filtered by other
          * paths in the caller.
          */
index 0d2dde72be4289c09e65dbcb58400b815b66e0d5..03b0630a75548f59d66ab2e14f3897de9d38e4a8 100644 (file)
@@ -455,10 +455,13 @@ fs_visitor::type_size(const struct glsl_type *type)
        * link time.
        */
       return 0;
-   default:
+   case GLSL_TYPE_VOID:
+   case GLSL_TYPE_ERROR:
       assert(!"not reached");
-      return 0;
+      break;
    }
+
+   return 0;
 }
 
 fs_reg
index 2b1332f1acc526420e0fab5317858c6ddf75eac4..9f6af6f872a34b78dd4e3d9aa63823f4a633034f 100644 (file)
@@ -698,7 +698,8 @@ fs_visitor::emit_assignment_writes(fs_reg &l, fs_reg &r,
    case GLSL_TYPE_SAMPLER:
       break;
 
-   default:
+   case GLSL_TYPE_VOID:
+   case GLSL_TYPE_ERROR:
       assert(!"not reached");
       break;
    }
index 1c02c87a11b19e1f9915b3c9c7dcb6463497b318..6abf714f3a17385faccf3d70c098d132ad9f8af7 100644 (file)
@@ -285,10 +285,13 @@ brw_type_for_base_type(const struct glsl_type *type)
        * way to trip up if we don't.
        */
       return BRW_REGISTER_TYPE_UD;
-   default:
+   case GLSL_TYPE_VOID:
+   case GLSL_TYPE_ERROR:
       assert(!"not reached");
-      return BRW_REGISTER_TYPE_F;
+      break;
    }
+
+   return BRW_REGISTER_TYPE_F;
 }
 
 uint32_t
index 4fb365d9acdc3a744c0a2093ed00749d6025f255..84dcc48341b603998801f58fbc979def52a4f957 100644 (file)
@@ -509,10 +509,13 @@ type_size(const struct glsl_type *type)
        * at link time.
        */
       return 1;
-   default:
+   case GLSL_TYPE_VOID:
+   case GLSL_TYPE_ERROR:
       assert(0);
-      return 0;
+      break;
    }
+
+   return 0;
 }
 
 int
index 544b4a93c23a89256b9816136fab3ca4fec7c76b..fc892fe86cc8d2d20a0f4b4e27eb71fcf8bcd7f1 100644 (file)
@@ -623,10 +623,13 @@ type_size(const struct glsl_type *type)
        * at link time.
        */
       return 1;
-   default:
-      assert(0);
-      return 0;
+   case GLSL_TYPE_VOID:
+   case GLSL_TYPE_ERROR:
+      assert(!"Invalid type in type_size");
+      break;
    }
+
+   return 0;
 }
 
 /**
@@ -2529,7 +2532,10 @@ _mesa_associate_uniform_storage(struct gl_context *ctx,
            format = uniform_native;
            columns = 1;
            break;
-        default:
+         case GLSL_TYPE_ARRAY:
+         case GLSL_TYPE_VOID:
+         case GLSL_TYPE_STRUCT:
+         case GLSL_TYPE_ERROR:
            assert(!"Should not get here.");
            break;
         }
index 575636e6e571ac674253bb782efa60afcdbd8d1b..643a9bbb09d1af0b2f43df39973cf639ec9f9774 100644 (file)
@@ -984,10 +984,12 @@ type_size(const struct glsl_type *type)
        * at link time.
        */
       return 1;
-   default:
-      assert(0);
-      return 0;
+   case GLSL_TYPE_VOID:
+   case GLSL_TYPE_ERROR:
+      assert(!"Invalid type in type_size");
+      break;
    }
+   return 0;
 }
 
 /**