From: Erik Verbruggen Date: Wed, 5 Mar 2014 14:34:08 +0000 (+0100) Subject: Fix more MSVC2012 compiler warnings. X-Git-Tag: upstream/5.2.90+alpha~35 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=90487ebb7584bde9283e154228b9494e3b7bd8fe;p=platform%2Fupstream%2Fqtdeclarative.git Fix more MSVC2012 compiler warnings. All are conversions from size_t to int or to unsigned. Change-Id: Ic94c938dcad6d50a32dd6ec62da2341869cf994d Reviewed-by: Simon Hausmann --- diff --git a/src/3rdparty/masm/yarr/YarrInterpreter.cpp b/src/3rdparty/masm/yarr/YarrInterpreter.cpp index f0312ea..4a789f6 100644 --- a/src/3rdparty/masm/yarr/YarrInterpreter.cpp +++ b/src/3rdparty/masm/yarr/YarrInterpreter.cpp @@ -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(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(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(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(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(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(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(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(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(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(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(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(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(m_bodyDisjunction->terms.size()); m_bodyDisjunction->terms[m_currentAlternativeIndex].alternative.next = newAlternativeIndex - m_currentAlternativeIndex; m_bodyDisjunction->terms.append(ByteTerm::AlternativeDisjunction()); diff --git a/src/3rdparty/masm/yarr/YarrPattern.cpp b/src/3rdparty/masm/yarr/YarrPattern.cpp index 3ce0216..ae527f0 100644 --- a/src/3rdparty/masm/yarr/YarrPattern.cpp +++ b/src/3rdparty/masm/yarr/YarrPattern.cpp @@ -191,7 +191,8 @@ private: void addSorted(Vector& matches, UChar ch) { unsigned pos = 0; - unsigned range = matches.size(); + ASSERT(matches.size() <= UINT_MAX); + unsigned range = static_cast(matches.size()); // binary chop, find position to insert char. while (range) { @@ -216,7 +217,8 @@ private: void addSortedRange(Vector& ranges, UChar lo, UChar hi) { - unsigned end = ranges.size(); + ASSERT(ranges.size() <= UINT_MAX); + unsigned end = static_cast(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(parenthesesDisjunction->m_alternatives.size()); unsigned numBOLAnchoredAlts = 0; for (unsigned i = 0; i < numParenAlternatives; i++) { diff --git a/src/qml/compiler/qv4ssa.cpp b/src/qml/compiler/qv4ssa.cpp index e2c88c8..847df6e 100644 --- a/src/qml/compiler/qv4ssa.cpp +++ b/src/qml/compiler/qv4ssa.cpp @@ -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(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(worklist.size()) - 2; it >= 0; --it) { BasicBlockIndex bbIt = worklist[it]; ancestor[bbIt] = last; BasicBlockIndex &best_it = best[bbIt];