From 09e7dde0eaf9b60d759c41b41cb1319e313b8171 Mon Sep 17 00:00:00 2001
From: Houtan Bastani <houtan@dynare.org>
Date: Mon, 2 Jan 2017 11:37:15 +0100
Subject: [PATCH] fix warnings introduced in
 3b20d41a92db4267c0ba13278f3885aba67e6c47 related to size_t/int comparison
 #1201

---
 preprocessor/ModelTree.cc | 14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/preprocessor/ModelTree.cc b/preprocessor/ModelTree.cc
index 415bdfa4b8..a1c4f6a81b 100644
--- a/preprocessor/ModelTree.cc
+++ b/preprocessor/ModelTree.cc
@@ -1304,7 +1304,7 @@ ModelTree::fixNestedParenthesis(ostringstream &output, map<string, string> &tmp_
   bool hit_limit = false;
   int i1 = 0;
   map<string, string>::iterator it;
-  for (int i = 0; i < str.length(); i++)
+  for (size_t i = 0; i < str.length(); i++)
     {
       if (str.at(i) == '(')
         {
@@ -1334,10 +1334,10 @@ ModelTree::fixNestedParenthesis(ostringstream &output, map<string, string> &tmp_
           string varname;
           while (testNestedParenthesis(str1))
             {
-              int open_paren_idx = -1;
-              int match_paren_idx = -1;
-              int last_open_paren = -1;
-              for (int j = 0; j < str1.length(); j++)
+              size_t open_paren_idx  = string::npos;
+              size_t match_paren_idx = string::npos;
+              size_t last_open_paren = string::npos;
+              for (size_t j = 0; j < str1.length(); j++)
                 {
                   if (str1.at(j) == '(')
                     {
@@ -1355,7 +1355,7 @@ ModelTree::fixNestedParenthesis(ostringstream &output, map<string, string> &tmp_
                         match_paren_idx = j;
                     }
 
-                  if (open_paren_idx != -1 && match_paren_idx != -1)
+                  if (open_paren_idx != string::npos && match_paren_idx != string::npos)
                     {
                       string val = str1.substr(open_paren_idx, match_paren_idx - open_paren_idx + 1);
                       it = tmp_paren_vars.find(val);
@@ -1399,7 +1399,7 @@ bool
 ModelTree::testNestedParenthesis(const string &str) const
 {
   int open = 0;
-  for (int i = 0; i < str.length(); i++)
+  for (size_t i = 0; i < str.length(); i++)
     {
       if (str.at(i) == '(')
         open++;
-- 
GitLab