glsl: Eliminate assumptions about size of ir_expression::operands
[mesa.git] / src / glsl / ir_clone.cpp
index 18543a35aa19c93a4bb52e8b1537ec9b8ec437f3..4032647c3a29e63464fccbdef807b89fb1453f4d 100644 (file)
@@ -22,6 +22,7 @@
  */
 
 #include <string.h>
+#include "main/compiler.h"
 #include "ir.h"
 #include "glsl_types.h"
 extern "C" {
@@ -51,6 +52,9 @@ ir_variable::clone(void *mem_ctx, struct hash_table *ht) const
    var->warn_extension = this->warn_extension;
    var->origin_upper_left = this->origin_upper_left;
    var->pixel_center_integer = this->pixel_center_integer;
+   var->explicit_location = this->explicit_location;
+   if (this->explicit_location)
+      var->location = this->location;
 
    if (this->constant_value)
       var->constant_value = this->constant_value->clone(mem_ctx, ht);
@@ -157,7 +161,7 @@ ir_call::clone(void *mem_ctx, struct hash_table *ht) const
 ir_expression *
 ir_expression::clone(void *mem_ctx, struct hash_table *ht) const
 {
-   ir_rvalue *op[2] = {NULL, NULL};
+   ir_rvalue *op[Elements(this->operands)] = { NULL, };
    unsigned int i;
 
    for (i = 0; i < get_num_operands(); i++) {