summaryrefslogtreecommitdiffstats
path: root/src/glsl/ast_to_hir.cpp
diff options
context:
space:
mode:
authorEric Anholt <[email protected]>2012-01-30 09:50:35 -0800
committerEric Anholt <[email protected]>2012-02-03 11:07:04 +0100
commit57e44371a5b6aa8122b6a482ed6bd33e797ea1d2 (patch)
tree73824cdf7b1a39e036dc21ffb7d197643b6c2e98 /src/glsl/ast_to_hir.cpp
parent140632190cf41e6a035ca199b181091d4ed46986 (diff)
glsl: Add error case for switch() with two default cases.
Fixes piglit switch-case-duplicated.vert. NOTE: This is a candidate for the 8.0 branch. Reviewed-by: Ian Romanick <[email protected]>
Diffstat (limited to 'src/glsl/ast_to_hir.cpp')
-rw-r--r--src/glsl/ast_to_hir.cpp15
1 files changed, 15 insertions, 0 deletions
diff --git a/src/glsl/ast_to_hir.cpp b/src/glsl/ast_to_hir.cpp
index 4f328ad8f46..c580359fdd0 100644
--- a/src/glsl/ast_to_hir.cpp
+++ b/src/glsl/ast_to_hir.cpp
@@ -3537,6 +3537,7 @@ ast_switch_statement::hir(exec_list *instructions,
state->switch_state.switch_nesting_ast = this;
state->switch_state.labels_ht = hash_table_ctor(0, hash_table_pointer_hash,
hash_table_pointer_compare);
+ state->switch_state.previous_default = NULL;
/* Initalize is_fallthru state to false.
*/
@@ -3749,6 +3750,20 @@ ast_switch_statement::hir(exec_list *instructions,
instructions->push_tail(set_fallthru_on_test);
} else { /* default case */
+ if (state->switch_state.previous_default) {
+ printf("a\n");
+ YYLTYPE loc = this->get_location();
+ _mesa_glsl_error(& loc, state,
+ "multiple default labels in one switch");
+
+ printf("b\n");
+
+ loc = state->switch_state.previous_default->get_location();
+ _mesa_glsl_error(& loc, state,
+ "this is the first default label");
+ }
+ state->switch_state.previous_default = this;
+
/* Set falltrhu state.
*/
ir_assignment *set_fallthru =