summaryrefslogtreecommitdiffstats
path: root/src/mesa/program/program.h
diff options
context:
space:
mode:
authorPaul Berry <[email protected]>2013-12-17 09:54:38 -0800
committerPaul Berry <[email protected]>2013-12-30 11:21:27 -0800
commit99e822fa18a322f7bf0d32ce99eab534d5614469 (patch)
treed2dd92b2c2f2312a9d5582534dc4b2f5073b274d /src/mesa/program/program.h
parentb30e25f29752fe3782d9ad43cb2cee46885c487d (diff)
mesa: Improve static error checking of arrays sized by MESA_SHADER_TYPES.
This patch replaces the following pattern: foo bar[MESA_SHADER_TYPES] = { ... }; With: foo bar[] = { ... }; STATIC_ASSERT(Elements(bar) == MESA_SHADER_TYPES); This way, when a new shader type is added in a future version of Mesa, we will get a compile error to remind us that the array needs to be updated. Reviewed-by: Brian Paul <[email protected]>
Diffstat (limited to 'src/mesa/program/program.h')
-rw-r--r--src/mesa/program/program.h3
1 files changed, 2 insertions, 1 deletions
diff --git a/src/mesa/program/program.h b/src/mesa/program/program.h
index 353ccab4789..135271caf9a 100644
--- a/src/mesa/program/program.h
+++ b/src/mesa/program/program.h
@@ -210,11 +210,12 @@ _mesa_program_target_to_index(GLenum v)
static inline GLenum
_mesa_program_index_to_target(GLuint i)
{
- static const GLenum enums[MESA_SHADER_TYPES] = {
+ static const GLenum enums[] = {
GL_VERTEX_PROGRAM_ARB,
GL_GEOMETRY_PROGRAM_NV,
GL_FRAGMENT_PROGRAM_ARB
};
+ STATIC_ASSERT(Elements(enums) == MESA_SHADER_TYPES);
if(i >= MESA_SHADER_TYPES)
return 0;
else