1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-04-23 22:52:11 +02:00

Bug 421823 - When a base class lookup runs into a deferred instance,

disambiguate between a method and a field

Change-Id: I03cf9aa55d79c6b9f2a96bf3cace36e706bfecfb
Signed-off-by: Nathan Ridge <zeratul976@hotmail.com>
This commit is contained in:
Nathan Ridge 2015-07-09 02:09:38 -04:00 committed by Gerrit Code Review @ Eclipse.org
parent a9a454f256
commit 6ed25565a6
3 changed files with 25 additions and 1 deletions

View file

@ -8816,4 +8816,22 @@ public class AST2TemplateTests extends AST2TestBase {
public void testAmbiguityResolutionOrder_462348b() throws Exception { public void testAmbiguityResolutionOrder_462348b() throws Exception {
parseAndCheckBindings(); parseAndCheckBindings();
} }
// template <typename>
// struct Base {
// template <typename>
// void method(int);
// };
//
// template <typename V>
// struct C : Base<V> {
// typedef int WALDO;
//
// C() {
// this->template method<WALDO>(0);
// }
// };
public void testRegression_421823() throws Exception {
parseAndCheckBindings();
}
} }

View file

@ -217,6 +217,7 @@ import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPScope;
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPTemplateNonTypeArgument; import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPTemplateNonTypeArgument;
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPTemplateParameterMap; import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPTemplateParameterMap;
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPUnknownConstructor; import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPUnknownConstructor;
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPUnknownField;
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPUnknownMemberClass; import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPUnknownMemberClass;
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPUnknownMethod; import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPUnknownMethod;
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPUsingDeclaration; import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPUsingDeclaration;
@ -497,8 +498,10 @@ public class CPPSemantics {
if (binding == null && data.skippedScope != null) { if (binding == null && data.skippedScope != null) {
if (namePropertyInParent == IASTNamedTypeSpecifier.NAME) { if (namePropertyInParent == IASTNamedTypeSpecifier.NAME) {
binding= new CPPUnknownMemberClass(data.skippedScope, name.getSimpleID()); binding= new CPPUnknownMemberClass(data.skippedScope, name.getSimpleID());
} else { } else if (data.isFunctionCall()) {
binding= new CPPUnknownMethod(data.skippedScope, name.getSimpleID()); binding= new CPPUnknownMethod(data.skippedScope, name.getSimpleID());
} else {
binding= new CPPUnknownField(data.skippedScope, name.getSimpleID());
} }
} }

View file

@ -186,6 +186,9 @@ public class LookupData extends ScopeLookupData {
fDeclarator= (IASTDeclarator) nameParent; fDeclarator= (IASTDeclarator) nameParent;
} else if (nameParent instanceof IASTFieldReference) { } else if (nameParent instanceof IASTFieldReference) {
qualified= true; qualified= true;
if (nameParent.getPropertyInParent() == IASTFunctionCallExpression.FUNCTION_NAME) {
fFunctionCall= true;
}
} else if (nameParent instanceof IASTIdExpression) { } else if (nameParent instanceof IASTIdExpression) {
if (nameParent.getPropertyInParent() == IASTFunctionCallExpression.FUNCTION_NAME) { if (nameParent.getPropertyInParent() == IASTFunctionCallExpression.FUNCTION_NAME) {
fFunctionCall= true; fFunctionCall= true;