From: Mikko Rasa Date: Sun, 10 Oct 2021 11:40:52 +0000 (+0300) Subject: Remove support for redeclaring user-defined variables X-Git-Url: http://git.tdb.fi/?a=commitdiff_plain;ds=inline;h=6306d2f7018fe9aab3600b49332397d70306ef11;p=libs%2Fgl.git Remove support for redeclaring user-defined variables ... with the exception of redeclaring a previously unsized array. Builtin array sizes can also now be redeclared. --- diff --git a/source/glsl/resolve.cpp b/source/glsl/resolve.cpp index c62f19e5..c03ecae0 100644 --- a/source/glsl/resolve.cpp +++ b/source/glsl/resolve.cpp @@ -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; } }