summaryrefslogtreecommitdiff
path: root/src/libs/cplusplus
diff options
context:
space:
mode:
Diffstat (limited to 'src/libs/cplusplus')
-rw-r--r--src/libs/cplusplus/LookupContext.cpp11
-rw-r--r--src/libs/cplusplus/pp-engine.cpp27
2 files changed, 32 insertions, 6 deletions
diff --git a/src/libs/cplusplus/LookupContext.cpp b/src/libs/cplusplus/LookupContext.cpp
index 862ff1850e..a844414fc0 100644
--- a/src/libs/cplusplus/LookupContext.cpp
+++ b/src/libs/cplusplus/LookupContext.cpp
@@ -631,10 +631,15 @@ QList<LookupItem> ClassOrNamespace::lookup_helper(const Name *name, bool searchI
// a qualified name. For instance, a nested class which is forward declared
// in the class but defined outside it - we should capture both.
Symbol *match = 0;
+ QSet<ClassOrNamespace *> processed;
for (ClassOrNamespace *parentBinding = binding->parent();
parentBinding && !match;
- parentBinding = parentBinding->parent())
+ parentBinding = parentBinding->parent()) {
+ if (processed.contains(parentBinding))
+ break;
+ processed.insert(parentBinding);
match = parentBinding->lookupInScope(fullName);
+ }
if (match) {
LookupItem item;
@@ -648,8 +653,12 @@ QList<LookupItem> ClassOrNamespace::lookup_helper(const Name *name, bool searchI
}
QSet<ClassOrNamespace *> processed;
+ QSet<ClassOrNamespace *> processedOwnParents;
ClassOrNamespace *binding = this;
do {
+ if (processedOwnParents.contains(binding))
+ break;
+ processedOwnParents.insert(binding);
lookup_helper(name, binding, &result, &processed, /*templateId = */ 0);
binding = binding->_parent;
} while (searchInEnclosingScope && binding);
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