summaryrefslogtreecommitdiff
path: root/src/libs/cplusplus/pp-engine.cpp
diff options
context:
space:
mode:
authorEike Ziller <eike.ziller@theqtcompany.com>2015-02-12 17:36:29 +0100
committerEike Ziller <eike.ziller@theqtcompany.com>2015-02-12 17:36:29 +0100
commit56aadc407d7becadec794e660ae7d7c20e820e0c (patch)
treec9aad23933bc6b0c68406e64e359f57143ef54d8 /src/libs/cplusplus/pp-engine.cpp
parent9926fc2ab12ccaa02b7f03b416c54cd58ef30b31 (diff)
parent28971701fd4baa99f294d9393650b83c40754e18 (diff)
downloadqt-creator-56aadc407d7becadec794e660ae7d7c20e820e0c.tar.gz
Merge remote-tracking branch 'origin/3.3'
Conflicts: src/plugins/debugger/watchhandler.cpp src/plugins/projectexplorer/kitmodel.cpp src/plugins/qbsprojectmanager/qbsprojectmanager.cpp src/shared/qbs Change-Id: I6a68090993a264e93ac7850858cc24ba6bdb5602
Diffstat (limited to 'src/libs/cplusplus/pp-engine.cpp')
-rw-r--r--src/libs/cplusplus/pp-engine.cpp27
1 files changed, 22 insertions, 5 deletions
diff --git a/src/libs/cplusplus/pp-engine.cpp b/src/libs/cplusplus/pp-engine.cpp
index 05a8f66c87..ba8470e50e 100644
--- a/src/libs/cplusplus/pp-engine.cpp
+++ b/src/libs/cplusplus/pp-engine.cpp
@@ -140,6 +140,12 @@ static bool isQtReservedWord(const char *name, int size)
return false;
}
+static void nestingTooDeep()
+{
+#ifndef NO_DEBUG
+ std::cerr << "*** WARNING #if / #ifdef nesting exceeded the max level " << MAX_LEVEL << std::endl;
+#endif
+}
} // anonymous namespace
@@ -1824,6 +1830,12 @@ void Preprocessor::handleIfDirective(PPToken *tk)
lex(tk); // consume "if" token
Value result;
const PPToken lastExpressionToken = evalExpression(tk, result);
+
+ if (m_state.m_ifLevel >= MAX_LEVEL - 1) {
+ nestingTooDeep();
+ return;
+ }
+
const bool value = !result.is_zero();
const bool wasSkipping = m_state.m_skipping[m_state.m_ifLevel];
@@ -1950,12 +1962,17 @@ void Preprocessor::handleIfDefDirective(bool checkUndefined, PPToken *tk)
value = !value;
const bool wasSkipping = m_state.m_skipping[m_state.m_ifLevel];
- ++m_state.m_ifLevel;
- m_state.m_trueTest[m_state.m_ifLevel] = value;
- m_state.m_skipping[m_state.m_ifLevel] = wasSkipping ? wasSkipping : !value;
- if (m_client && !wasSkipping && !value)
- startSkippingBlocks(*tk);
+ if (m_state.m_ifLevel < MAX_LEVEL - 1) {
+ ++m_state.m_ifLevel;
+ m_state.m_trueTest[m_state.m_ifLevel] = value;
+ m_state.m_skipping[m_state.m_ifLevel] = wasSkipping ? wasSkipping : !value;
+
+ if (m_client && !wasSkipping && !value)
+ startSkippingBlocks(*tk);
+ } else {
+ nestingTooDeep();
+ }
lex(tk); // consume the identifier
#ifndef NO_DEBUG