diff options
3 files changed, 50 insertions, 19 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 f0055d630f0..a8cedf674bc 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 @@ -8039,4 +8039,25 @@ public class AST2TemplateTests extends AST2TestBase { public void testOutOfLineMethodOfPartialSpecialization_401152() throws Exception { parseAndCheckBindings(); } + + // template <typename T> + // T foo(T); + // + // template <typename T> + // struct U { + // typedef typename decltype(foo(T()))::type type; + // }; + // + // struct S { + // typedef int type; + // }; + // + // int main() { + // U<S>::type x; + // } + public void testDependentDecltypeInNameQualifier_415198() throws Exception { + BindingAssertionHelper helper = getAssertionHelper(); + helper.assertNonProblem("decltype(foo(T()))::type"); + assertSameType((ITypedef) helper.assertNonProblem("U<S>::type"), CommonTypes.int_); + } } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/CPPTemplates.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/CPPTemplates.java index 1a176a0b525..e5cf9c41887 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/CPPTemplates.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/CPPTemplates.java @@ -1266,11 +1266,18 @@ public class CPPTemplates { } if (type instanceof ICPPUnknownBinding) { - IBinding binding= resolveUnknown((ICPPUnknownBinding) type, tpMap, packOffset, within, point); - if (binding instanceof IType) - return (IType) binding; - - return type; + if (type instanceof TypeOfDependentExpression) { + ICPPEvaluation eval = ((TypeOfDependentExpression) type).getEvaluation(); + ICPPEvaluation instantiated = eval.instantiate(tpMap, packOffset, within, Value.MAX_RECURSION_DEPTH, point); + if (instantiated != eval) + return instantiated.getTypeOrFunctionSet(point); + } else { + IBinding binding= resolveUnknown((ICPPUnknownBinding) type, tpMap, packOffset, within, point); + if (binding instanceof IType) + return (IType) binding; + + return type; + } } if (within != null && type instanceof IBinding) { @@ -1348,13 +1355,6 @@ public class CPPTemplates { return typeContainer; } - if (type instanceof TypeOfDependentExpression) { - ICPPEvaluation eval = ((TypeOfDependentExpression) type).getEvaluation(); - ICPPEvaluation instantiated = eval.instantiate(tpMap, packOffset, within, Value.MAX_RECURSION_DEPTH, point); - if (instantiated != eval) - return instantiated.getTypeOrFunctionSet(point); - } - return type; } catch (DOMException e) { return e.getProblem(); @@ -2646,6 +2646,11 @@ public class CPPTemplates { if (type instanceof IBinding) return (IBinding) type; } + if (unknown instanceof TypeOfDependentExpression) { + IType type= instantiateType((IType) unknown, tpMap, packOffset, within, point); + if (type instanceof IBinding) + return (IBinding) type; + } return unknown; } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/TypeOfDependentExpression.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/TypeOfDependentExpression.java index c1bccc5280b..fda78316412 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/TypeOfDependentExpression.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/TypeOfDependentExpression.java @@ -12,11 +12,13 @@ package org.eclipse.cdt.internal.core.dom.parser.cpp.semantics; import org.eclipse.cdt.core.CCorePlugin; +import org.eclipse.cdt.core.dom.ast.IBinding; import org.eclipse.cdt.core.dom.ast.IType; import org.eclipse.cdt.internal.core.dom.parser.ISerializableEvaluation; import org.eclipse.cdt.internal.core.dom.parser.ISerializableType; import org.eclipse.cdt.internal.core.dom.parser.ITypeMarshalBuffer; import org.eclipse.cdt.internal.core.dom.parser.ProblemType; +import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPUnknownBinding; import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPEvaluation; import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPUnknownType; import org.eclipse.core.runtime.CoreException; @@ -24,10 +26,11 @@ import org.eclipse.core.runtime.CoreException; /** * Represents the type of a dependent expression. */ -public class TypeOfDependentExpression implements ICPPUnknownType, ISerializableType { +public class TypeOfDependentExpression extends CPPUnknownBinding implements ICPPUnknownType, ISerializableType { private final ICPPEvaluation fEvaluation; public TypeOfDependentExpression(ICPPEvaluation evaluation) { + super(evaluation.getSignature()); fEvaluation= evaluation; } @@ -42,12 +45,8 @@ public class TypeOfDependentExpression implements ICPPUnknownType, ISerializable } @Override - public Object clone() { - try { - return super.clone(); - } catch (CloneNotSupportedException e) { - return null; - } + public TypeOfDependentExpression clone() { + return (TypeOfDependentExpression) super.clone(); } public char[] getSignature() { @@ -73,4 +72,10 @@ public class TypeOfDependentExpression implements ICPPUnknownType, ISerializable return new TypeOfDependentExpression((ICPPEvaluation) eval); return ProblemType.UNKNOWN_FOR_EXPRESSION; } + + @Override + public IBinding getOwner() { + // We won't know until instantiation. + return null; + } } |