From 9e898f4eb6198cda02e0eafe2487b6d1c4464b06 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?S=C3=A9bastien=20Villemot?= <sebastien.villemot@ens.fr>
Date: Mon, 21 Feb 2011 16:32:21 +0100
Subject: [PATCH] Preprocessor: avoid name clashes with model local variables

---
 ExprNode.cc  | 4 +++-
 ModelTree.cc | 4 +++-
 2 files changed, 6 insertions(+), 2 deletions(-)

diff --git a/ExprNode.cc b/ExprNode.cc
index b72f4e0e..3897415d 100644
--- a/ExprNode.cc
+++ b/ExprNode.cc
@@ -596,7 +596,9 @@ VariableNode::writeOutput(ostream &output, ExprNodeOutputType output_type,
           output << ")";
         }
       else
-        output << datatree.symbol_table.getName(symb_id);
+        /* We append underscores to avoid name clashes with "g1" or "oo_" (see
+           also ModelTree::writeModelLocalVariables) */
+        output << datatree.symbol_table.getName(symb_id) << "__";
       break;
 
     case eModFileLocalVariable:
diff --git a/ModelTree.cc b/ModelTree.cc
index 49586045..b6e5fb15 100644
--- a/ModelTree.cc
+++ b/ModelTree.cc
@@ -1171,7 +1171,9 @@ ModelTree::writeModelLocalVariables(ostream &output, ExprNodeOutputType output_t
       if (IS_C(output_type))
         output << "double ";
 
-      output << symbol_table.getName(id) << " = ";
+      /* We append underscores to avoid name clashes with "g1" or "oo_" (see
+         also VariableNode::writeOutput) */
+      output << symbol_table.getName(id) << "__ = ";
       // Use an empty set for the temporary terms
       value->writeOutput(output, output_type);
       output << ";" << endl;
-- 
GitLab