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 d9635920e35..c7ca12fdcf9 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 @@ -10242,4 +10242,17 @@ public class AST2TemplateTests extends AST2TestBase { public void testOverloadingOnTypeOfNonTypeTemplateParameter_512932() throws Exception { parseAndCheckBindings(); } + + // template + // void waldo(T&); + // + // class A {}; + // typedef const A CA; + // + // int main() { + // waldo(CA()); + // } + public void testReferenceBinding_Regression_516284() throws Exception { + parseAndCheckBindings(); + } } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/EvalTypeId.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/EvalTypeId.java index 79c966a8e22..8d9cc05f756 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/EvalTypeId.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/EvalTypeId.java @@ -80,7 +80,7 @@ public class EvalTypeId extends CPPDependentEvaluation { throw new NullPointerException("arguments"); //$NON-NLS-1$ if (!CPPTemplates.isDependentType(type)) - type = SemanticUtil.getNestedType(type, TDEF | CVTYPE); + type = SemanticUtil.getNestedType(type, TDEF); fInputType= type; fArguments= arguments; fRepresentsNewExpression = forNewExpression; @@ -146,8 +146,9 @@ public class EvalTypeId extends CPPDependentEvaluation { if (fRepresentsNewExpression) return IntegralValue.UNKNOWN; - if (fInputType instanceof ICPPClassType) { - ICPPClassType classType = (ICPPClassType) fInputType; + IType inputType = SemanticUtil.getNestedType(fInputType, CVTYPE); + if (inputType instanceof ICPPClassType) { + ICPPClassType classType = (ICPPClassType) inputType; IBinding ctor = getConstructor(point); if (EvalUtil.isCompilerGeneratedCtor(ctor)) { return CompositeValue.create(classType, point); @@ -164,8 +165,8 @@ public class EvalTypeId extends CPPDependentEvaluation { } } if (fArguments.length == 0 || isEmptyInitializerList(fArguments)) { - if (fInputType instanceof ICPPBasicType) { - switch (((ICPPBasicType) fInputType).getKind()) { + if (inputType instanceof ICPPBasicType) { + switch (((ICPPBasicType) inputType).getKind()) { case eInt: case eInt128: case eDouble: @@ -254,7 +255,7 @@ public class EvalTypeId extends CPPDependentEvaluation { if (isTypeDependent()) return null; - IType simplifiedType = SemanticUtil.getNestedType(fInputType, SemanticUtil.TDEF); + IType simplifiedType = SemanticUtil.getNestedType(fInputType, TDEF | CVTYPE); if (simplifiedType instanceof ICPPClassType) { ICPPClassType classType = (ICPPClassType) simplifiedType; ICPPEvaluation[] arguments = fArguments;