From 745e3c9d98bb7a0d76f3b86a3bdd335e56a7aa1a Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?S=C3=A9bastien=20Villemot?= <sebastien@dynare.org>
Date: Fri, 25 May 2018 14:47:34 +0200
Subject: [PATCH] Fix bug when a trinary operator becomes a temporary term with
 block decomposition (without bytecode)

---
 preprocessor/ExprNode.cc | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/preprocessor/ExprNode.cc b/preprocessor/ExprNode.cc
index 2aa85568e..1d0f4240a 100644
--- a/preprocessor/ExprNode.cc
+++ b/preprocessor/ExprNode.cc
@@ -4218,7 +4218,10 @@ TrinaryOpNode::writeOutput(ostream &output, ExprNodeOutputType output_type,
   temporary_terms_t::const_iterator it = temporary_terms.find(const_cast<TrinaryOpNode *>(this));
   if (it != temporary_terms.end())
     {
-      output << "T" << idx;
+      if (output_type == oMatlabDynamicModelSparse)
+        output << "T" << idx << "(it_)";
+      else
+        output << "T" << idx;
       return;
     }
 
-- 
GitLab