summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNathan Ridge2013-03-05 04:28:41 (EST)
committer Sergey Prigogin2013-03-06 12:56:09 (EST)
commit3df391336b3fed78347aca82c2e345790fa8cc86 (patch)
tree01bb1c56c59eefdb891b0e58768cf3fc9e07b93f
parent23d72af75bc0cd2c2a6be5a2d44b77b9be091d39 (diff)
downloadorg.eclipse.cdt-3df391336b3fed78347aca82c2e345790fa8cc86.zip
org.eclipse.cdt-3df391336b3fed78347aca82c2e345790fa8cc86.tar.gz
org.eclipse.cdt-3df391336b3fed78347aca82c2e345790fa8cc86.tar.bz2
Bug 402409 - Dependent expressions and auto type resolutionrefs/changes/39/10839/2
Change-Id: I71c8f2237bf22ffd0d9e79b15dce8cd693556564 Reviewed-on: https://git.eclipse.org/r/10839 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.java21
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/EvalID.java9
2 files changed, 30 insertions, 0 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 c6e89ee..a95ce65 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,6 +42,7 @@ 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;
@@ -95,6 +96,7 @@ 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;
@@ -5874,6 +5876,25 @@ public class AST2TemplateTests extends AST2TestBase {
parseAndCheckBindings();
}
+ // struct vector {
+ // int* begin();
+ // };
+ //
+ // template<class Container>
+ // auto begin(Container cont) -> decltype(cont.begin());
+ //
+ // vector v;
+ // auto x = begin(v);
+ public void testResolvingAutoTypeWithDependentExpression_402409() throws Exception {
+ BindingAssertionHelper helper = new BindingAssertionHelper(getAboveComment(), true);
+ ICPPVariable x = helper.assertNonProblem("x", ICPPVariable.class);
+ IType xType = x.getType();
+ assertInstance(xType, CPPPointerType.class);
+ IType xTypeInner = ((CPPPointerType) xType).getType();
+ assertInstance(xTypeInner, ICPPBasicType.class);
+ assertEquals(Kind.eInt, ((ICPPBasicType) xTypeInner).getKind());
+ }
+
// void foo(int, int);
// template <typename... Args> void bar(Args... args) {
// foo(1,2,args...);
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/EvalID.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/EvalID.java
index bf6318b..8471426 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/EvalID.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/EvalID.java
@@ -324,6 +324,15 @@ public class EvalID extends CPPDependentEvaluation {
if (eval != null)
return eval;
}
+
+ if (fieldOwner != null && !fieldOwner.isTypeDependent()) {
+ IType fieldOwnerType = fieldOwner.getTypeOrFunctionSet(point);
+ if (fieldOwnerType instanceof ICPPClassType) {
+ ICPPEvaluation eval = resolveName((ICPPClassType) fieldOwnerType, templateArgs, point);
+ if (eval != null)
+ return eval;
+ }
+ }
return new EvalID(fieldOwner, nameOwner, fName, fAddressOf, fQualified, templateArgs, getTemplateDefinition());
}