glsl: Replace most default cases in switches on GLSL type

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>
This commit is contained in:
Ian Romanick
2012-12-11 12:56:03 -08:00
parent 416326e337
commit ecfb404e8d
10 changed files with 48 additions and 23 deletions

View 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. * ignores the sampler present in the type.
*/ */
break; break;
default:
assert(!"Should not get here.");
break;
} }
if (cmp == NULL) if (cmp == NULL)

View File

@@ -672,9 +672,13 @@ glsl_type::component_slots() const
case GLSL_TYPE_ARRAY: case GLSL_TYPE_ARRAY:
return this->length * this->fields.array->component_slots(); return this->length * this->fields.array->component_slots();
default: case GLSL_TYPE_SAMPLER:
return 0; case GLSL_TYPE_VOID:
case GLSL_TYPE_ERROR:
break;
} }
return 0;
} }
bool bool

View File

@@ -375,10 +375,14 @@ ir_constant::clone(void *mem_ctx, struct hash_table *ht) const
return c; return c;
} }
default: case GLSL_TYPE_SAMPLER:
case GLSL_TYPE_VOID:
case GLSL_TYPE_ERROR:
assert(!"Should not get here."); assert(!"Should not get here.");
return NULL; break;
} }
return NULL;
} }

View File

@@ -67,7 +67,10 @@ copy_constant_to_storage(union gl_constant_value *storage,
case GLSL_TYPE_BOOL: case GLSL_TYPE_BOOL:
storage[i].b = int(val->value.b[i]); storage[i].b = int(val->value.b[i]);
break; 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 /* All other types should have already been filtered by other
* paths in the caller. * paths in the caller.
*/ */

View File

@@ -455,10 +455,13 @@ fs_visitor::type_size(const struct glsl_type *type)
* link time. * link time.
*/ */
return 0; return 0;
default: case GLSL_TYPE_VOID:
case GLSL_TYPE_ERROR:
assert(!"not reached"); assert(!"not reached");
return 0; break;
} }
return 0;
} }
fs_reg fs_reg

View File

@@ -698,7 +698,8 @@ fs_visitor::emit_assignment_writes(fs_reg &l, fs_reg &r,
case GLSL_TYPE_SAMPLER: case GLSL_TYPE_SAMPLER:
break; break;
default: case GLSL_TYPE_VOID:
case GLSL_TYPE_ERROR:
assert(!"not reached"); assert(!"not reached");
break; break;
} }

View File

@@ -285,10 +285,13 @@ brw_type_for_base_type(const struct glsl_type *type)
* way to trip up if we don't. * way to trip up if we don't.
*/ */
return BRW_REGISTER_TYPE_UD; return BRW_REGISTER_TYPE_UD;
default: case GLSL_TYPE_VOID:
case GLSL_TYPE_ERROR:
assert(!"not reached"); assert(!"not reached");
return BRW_REGISTER_TYPE_F; break;
} }
return BRW_REGISTER_TYPE_F;
} }
uint32_t uint32_t

View File

@@ -509,10 +509,13 @@ type_size(const struct glsl_type *type)
* at link time. * at link time.
*/ */
return 1; return 1;
default: case GLSL_TYPE_VOID:
case GLSL_TYPE_ERROR:
assert(0); assert(0);
return 0; break;
} }
return 0;
} }
int int

View File

@@ -623,10 +623,13 @@ type_size(const struct glsl_type *type)
* at link time. * at link time.
*/ */
return 1; return 1;
default: case GLSL_TYPE_VOID:
assert(0); case GLSL_TYPE_ERROR:
return 0; assert(!"Invalid type in type_size");
break;
} }
return 0;
} }
/** /**
@@ -2529,7 +2532,10 @@ _mesa_associate_uniform_storage(struct gl_context *ctx,
format = uniform_native; format = uniform_native;
columns = 1; columns = 1;
break; break;
default: case GLSL_TYPE_ARRAY:
case GLSL_TYPE_VOID:
case GLSL_TYPE_STRUCT:
case GLSL_TYPE_ERROR:
assert(!"Should not get here."); assert(!"Should not get here.");
break; break;
} }

View File

@@ -984,10 +984,12 @@ type_size(const struct glsl_type *type)
* at link time. * at link time.
*/ */
return 1; return 1;
default: case GLSL_TYPE_VOID:
assert(0); case GLSL_TYPE_ERROR:
return 0; assert(!"Invalid type in type_size");
break;
} }
return 0;
} }
/** /**