1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-07-25 18:05:33 +02:00

Bug 418770 - NPE in EvalBinding.getBinding involving specialized enum

Change-Id: Ibbf3c1dd40e3e33a111c5d3a433277a1349dd445
Signed-off-by: Marc-Andre Laperle <marc-andre.laperle@ericsson.com>
Reviewed-on: https://git.eclipse.org/r/19031
Tested-by: Hudson CI
Reviewed-by: Sergey Prigogin <eclipse.sprigogin@gmail.com>
This commit is contained in:
Marc-Andre Laperle 2013-11-28 01:10:29 -05:00
parent 1b15d0bdc3
commit 0071f546d1
3 changed files with 37 additions and 1 deletions

View file

@ -8122,4 +8122,29 @@ public class AST2TemplateTests extends AST2TestBase {
public void testMemberOfPartialSpecialization_416788() throws Exception {
parseAndCheckBindings();
}
// template<bool>
// struct enable_if {
// typedef void type;
// };
//
// template<int I>
// struct MyClass {
// enum {
// K
// };
//
// template<int J>
// void method(typename enable_if<J == K>::type* = 0) {
// }
// };
//
// int main() {
// MyClass<0> myObject;
// myObject.method<0>();
// return 0;
// }
public void testSpecializedEnumerator_418770() throws Exception {
parseAndCheckBindings();
}
}

View file

@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2013 Nathan Ridge.
* Copyright (c) 2013 Nathan Ridge 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
@ -7,6 +7,7 @@
*
* Contributors:
* Nathan Ridge - Initial API and implementation
* Marc-Andre Laperle (Ericsson)
*******************************************************************************/
package org.eclipse.cdt.internal.core.dom.parser.cpp;
@ -17,6 +18,7 @@ import org.eclipse.cdt.core.dom.ast.ITypedef;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPEnumeration;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPEnumerationSpecialization;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPScope;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPSpecialization;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateParameterMap;
import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.SemanticUtil;
@ -93,6 +95,10 @@ public class CPPEnumerationSpecialization extends CPPSpecialization implements I
@Override
public IEnumerator specializeEnumerator(IEnumerator enumerator) {
if (enumerator instanceof ICPPSpecialization && ((ICPPSpecialization) enumerator).getOwner() == this) {
return enumerator;
}
// The specialized enumerators are already computed, just need
// to look up the right one.
IEnumerator[] unspecializedEnumerators = getSpecializedBinding().getEnumerators();

View file

@ -7,6 +7,7 @@
*
* Contributors:
* Sergey Prigogin (Google) - initial API and implementation
* Marc-Andre Laperle (Ericsson)
*******************************************************************************/
package org.eclipse.cdt.internal.core.pdom.dom.cpp;
@ -245,6 +246,10 @@ class PDOMCPPEnumerationSpecialization extends PDOMCPPSpecialization
@Override
public IEnumerator specializeEnumerator(IEnumerator enumerator) {
if (enumerator instanceof ICPPSpecialization && ((ICPPSpecialization) enumerator).getOwner() == this) {
return enumerator;
}
// The specialized enumerators are already computed, just need to look up the right one.
IEnumerator[] unspecializedEnumerators = getSpecializedBinding().getEnumerators();
for (int i = 0; i < unspecializedEnumerators.length; ++i) {