diff options
3 files changed, 38 insertions, 7 deletions
diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2TemplateTests.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2TemplateTests.java index 995369058a8..98f06da5e73 100644 --- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2TemplateTests.java +++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2TemplateTests.java @@ -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_); + } } diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2TestBase.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2TestBase.java index 6dd95c5dce1..fa6c2a07227 100644 --- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2TestBase.java +++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2TestBase.java @@ -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) { diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/CPPSemantics.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/CPPSemantics.java index d9154a68c6a..6dd5c3bab52 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/CPPSemantics.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/CPPSemantics.java @@ -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 |