From e76dfadc783862c44418be8a7003f3350feaf429 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

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

diff --git a/preprocessor/ExprNode.cc b/preprocessor/ExprNode.cc
index b72f4e0e51..3897415d36 100644
--- a/preprocessor/ExprNode.cc
+++ b/preprocessor/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/preprocessor/ModelTree.cc b/preprocessor/ModelTree.cc
index 495860453b..b6e5fb1531 100644
--- a/preprocessor/ModelTree.cc
+++ b/preprocessor/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