summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNathan Ridge2013-03-10 19:52:09 (EDT)
committer Sergey Prigogin2013-03-11 14:08:57 (EDT)
commitc8e936ae119c12ed88dbdfb6a9913aa71225d899 (patch)
tree353b08560f2cfd5bb791bdd85d228f27cb57b61d
parent072b8512ea7ffded0f5feedab57b369f47faa8b4 (diff)
downloadorg.eclipse.cdt-c8e936ae119c12ed88dbdfb6a9913aa71225d899.zip
org.eclipse.cdt-c8e936ae119c12ed88dbdfb6a9913aa71225d899.tar.gz
org.eclipse.cdt-c8e936ae119c12ed88dbdfb6a9913aa71225d899.tar.bz2
Bug 402854 - Qualified name lookup finds name in enclosing scoperefs/changes/32/11032/3
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>
-rw-r--r--core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2TemplateTests.java30
-rw-r--r--core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2TestBase.java14
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/CPPSemantics.java1
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 9953690..98f06da 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 6dd95c5..fa6c2a0 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 d9154a6..6dd5c3b 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