1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-07-23 17:05:26 +02:00

Bug 402409 - Dependent expressions and auto type resolution

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>
This commit is contained in:
Nathan Ridge 2013-03-05 04:28:41 -05:00 committed by Sergey Prigogin
parent 23d72af75b
commit 3df391336b
2 changed files with 30 additions and 0 deletions

View file

@ -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...);

View file

@ -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());
}