1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-06-06 17:26:01 +02:00

Bug 508254 - Static field of enclosing class type

We previously guarded against recursion in this case, but the
result was an invalid composite value that could cause problems
down the line.

This patch avoids getting into the recursion to begin with by
skipping the processing of static fields in a case where it's
not necessary to begin with.

Change-Id: Ic3a346092bb7ad5c94cd15871110dd17ecd64886
This commit is contained in:
Nathan Ridge 2016-12-12 04:16:32 -05:00
parent 9b3a28f334
commit ade410bbe9
2 changed files with 15 additions and 0 deletions

View file

@ -2386,4 +2386,17 @@ public class IndexCPPBindingResolutionTest extends IndexBindingResolutionTestBas
ICPPMethod[] pureVirtuals = SemanticQueries.getPureVirtualMethods((ICPPClassType) type, null);
assertEquals(0, pureVirtuals.length);
}
// class waldo {
// static waldo instance;
//
// constexpr waldo() {}
// };
//
// waldo waldo::instance;
// // empty file
public void testStaticFieldOfEnclosingType_508254() throws Exception {
checkBindings();
}
}

View file

@ -211,6 +211,8 @@ public final class CompositeValue implements IValue {
ICPPField[] fields = ClassTypeHelper.getDeclaredFields(classType, null);
for (ICPPField field : fields) {
if (field.isStatic())
continue;
final ICPPEvaluation value = EvalUtil.getVariableValue(field, record);
int fieldPos = CPPASTFieldReference.getFieldPosition(field);
record.update(field, value);