mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-08-08 08:45:44 +02:00
Bug 402854 - Qualified name lookup finds name in enclosing scope
Change-Id: Iebf9f427b3291a1af695936055daecb5d28e56f6 Reviewed-on: https://git.eclipse.org/r/11032 Reviewed-by: Sergey Prigogin <eclipse.sprigogin@gmail.com> IP-Clean: Sergey Prigogin <eclipse.sprigogin@gmail.com> Tested-by: Sergey Prigogin <eclipse.sprigogin@gmail.com>
This commit is contained in:
parent
072b8512ea
commit
c8e936ae11
3 changed files with 38 additions and 7 deletions
|
@ -42,7 +42,6 @@ import org.eclipse.cdt.core.dom.ast.IASTProblemStatement;
|
|||
import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTTypeId;
|
||||
import org.eclipse.cdt.core.dom.ast.IBasicType;
|
||||
import org.eclipse.cdt.core.dom.ast.IBasicType.Kind;
|
||||
import org.eclipse.cdt.core.dom.ast.IBinding;
|
||||
import org.eclipse.cdt.core.dom.ast.ICompositeType;
|
||||
import org.eclipse.cdt.core.dom.ast.IEnumerator;
|
||||
|
@ -96,7 +95,6 @@ import org.eclipse.cdt.core.parser.util.ObjectMap;
|
|||
import org.eclipse.cdt.internal.core.dom.parser.Value;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTNameBase;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPBasicType;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPPointerType;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPReferenceType;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.ClassTypeHelper;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPDeferredClassInstance;
|
||||
|
@ -5891,11 +5889,8 @@ public class AST2TemplateTests extends AST2TestBase {
|
|||
// auto x2 = begin2(v);
|
||||
public void testResolvingAutoTypeWithDependentExpression_402409a() throws Exception {
|
||||
BindingAssertionHelper helper = new BindingAssertionHelper(getAboveComment(), true);
|
||||
ICPPVariable x1 = helper.assertNonProblem("x1", ICPPVariable.class);
|
||||
ICPPVariable x2 = helper.assertNonProblem("x2", ICPPVariable.class);
|
||||
IType pointerToInt = new CPPPointerType(new CPPBasicType(Kind.eInt, 0));
|
||||
assertSameType(pointerToInt, x1.getType());
|
||||
assertSameType(pointerToInt, x2.getType());
|
||||
helper.assertVariableType("x1", CommonTypes.pointerToInt);
|
||||
helper.assertVariableType("x2", CommonTypes.pointerToInt);
|
||||
}
|
||||
|
||||
// struct vector {
|
||||
|
@ -7532,4 +7527,25 @@ public class AST2TemplateTests extends AST2TestBase {
|
|||
public void testUnqualifiedFunctionCallInTemplate_402498() throws Exception {
|
||||
parseAndCheckBindings();
|
||||
}
|
||||
|
||||
// template <typename>
|
||||
// struct no_type {};
|
||||
//
|
||||
// struct type {};
|
||||
//
|
||||
// template <typename T>
|
||||
// struct A {};
|
||||
//
|
||||
// template <typename T>
|
||||
// int foo(T);
|
||||
//
|
||||
// template <typename T>
|
||||
// typename no_type<T>::type const foo(A<T>);
|
||||
//
|
||||
// A<int> a;
|
||||
// auto b = foo(a);
|
||||
public void testQualifiedNameLookupInTemplate_402854() throws Exception {
|
||||
BindingAssertionHelper helper = new BindingAssertionHelper(getAboveComment(), true);
|
||||
helper.assertVariableType("b", CommonTypes.int_);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -57,6 +57,8 @@ import org.eclipse.cdt.core.dom.ast.IField;
|
|||
import org.eclipse.cdt.core.dom.ast.IFunctionType;
|
||||
import org.eclipse.cdt.core.dom.ast.IProblemBinding;
|
||||
import org.eclipse.cdt.core.dom.ast.IType;
|
||||
import org.eclipse.cdt.core.dom.ast.IBasicType.Kind;
|
||||
import org.eclipse.cdt.core.dom.ast.IVariable;
|
||||
import org.eclipse.cdt.core.dom.ast.c.ICASTTypeIdInitializerExpression;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTLinkageSpecification;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTNamespaceDefinition;
|
||||
|
@ -86,6 +88,8 @@ import org.eclipse.cdt.internal.core.dom.parser.ASTNode;
|
|||
import org.eclipse.cdt.internal.core.dom.parser.AbstractGNUSourceCodeParser;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.c.CVisitor;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.c.GNUCSourceParser;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPBasicType;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPPointerType;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.GNUCPPSourceParser;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPVisitor;
|
||||
import org.eclipse.cdt.internal.core.model.ASTStringUtil;
|
||||
|
@ -99,6 +103,11 @@ public class AST2TestBase extends BaseTestCase {
|
|||
public final static String TEST_CODE = "<testcode>";
|
||||
protected static final IParserLogService NULL_LOG = new NullLogService();
|
||||
protected static boolean sValidateCopy;
|
||||
|
||||
protected static class CommonTypes {
|
||||
public static IType int_ = new CPPBasicType(Kind.eInt, 0);
|
||||
public static IType pointerToInt = new CPPPointerType(int_);
|
||||
}
|
||||
|
||||
private static final ScannerInfo GNU_SCANNER_INFO = new ScannerInfo(getGnuMap());
|
||||
private static final ScannerInfo SCANNER_INFO = new ScannerInfo(getStdMap());
|
||||
|
@ -739,6 +748,11 @@ public class AST2TestBase extends BaseTestCase {
|
|||
assertTrue("ProblemBinding for name: " + name, !(binding instanceof IProblemBinding));
|
||||
return assertType(binding, cs);
|
||||
}
|
||||
|
||||
public void assertVariableType(String variableName, IType expectedType) {
|
||||
IVariable var = assertNonProblem(variableName, IVariable.class);
|
||||
assertSameType(expectedType, var.getType());
|
||||
}
|
||||
|
||||
public <T, U extends T> U assertType(T obj, Class... cs) {
|
||||
for (Class c : cs) {
|
||||
|
|
|
@ -3737,6 +3737,7 @@ public class CPPSemantics {
|
|||
LookupData data = new LookupData(unknownName, null, point);
|
||||
data.setIgnorePointOfDeclaration(true);
|
||||
data.typesOnly= unknown instanceof IType;
|
||||
data.qualified= true;
|
||||
|
||||
try {
|
||||
// 2: Lookup
|
||||
|
|
Loading…
Add table
Reference in a new issue