From 3f8b3f0870e55311dbda27f62884ac23e3bc9253 Mon Sep 17 00:00:00 2001 From: Nathan Ridge Date: Sat, 17 Dec 2016 02:16:41 -0500 Subject: [PATCH] Bug 508254 - Gracefully handle ProblemBinding arising during instantiation of EvalConstructor Change-Id: Ib5c5ce10e32cb0e7b42ccf0283709295da311931 --- .../index/tests/IndexMultiFileTest.java | 23 +++++++++++++++++++ .../parser/cpp/semantics/EvalConstructor.java | 6 ++++- 2 files changed, 28 insertions(+), 1 deletion(-) diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/index/tests/IndexMultiFileTest.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/index/tests/IndexMultiFileTest.java index 1a61d1ed56b..dbf8ad5df66 100644 --- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/index/tests/IndexMultiFileTest.java +++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/index/tests/IndexMultiFileTest.java @@ -187,4 +187,27 @@ public class IndexMultiFileTest extends IndexBindingResolutionTestBase { public void testClassTemplatePartialSpecialization_470726() throws Exception { checkBindings(); } + + // test.h + // template + // struct base {}; + // + // template + // struct derived : private base { + // constexpr derived() : base() {} + // }; + + // test1.cpp + // #include "test.h" + + // test2.cpp * + // template + // struct base {}; + // + // static derived<> waldo; + public void testProblemBindingInMemInitList_508254() throws Exception { + // This code is invalid, so we don't checkBindings(). + // If the test gets this far (doesn't throw in setup() during indexing), it passes. + } + } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/EvalConstructor.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/EvalConstructor.java index 553fe9ef0dd..0ec99d8d803 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/EvalConstructor.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/EvalConstructor.java @@ -134,7 +134,11 @@ public final class EvalConstructor extends CPPDependentEvaluation { @Override public ICPPEvaluation computeForFunctionCall(ActivationRecord callSiteRecord, ConstexprEvaluationContext context) { - final ICPPClassType classType = (ICPPClassType) SemanticUtil.getNestedType(fType, TDEF | REF | CVTYPE); + final IType unwrappedType = SemanticUtil.getNestedType(fType, TDEF | REF | CVTYPE); + if (!(unwrappedType instanceof ICPPClassType)) { + return this; + } + final ICPPClassType classType = (ICPPClassType) unwrappedType; final CompositeValue compositeValue = CompositeValue.create(classType); ICPPEvaluation[] argList = evaluateArguments(fArguments, callSiteRecord, context); EvalFixed constructedObject = new EvalFixed(fType, ValueCategory.PRVALUE, compositeValue);