mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-07-31 21:05:37 +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:
parent
1b15d0bdc3
commit
0071f546d1
3 changed files with 37 additions and 1 deletions
|
@ -8122,4 +8122,29 @@ public class AST2TemplateTests extends AST2TestBase {
|
||||||
public void testMemberOfPartialSpecialization_416788() throws Exception {
|
public void testMemberOfPartialSpecialization_416788() throws Exception {
|
||||||
parseAndCheckBindings();
|
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();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -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
|
* All rights reserved. This program and the accompanying materials
|
||||||
* are made available under the terms of the Eclipse Public License v1.0
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
* which accompanies this distribution, and is available at
|
* which accompanies this distribution, and is available at
|
||||||
|
@ -7,6 +7,7 @@
|
||||||
*
|
*
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* Nathan Ridge - Initial API and implementation
|
* Nathan Ridge - Initial API and implementation
|
||||||
|
* Marc-Andre Laperle (Ericsson)
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.cdt.internal.core.dom.parser.cpp;
|
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.ICPPEnumeration;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPEnumerationSpecialization;
|
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.ICPPScope;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPSpecialization;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateParameterMap;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateParameterMap;
|
||||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.SemanticUtil;
|
import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.SemanticUtil;
|
||||||
|
|
||||||
|
@ -93,6 +95,10 @@ public class CPPEnumerationSpecialization extends CPPSpecialization implements I
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public IEnumerator specializeEnumerator(IEnumerator enumerator) {
|
public IEnumerator specializeEnumerator(IEnumerator enumerator) {
|
||||||
|
if (enumerator instanceof ICPPSpecialization && ((ICPPSpecialization) enumerator).getOwner() == this) {
|
||||||
|
return enumerator;
|
||||||
|
}
|
||||||
|
|
||||||
// The specialized enumerators are already computed, just need
|
// The specialized enumerators are already computed, just need
|
||||||
// to look up the right one.
|
// to look up the right one.
|
||||||
IEnumerator[] unspecializedEnumerators = getSpecializedBinding().getEnumerators();
|
IEnumerator[] unspecializedEnumerators = getSpecializedBinding().getEnumerators();
|
||||||
|
|
|
@ -7,6 +7,7 @@
|
||||||
*
|
*
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* Sergey Prigogin (Google) - initial API and implementation
|
* Sergey Prigogin (Google) - initial API and implementation
|
||||||
|
* Marc-Andre Laperle (Ericsson)
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.cdt.internal.core.pdom.dom.cpp;
|
package org.eclipse.cdt.internal.core.pdom.dom.cpp;
|
||||||
|
|
||||||
|
@ -245,6 +246,10 @@ class PDOMCPPEnumerationSpecialization extends PDOMCPPSpecialization
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public IEnumerator specializeEnumerator(IEnumerator enumerator) {
|
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.
|
// The specialized enumerators are already computed, just need to look up the right one.
|
||||||
IEnumerator[] unspecializedEnumerators = getSpecializedBinding().getEnumerators();
|
IEnumerator[] unspecializedEnumerators = getSpecializedBinding().getEnumerators();
|
||||||
for (int i = 0; i < unspecializedEnumerators.length; ++i) {
|
for (int i = 0; i < unspecializedEnumerators.length; ++i) {
|
||||||
|
|
Loading…
Add table
Reference in a new issue