mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-23 14:42:11 +02:00
Bug 284665.
This commit is contained in:
parent
1c5b36e9a9
commit
72d12ff557
3 changed files with 32 additions and 7 deletions
|
@ -33,6 +33,7 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPBasicType;
|
|||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPBinding;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassScope;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassType;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPConstructor;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPField;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPFunction;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPFunctionType;
|
||||
|
@ -1374,12 +1375,28 @@ public abstract class IndexCPPBindingResolutionTest extends IndexBindingResoluti
|
|||
|
||||
// class A {
|
||||
// class B;
|
||||
// void method();
|
||||
// };
|
||||
|
||||
// class A::B {};
|
||||
public void _testNestedClass_284665() throws Exception {
|
||||
ICPPClassType b = getBindingFromASTName("B {}", 1, ICPPClassType.class);
|
||||
assertFalse(b instanceof IIndexBinding);
|
||||
// class A::B {
|
||||
// B(int x);
|
||||
// static void m(int p);
|
||||
// };
|
||||
//
|
||||
// void A::method() {
|
||||
// new B(0);
|
||||
// B::m(0);
|
||||
// }
|
||||
public void testNestedClass_284665() throws Exception {
|
||||
ICPPClassType b0 = getBindingFromASTName("B {", 1, ICPPClassType.class);
|
||||
assertFalse(b0 instanceof IIndexBinding);
|
||||
ICPPConstructor b1 = getBindingFromASTName("B(int x)", 1, ICPPConstructor.class);
|
||||
assertFalse(b1 instanceof IIndexBinding);
|
||||
ICPPConstructor b2 = getBindingFromASTName("B(0)", 1, ICPPConstructor.class);
|
||||
assertFalse(b2 instanceof IIndexBinding);
|
||||
assertEquals(b1, b2);
|
||||
ICPPMethod b3 = getBindingFromASTName("m(0)", 1, ICPPMethod.class);
|
||||
assertFalse(b3 instanceof IIndexBinding);
|
||||
}
|
||||
|
||||
// class A {
|
||||
|
@ -1479,7 +1496,7 @@ public abstract class IndexCPPBindingResolutionTest extends IndexBindingResoluti
|
|||
}
|
||||
|
||||
/**
|
||||
* @param binding
|
||||
* @param type
|
||||
* @param cqn
|
||||
* @param qn may be null
|
||||
*/
|
||||
|
|
|
@ -352,7 +352,11 @@ public class CPPSemantics {
|
|||
|
||||
if (data.considerConstructors) {
|
||||
if (binding instanceof ICPPClassType) {
|
||||
if (binding instanceof IIndexBinding) {
|
||||
binding= data.tu.mapToAST((ICPPClassType) binding);
|
||||
}
|
||||
ICPPClassType cls= (ICPPClassType) binding;
|
||||
|
||||
try {
|
||||
if (data.astName instanceof ICPPASTTemplateId && cls instanceof ICPPClassTemplate) {
|
||||
if (data.tu != null) {
|
||||
|
|
|
@ -218,11 +218,15 @@ public class CPPVisitor extends ASTQueries {
|
|||
return binding;
|
||||
}
|
||||
} else {
|
||||
return binding;
|
||||
if (binding instanceof ICPPClassType && binding instanceof IIndexBinding && name.isDefinition()) {
|
||||
parent= parent.getParent(); // need to create an ast binding.
|
||||
} else {
|
||||
return binding;
|
||||
}
|
||||
}
|
||||
} else if (parent instanceof ICPPASTTemplateId) {
|
||||
final ICPPASTTemplateId id = (ICPPASTTemplateId) parent;
|
||||
if (CPPTemplates.isClassTemplate(id))
|
||||
if (CPPTemplates.isClassTemplate(id))
|
||||
return CPPSemantics.resolveBinding(name);
|
||||
|
||||
// function templates/instances/specializations must be resolved via the id
|
||||
|
|
Loading…
Add table
Reference in a new issue