diff options
author | Marc-Andre Laperle | 2013-07-14 20:38:17 +0000 |
---|---|---|
committer | Marc-Andre Laperle | 2013-07-17 20:28:43 +0000 |
commit | 508bc8720d528a51ddb25be4133f0fc0bf896e24 (patch) | |
tree | 994fee5b7ddb9566e52cb220d21359159a885e50 | |
parent | fe67ac9631bdd0ce07e163af7ac2109ab814a1c6 (diff) | |
download | org.eclipse.cdt-508bc8720d528a51ddb25be4133f0fc0bf896e24.tar.gz org.eclipse.cdt-508bc8720d528a51ddb25be4133f0fc0bf896e24.tar.xz org.eclipse.cdt-508bc8720d528a51ddb25be4133f0fc0bf896e24.zip |
Bug 412555 - ClassCastException in EvalID.instantiate
Change-Id: I38ecb4f07834e7a2466ab42e048f32bfc1fccb50
Signed-off-by: Marc-Andre Laperle <marc-andre.laperle@ericsson.com>
Reviewed-on: https://git.eclipse.org/r/14540
Reviewed-by: Sergey Prigogin <eclipse.sprigogin@gmail.com>
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<bool B, class T = void> + // struct enable_if_c { + // typedef T type; + // }; + // + // template<class T> + // struct enable_if_c<false, T> { + // }; + // + // template<class Cond, class T = void> + // struct enable_if: public enable_if_c<Cond::value, T> { + // }; + // + // template<typename T, typename = void> + // struct some_trait { + // static const bool value = true; + // }; + // + // template<typename T> + // struct some_trait<T, typename enable_if_c<T::some_trait_value>::type> { + // static const bool value = true; + // }; + // + // template<typename T> + // inline typename enable_if_c<some_trait<T>::value>::type foo() { + // } + // + // typedef int myInt; + // int main() { + // foo<myInt>(); + // } + 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) |