From 508bc8720d528a51ddb25be4133f0fc0bf896e24 Mon Sep 17 00:00:00 2001 From: Marc-Andre Laperle Date: Sun, 14 Jul 2013 16:38:17 -0400 Subject: [PATCH] Bug 412555 - ClassCastException in EvalID.instantiate Change-Id: I38ecb4f07834e7a2466ab42e048f32bfc1fccb50 Signed-off-by: Marc-Andre Laperle Reviewed-on: https://git.eclipse.org/r/14540 Reviewed-by: Sergey Prigogin --- .../parser/tests/ast2/AST2TemplateTests.java | 36 +++++++++++++++++++ .../core/dom/parser/cpp/semantics/EvalID.java | 11 ++++-- 2 files changed, 44 insertions(+), 3 deletions(-) diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2TemplateTests.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2TemplateTests.java index 0f5915c42d7..e7810e8fb8e 100644 --- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2TemplateTests.java +++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2TemplateTests.java @@ -14,6 +14,7 @@ * Thomas Corbat (IFS) * Nathan Ridge * Danny Ferreira + * Marc-Andre Laperle (Ericsson) *******************************************************************************/ package org.eclipse.cdt.core.parser.tests.ast2; @@ -7955,4 +7956,39 @@ public class AST2TemplateTests extends AST2TestBase { ICPPField privateMemberVariable = bh.assertNonProblemOnFirstIdentifier("privateMemberVariable ="); assertVisibility(ICPPClassType.v_private, aTemplate.getVisibility(privateMemberVariable)); } + + // template + // struct enable_if_c { + // typedef T type; + // }; + // + // template + // struct enable_if_c { + // }; + // + // template + // struct enable_if: public enable_if_c { + // }; + // + // template + // struct some_trait { + // static const bool value = true; + // }; + // + // template + // struct some_trait::type> { + // static const bool value = true; + // }; + // + // template + // inline typename enable_if_c::value>::type foo() { + // } + // + // typedef int myInt; + // int main() { + // foo(); + // } + public void testInstantiationOfTypedef_412555() throws Exception { + parseAndCheckBindings(); + } } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/EvalID.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/EvalID.java index a069e4d17c0..306d17cac7c 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/EvalID.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/EvalID.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2012 Wind River Systems, Inc. and others. + * Copyright (c) 2012, 2013 Wind River Systems, Inc. and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -315,8 +315,13 @@ public class EvalID extends CPPDependentEvaluation { tpMap, packOffset, within, point); } else if (nameOwner instanceof IType) { IType type = CPPTemplates.instantiateType((IType) nameOwner, tpMap, packOffset, within, point); - if (type instanceof IBinding) - nameOwner = (IBinding) getNestedType(type, TDEF); + if (type instanceof IBinding) { + type = getNestedType(type, TDEF); + } + + if (!(type instanceof IBinding)) + return EvalFixed.INCOMPLETE; + nameOwner = (IBinding)type; } if (fieldOwner instanceof IProblemBinding || nameOwner instanceof IProblemBinding)