Fix more MSVC2012 compiler warnings.
authorErik Verbruggen <erik.verbruggen@digia.com>
Wed, 5 Mar 2014 14:34:08 +0000 (15:34 +0100)
committerThe Qt Project <gerrit-noreply@qt-project.org>
Fri, 7 Mar 2014 10:00:45 +0000 (11:00 +0100)
All are conversions from size_t to int or to unsigned.

Change-Id: Ic94c938dcad6d50a32dd6ec62da2341869cf994d
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
src/3rdparty/masm/yarr/YarrInterpreter.cpp
src/3rdparty/masm/yarr/YarrPattern.cpp
src/qml/compiler/qv4ssa.cpp

index f0312ea..4a789f6 100644 (file)
@@ -1544,7 +1544,8 @@ public:
 
     void atomParenthesesOnceBegin(unsigned subpatternId, bool capture, unsigned inputPosition, unsigned frameLocation, unsigned alternativeFrameLocation)
     {
-        int beginTerm = m_bodyDisjunction->terms.size();
+        ASSERT(m_bodyDisjunction->terms.size() <= INT_MAX);
+        int beginTerm = static_cast<int>(m_bodyDisjunction->terms.size());
 
         m_bodyDisjunction->terms.append(ByteTerm(ByteTerm::TypeParenthesesSubpatternOnceBegin, subpatternId, capture, false, inputPosition));
         m_bodyDisjunction->terms[m_bodyDisjunction->terms.size() - 1].frameLocation = frameLocation;
@@ -1557,7 +1558,8 @@ public:
 
     void atomParenthesesTerminalBegin(unsigned subpatternId, bool capture, unsigned inputPosition, unsigned frameLocation, unsigned alternativeFrameLocation)
     {
-        int beginTerm = m_bodyDisjunction->terms.size();
+        ASSERT(m_bodyDisjunction->terms.size() <= INT_MAX);
+        int beginTerm = static_cast<int>(m_bodyDisjunction->terms.size());
 
         m_bodyDisjunction->terms.append(ByteTerm(ByteTerm::TypeParenthesesSubpatternTerminalBegin, subpatternId, capture, false, inputPosition));
         m_bodyDisjunction->terms[m_bodyDisjunction->terms.size() - 1].frameLocation = frameLocation;
@@ -1574,7 +1576,8 @@ public:
         // then fix this up at the end! - simplifying this should make it much clearer.
         // https://bugs.webkit.org/show_bug.cgi?id=50136
 
-        int beginTerm = m_bodyDisjunction->terms.size();
+        ASSERT(m_bodyDisjunction->terms.size() <= INT_MAX);
+        int beginTerm = static_cast<int>(m_bodyDisjunction->terms.size());
 
         m_bodyDisjunction->terms.append(ByteTerm(ByteTerm::TypeParenthesesSubpatternOnceBegin, subpatternId, capture, false, inputPosition));
         m_bodyDisjunction->terms[m_bodyDisjunction->terms.size() - 1].frameLocation = frameLocation;
@@ -1587,7 +1590,8 @@ public:
 
     void atomParentheticalAssertionBegin(unsigned subpatternId, bool invert, unsigned frameLocation, unsigned alternativeFrameLocation)
     {
-        int beginTerm = m_bodyDisjunction->terms.size();
+        ASSERT(m_bodyDisjunction->terms.size() <= INT_MAX);
+        int beginTerm = static_cast<int>(m_bodyDisjunction->terms.size());
 
         m_bodyDisjunction->terms.append(ByteTerm(ByteTerm::TypeParentheticalAssertionBegin, subpatternId, false, invert, 0));
         m_bodyDisjunction->terms[m_bodyDisjunction->terms.size() - 1].frameLocation = frameLocation;
@@ -1602,7 +1606,8 @@ public:
     {
         unsigned beginTerm = popParenthesesStack();
         closeAlternative(beginTerm + 1);
-        unsigned endTerm = m_bodyDisjunction->terms.size();
+        ASSERT(m_bodyDisjunction->terms.size() <= INT_MAX);
+        unsigned endTerm = static_cast<int>(m_bodyDisjunction->terms.size());
 
         ASSERT(m_bodyDisjunction->terms[beginTerm].type == ByteTerm::TypeParentheticalAssertionBegin);
 
@@ -1628,7 +1633,8 @@ public:
     unsigned popParenthesesStack()
     {
         ASSERT(m_parenthesesStack.size());
-        int stackEnd = m_parenthesesStack.size() - 1;
+        ASSERT(m_parenthesesStack.size() <= INT_MAX);
+        int stackEnd = static_cast<int>(m_parenthesesStack.size()) - 1;
         unsigned beginTerm = m_parenthesesStack[stackEnd].beginTerm;
         m_currentAlternativeIndex = m_parenthesesStack[stackEnd].savedAlternativeIndex;
         m_parenthesesStack.shrink(stackEnd);
@@ -1653,7 +1659,8 @@ public:
     {
         int origBeginTerm = beginTerm;
         ASSERT(m_bodyDisjunction->terms[beginTerm].type == ByteTerm::TypeAlternativeBegin);
-        int endIndex = m_bodyDisjunction->terms.size();
+        ASSERT(m_bodyDisjunction->terms.size() <= INT_MAX);
+        int endIndex = static_cast<int>(m_bodyDisjunction->terms.size());
 
         unsigned frameLocation = m_bodyDisjunction->terms[beginTerm].frameLocation;
 
@@ -1679,7 +1686,8 @@ public:
         int beginTerm = 0;
         int origBeginTerm = 0;
         ASSERT(m_bodyDisjunction->terms[beginTerm].type == ByteTerm::TypeBodyAlternativeBegin);
-        int endIndex = m_bodyDisjunction->terms.size();
+        ASSERT(m_bodyDisjunction->terms.size() <= INT_MAX);
+        int endIndex = static_cast<int>(m_bodyDisjunction->terms.size());
 
         unsigned frameLocation = m_bodyDisjunction->terms[beginTerm].frameLocation;
 
@@ -1700,7 +1708,8 @@ public:
     {
         unsigned beginTerm = popParenthesesStack();
         closeAlternative(beginTerm + 1);
-        unsigned endTerm = m_bodyDisjunction->terms.size();
+        ASSERT(m_bodyDisjunction->terms.size() <= INT_MAX);
+        unsigned endTerm = static_cast<int>(m_bodyDisjunction->terms.size());
 
         ASSERT(m_bodyDisjunction->terms[beginTerm].type == ByteTerm::TypeParenthesesSubpatternOnceBegin);
 
@@ -1734,7 +1743,8 @@ public:
     {
         unsigned beginTerm = popParenthesesStack();
         closeAlternative(beginTerm + 1);
-        unsigned endTerm = m_bodyDisjunction->terms.size();
+        ASSERT(m_bodyDisjunction->terms.size() <= INT_MAX);
+        unsigned endTerm = static_cast<int>(m_bodyDisjunction->terms.size());
 
         ASSERT(m_bodyDisjunction->terms[beginTerm].type == ByteTerm::TypeParenthesesSubpatternOnceBegin);
 
@@ -1756,7 +1766,8 @@ public:
     {
         unsigned beginTerm = popParenthesesStack();
         closeAlternative(beginTerm + 1);
-        unsigned endTerm = m_bodyDisjunction->terms.size();
+        ASSERT(m_bodyDisjunction->terms.size() <= INT_MAX);
+        unsigned endTerm = static_cast<int>(m_bodyDisjunction->terms.size());
 
         ASSERT(m_bodyDisjunction->terms[beginTerm].type == ByteTerm::TypeParenthesesSubpatternTerminalBegin);
 
@@ -1789,7 +1800,8 @@ public:
 
     void alternativeBodyDisjunction(bool onceThrough)
     {
-        int newAlternativeIndex = m_bodyDisjunction->terms.size();
+        ASSERT(m_bodyDisjunction->terms.size() <= INT_MAX);
+        int newAlternativeIndex = static_cast<int>(m_bodyDisjunction->terms.size());
         m_bodyDisjunction->terms[m_currentAlternativeIndex].alternative.next = newAlternativeIndex - m_currentAlternativeIndex;
         m_bodyDisjunction->terms.append(ByteTerm::BodyAlternativeDisjunction(onceThrough));
 
@@ -1798,7 +1810,8 @@ public:
 
     void alternativeDisjunction()
     {
-        int newAlternativeIndex = m_bodyDisjunction->terms.size();
+        ASSERT(m_bodyDisjunction->terms.size() <= INT_MAX);
+        int newAlternativeIndex = static_cast<int>(m_bodyDisjunction->terms.size());
         m_bodyDisjunction->terms[m_currentAlternativeIndex].alternative.next = newAlternativeIndex - m_currentAlternativeIndex;
         m_bodyDisjunction->terms.append(ByteTerm::AlternativeDisjunction());
 
index 3ce0216..ae527f0 100644 (file)
@@ -191,7 +191,8 @@ private:
     void addSorted(Vector<UChar>& matches, UChar ch)
     {
         unsigned pos = 0;
-        unsigned range = matches.size();
+        ASSERT(matches.size() <= UINT_MAX);
+        unsigned range = static_cast<unsigned>(matches.size());
 
         // binary chop, find position to insert char.
         while (range) {
@@ -216,7 +217,8 @@ private:
 
     void addSortedRange(Vector<CharacterRange>& ranges, UChar lo, UChar hi)
     {
-        unsigned end = ranges.size();
+        ASSERT(ranges.size() <= UINT_MAX);
+        unsigned end = static_cast<unsigned>(ranges.size());
         
         // Simple linear scan - I doubt there are that many ranges anyway...
         // feel free to fix this with something faster (eg binary chop).
@@ -427,7 +429,8 @@ public:
 
         PatternTerm& lastTerm = m_alternative->lastTerm();
 
-        unsigned numParenAlternatives = parenthesesDisjunction->m_alternatives.size();
+        ASSERT(parenthesesDisjunction->m_alternatives.size() <= UINT_MAX);
+        unsigned numParenAlternatives = static_cast<unsigned>(parenthesesDisjunction->m_alternatives.size());
         unsigned numBOLAnchoredAlts = 0;
 
         for (unsigned i = 0; i < numParenAlternatives; i++) {
index e2c88c8..847df6e 100644 (file)
@@ -315,10 +315,12 @@ public:
     public:
         BasicBlock *operator*() const
         {
-            if (set.blockNumbers)
+            if (set.blockNumbers) {
                 return set.allBlocks.at(*numberIt);
-            else
-                return set.allBlocks.at(flagIt);
+            } else {
+                Q_ASSERT(flagIt <= INT_MAX);
+                return set.allBlocks.at(static_cast<int>(flagIt));
+            }
         }
 
         bool operator==(const const_iterator &other) const
@@ -490,7 +492,8 @@ class DominatorTree {
 
         BasicBlockIndex b = InvalidBasicBlockIndex;
         BasicBlockIndex last = worklist.back();
-        for (int it = worklist.size() - 2; it >= 0; --it) {
+        Q_ASSERT(worklist.size() <= INT_MAX);
+        for (int it = static_cast<int>(worklist.size()) - 2; it >= 0; --it) {
             BasicBlockIndex bbIt = worklist[it];
             ancestor[bbIt] = last;
             BasicBlockIndex &best_it = best[bbIt];