Commit b45c87bc authored by Andreas Pakulat's avatar Andreas Pakulat

Fix endless recursion in setSpecializedFrom

This could be triggered by having the exactly same specialization occur
twice in a single file. setSpecializedFrom would end up calling itself
with the same TemplateDeclaration over and over again.

Adding another recursion counter in the same way that other places already
have one fixes the problem. Unfortunately I wasn't able to generate a test
that exhibits the recursion problem.
parent 886ad1d9
......@@ -160,6 +160,7 @@ struct ThreadLocalData {
uint delayedDepth;
// recursion counter for alias type resolution
uint aliasDepth;
uint specializedFromDepth;
};
#if (QT_VERSION >= 0x040801)
......@@ -374,7 +375,30 @@ TemplateDeclaration* TemplateDeclaration::instantiatedFrom() const {
}
void TemplateDeclaration::setSpecializedFrom(TemplateDeclaration* other) {
ThreadLocalData& data = threadDataLocal();
PushValue<uint> safety(data.specializedFromDepth, data.specializedFromDepth+1);
if(data.specializedFromDepth > 30) {
QString withVal = "other";
if( other ) {
if( other->instantiatedFrom() ) {
withVal += ".instantiatedFrom() == " + other->instantiatedFrom()->id(true).qualifiedIdentifier().toString();
} else if( other->specializedFrom().data() ) {
withVal += ".specialiedFrom().data() == " + other->specializedFrom().data()->identifier().toString();
} else {
withVal += ".specializedFrom().data() == null && other.instantiatedFrom() == null";
}
} else {
withVal = " == null";
}
kWarning()
<< "depth-limit reached while setting specializedFrom"
<< (specializedFrom().data()
? specializedFrom().data()->identifier().toString()
: "this specializedFrom is null")
<< "with" << withVal;
return;
}
if(other && other->instantiatedFrom()) {
setSpecializedFrom(other->instantiatedFrom());
return;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment