diff options
author | Kenneth Graunke <[email protected]> | 2010-04-21 11:52:05 -0700 |
---|---|---|
committer | Ian Romanick <[email protected]> | 2010-04-21 15:36:36 -0700 |
commit | 67a092ae09dbb2dd820aab5aa7742d3f884d6cd4 (patch) | |
tree | 4929579dd2967dc567d71599e00746f06155f1f0 | |
parent | ff236fa9b6a35ce261098d288f77f238c3286e15 (diff) |
Ensure that both parameter lists are the same length in function overloading.
Fixes new test function-05.glsl, where the second function has matching
parameter types, but less of them.
-rw-r--r-- | ast_to_hir.cpp | 15 | ||||
-rw-r--r-- | tests/function-05.glsl | 26 |
2 files changed, 33 insertions, 8 deletions
diff --git a/ast_to_hir.cpp b/ast_to_hir.cpp index 316bcf7d71c..addbeefc4be 100644 --- a/ast_to_hir.cpp +++ b/ast_to_hir.cpp @@ -1889,17 +1889,10 @@ parameter_lists_match(exec_list *list_a, exec_list *list_b) exec_list_iterator iter_a = list_a->iterator(); exec_list_iterator iter_b = list_b->iterator(); - while (iter_a.has_next()) { + while (iter_a.has_next() && iter_b.has_next()) { ir_variable *a = (ir_variable *)iter_a.get(); ir_variable *b = (ir_variable *)iter_b.get(); - /* If all of the parameters from the other parameter list have been - * exhausted, the lists have different length and, by definition, - * do not match. - */ - if (!iter_b.has_next()) - return false; - /* If the types of the parameters do not match, the parameters lists * are different. */ @@ -1910,6 +1903,12 @@ parameter_lists_match(exec_list *list_a, exec_list *list_b) iter_b.next(); } + /* Unless both lists are exhausted, they differ in length and, by + * definition, do not match. + */ + if (iter_a.has_next() != iter_b.has_next()) + return false; + return true; } diff --git a/tests/function-05.glsl b/tests/function-05.glsl new file mode 100644 index 00000000000..43365bf6062 --- /dev/null +++ b/tests/function-05.glsl @@ -0,0 +1,26 @@ +/* PASS */ + +vec4 foo(in float x, in float y, float z, float w) +{ + vec4 v; + v.x = x; + v.y = y; + v.z = z; + v.w = w; + return v; +} + +vec4 foo(in float x) +{ + vec4 v; + v.x = x; + v.y = x; + v.z = x; + v.w = x; +} + +void main() +{ + gl_Position = foo(1.0, 1.0, 1.0, 0.0); + gl_Position = foo(2.0); +} |