diff options
author | Nathan Ridge | 2016-12-12 09:16:32 +0000 |
---|---|---|
committer | Nathan Ridge | 2016-12-27 00:43:35 +0000 |
commit | ade410bbe96f4e45e2e627bbd27b662e6a520a9b (patch) | |
tree | d797e886c646373133bcdb64bee35e87d24210ea | |
parent | 9b3a28f334b9c8ce452fc8ae83d2317bd39f2ced (diff) | |
download | org.eclipse.cdt-ade410bbe96f4e45e2e627bbd27b662e6a520a9b.tar.gz org.eclipse.cdt-ade410bbe96f4e45e2e627bbd27b662e6a520a9b.tar.xz org.eclipse.cdt-ade410bbe96f4e45e2e627bbd27b662e6a520a9b.zip |
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
2 files changed, 15 insertions, 0 deletions
diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/index/tests/IndexCPPBindingResolutionTest.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/index/tests/IndexCPPBindingResolutionTest.java index 09200b3e140..ac0b9375d31 100644 --- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/index/tests/IndexCPPBindingResolutionTest.java +++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/index/tests/IndexCPPBindingResolutionTest.java @@ -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(); + } } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/CompositeValue.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/CompositeValue.java index 009c1f92972..3ea358fbfd5 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/CompositeValue.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/CompositeValue.java @@ -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); |