From 5089933d82e69c4485843781aa4c762fc0c49be7 Mon Sep 17 00:00:00 2001 From: Mikko Rasa Date: Fri, 21 Jun 2019 11:23:21 +0300 Subject: [PATCH] Merge variable declaration layouts --- source/programcompiler.cpp | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/source/programcompiler.cpp b/source/programcompiler.cpp index 6b8d2eb8..9a3986a1 100644 --- a/source/programcompiler.cpp +++ b/source/programcompiler.cpp @@ -643,6 +643,27 @@ void ProgramCompiler::DeclarationCombiner::visit(VariableDeclaration &var) ptr->type = var.type; if(var.init_expression) ptr->init_expression = var.init_expression; + if(var.layout) + { + if(ptr->layout) + { + for(vector::iterator i=var.layout->qualifiers.begin(); i!=var.layout->qualifiers.end(); ++i) + { + bool found = false; + for(vector::iterator j=ptr->layout->qualifiers.begin(); (!found && j!=ptr->layout->qualifiers.end()); ++j) + if(j->identifier==i->identifier) + { + j->value = i->value; + found = true; + } + + if(!found) + ptr->layout->qualifiers.push_back(*i); + } + } + else + ptr->layout = var.layout; + } remove_node = true; } else -- 2.45.2