mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-07-28 11:25:35 +02:00
Bug 525982 - Have TypeOfUnknownMember implement ICPPUnknownBinding
This ensures that name resolution can proceed when a TypeOfUnknownMember appears on the left hand side of a scope resolution operator. Change-Id: I2dfc22eb474b8a2f776eda09ce90c91462d7fe5b
This commit is contained in:
parent
a80f50a725
commit
20cebd8f6f
3 changed files with 26 additions and 19 deletions
|
@ -9723,6 +9723,15 @@ public class AST2TemplateTests extends AST2CPPTestBase {
|
||||||
IVariable var2 = helper.assertNonProblem("var2");
|
IVariable var2 = helper.assertNonProblem("var2");
|
||||||
assertSameType(var1.getType(), var2.getType());
|
assertSameType(var1.getType(), var2.getType());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// template <typename T>
|
||||||
|
// void foo() {
|
||||||
|
// typedef decltype(T::member) C;
|
||||||
|
// typedef decltype(C::member) D;
|
||||||
|
// }
|
||||||
|
public void testScopeOfUnkownMemberType_525982() throws Exception {
|
||||||
|
parseAndCheckBindings();
|
||||||
|
}
|
||||||
|
|
||||||
// template <bool>
|
// template <bool>
|
||||||
// struct integral_constant {
|
// struct integral_constant {
|
||||||
|
|
|
@ -1533,6 +1533,16 @@ public class CPPTemplates {
|
||||||
return instantiated.getType();
|
return instantiated.getType();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
} else if (type instanceof TypeOfUnknownMember) {
|
||||||
|
IBinding binding = resolveUnknown(((TypeOfUnknownMember) type).getUnknownMember(), context);
|
||||||
|
if (binding instanceof IType) {
|
||||||
|
return (IType) binding;
|
||||||
|
} else if (binding instanceof IVariable) {
|
||||||
|
return ((IVariable) binding).getType();
|
||||||
|
} else if (binding instanceof IFunction) {
|
||||||
|
return ((IFunction) binding).getType();
|
||||||
|
}
|
||||||
|
return type;
|
||||||
} else {
|
} else {
|
||||||
IBinding binding= resolveUnknown((ICPPUnknownBinding) type, context);
|
IBinding binding= resolveUnknown((ICPPUnknownBinding) type, context);
|
||||||
if (binding instanceof IType)
|
if (binding instanceof IType)
|
||||||
|
@ -1542,18 +1552,6 @@ public class CPPTemplates {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (type instanceof TypeOfUnknownMember) {
|
|
||||||
IBinding binding = resolveUnknown(((TypeOfUnknownMember) type).getUnknownMember(), context);
|
|
||||||
if (binding instanceof IType) {
|
|
||||||
return (IType) binding;
|
|
||||||
} else if (binding instanceof IVariable) {
|
|
||||||
return ((IVariable) binding).getType();
|
|
||||||
} else if (binding instanceof IFunction) {
|
|
||||||
return ((IFunction) binding).getType();
|
|
||||||
}
|
|
||||||
return type;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (context.getContextTypeSpecialization() != null && type instanceof IBinding) {
|
if (context.getContextTypeSpecialization() != null && type instanceof IBinding) {
|
||||||
IType unwound= getNestedType(type, TDEF);
|
IType unwound= getNestedType(type, TDEF);
|
||||||
ICPPClassSpecialization withinClass = context.getContextClassSpecialization();
|
ICPPClassSpecialization withinClass = context.getContextClassSpecialization();
|
||||||
|
|
|
@ -11,9 +11,11 @@
|
||||||
package org.eclipse.cdt.internal.core.dom.parser.cpp.semantics;
|
package org.eclipse.cdt.internal.core.dom.parser.cpp.semantics;
|
||||||
|
|
||||||
import org.eclipse.cdt.core.CCorePlugin;
|
import org.eclipse.cdt.core.CCorePlugin;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.IBinding;
|
||||||
import org.eclipse.cdt.core.dom.ast.IType;
|
import org.eclipse.cdt.core.dom.ast.IType;
|
||||||
import org.eclipse.cdt.internal.core.dom.parser.ISerializableType;
|
import org.eclipse.cdt.internal.core.dom.parser.ISerializableType;
|
||||||
import org.eclipse.cdt.internal.core.dom.parser.ITypeMarshalBuffer;
|
import org.eclipse.cdt.internal.core.dom.parser.ITypeMarshalBuffer;
|
||||||
|
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPUnknownBinding;
|
||||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPUnknownMember;
|
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPUnknownMember;
|
||||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPUnknownType;
|
import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPUnknownType;
|
||||||
import org.eclipse.cdt.internal.core.index.IIndexFragment;
|
import org.eclipse.cdt.internal.core.index.IIndexFragment;
|
||||||
|
@ -22,10 +24,11 @@ import org.eclipse.core.runtime.CoreException;
|
||||||
/**
|
/**
|
||||||
* Represents the type of an unknown member.
|
* Represents the type of an unknown member.
|
||||||
*/
|
*/
|
||||||
public class TypeOfUnknownMember implements ICPPUnknownType, ISerializableType {
|
public class TypeOfUnknownMember extends CPPUnknownBinding implements ICPPUnknownType, ISerializableType {
|
||||||
private final CPPUnknownMember fMember;
|
private final CPPUnknownMember fMember;
|
||||||
|
|
||||||
public TypeOfUnknownMember(CPPUnknownMember member) {
|
public TypeOfUnknownMember(CPPUnknownMember member) {
|
||||||
|
super(("decltype(" + member.getName() + ")").toCharArray()); //$NON-NLS-1$ //$NON-NLS-2$
|
||||||
fMember = member;
|
fMember = member;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -53,11 +56,8 @@ public class TypeOfUnknownMember implements ICPPUnknownType, ISerializableType {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Object clone() {
|
public IBinding getOwner() {
|
||||||
try {
|
// We won't know until instantiation.
|
||||||
return super.clone();
|
return null;
|
||||||
} catch (CloneNotSupportedException e) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue