]> git.tdb.fi Git - libs/gl.git/commitdiff
Remove support for redeclaring user-defined variables
authorMikko Rasa <tdb@tdb.fi>
Sun, 10 Oct 2021 11:40:52 +0000 (14:40 +0300)
committerMikko Rasa <tdb@tdb.fi>
Sun, 10 Oct 2021 11:47:49 +0000 (14:47 +0300)
... with the exception of redeclaring a previously unsized array.
Builtin array sizes can also now be redeclared.

source/glsl/resolve.cpp

index c62f19e57fb4dea5abc4b59ce55541bca14ee890..c03ecae08c80d5bbe9be4c942a8379482b2bbe14 100644 (file)
@@ -399,23 +399,28 @@ void VariableResolver::visit(VariableDeclaration &var)
        else if(!current_block->parent && ptr->interface==var.interface && ptr->type==var.type)
        {
                if(ptr->source==BUILTIN_SOURCE)
-                       redeclared_builtins.push_back(&var);
-               else
-                       stage->diagnostics.push_back(Diagnostic(Diagnostic::WARN, var.source, var.line,
-                               format("Redeclaring non-builtin variable '%s' is deprecated", var.name)));
+               {
+                       redeclared_builtins.push_back(ptr);
+
+                       if(var.layout)
+                       {
+                               if(ptr->layout)
+                                       merge_layouts(*ptr->layout, *var.layout);
+                               else
+                                       ptr->layout = var.layout;
+                       }
+                       if(var.array_size)
+                               ptr->array_size = var.array_size;
 
-               if(var.init_expression)
-                       ptr->init_expression = var.init_expression;
-               if(var.layout)
+                       nodes_to_remove.insert(&var);
+                       r_any_resolved = true;
+               }
+               else if(ptr->array && !ptr->array_size && !var.layout && !var.init_expression)
                {
-                       if(ptr->layout)
-                               merge_layouts(*ptr->layout, *var.layout);
-                       else
-                               ptr->layout = var.layout;
+                       ptr->array_size = var.array_size;
+                       nodes_to_remove.insert(&var);
+                       r_any_resolved = true;
                }
-               nodes_to_remove.insert(&var);
-
-               r_any_resolved = true;
        }
 }