mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-06-08 02:06:01 +02:00
Bug 487698 - Use fully simplified type during deduction (while still preserving typedefs in the result)
Change-Id: Ic2b7fbe62317660af218a722d2a113f5ab0d9b4b
This commit is contained in:
parent
98bbc1597e
commit
d5e518217a
2 changed files with 27 additions and 2 deletions
|
@ -7854,6 +7854,30 @@ public class AST2TemplateTests extends AST2TestBase {
|
||||||
parseAndCheckBindings();
|
parseAndCheckBindings();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// template<typename T>
|
||||||
|
// struct term_traits;
|
||||||
|
//
|
||||||
|
// template<typename T>
|
||||||
|
// struct term_traits<T const &> {
|
||||||
|
// typedef T value_type;
|
||||||
|
// };
|
||||||
|
//
|
||||||
|
// template<typename T, int N>
|
||||||
|
// struct term_traits<T const (&)[N]> {
|
||||||
|
// typedef T value_type[N];
|
||||||
|
// };
|
||||||
|
//
|
||||||
|
// using T = const char(&)[4];
|
||||||
|
// using ActualType = term_traits<T const &>::value_type;
|
||||||
|
//
|
||||||
|
// using ExpectedType = char[4];
|
||||||
|
public void testQualifierTypeThatCollapsesAfterTypedefSubstitution_487698() throws Exception {
|
||||||
|
BindingAssertionHelper helper = getAssertionHelper();
|
||||||
|
ITypedef actualType = helper.assertNonProblem("ActualType");
|
||||||
|
ITypedef expectedType = helper.assertNonProblem("ExpectedType");
|
||||||
|
assertSameType(actualType, expectedType);
|
||||||
|
}
|
||||||
|
|
||||||
// template <typename>
|
// template <typename>
|
||||||
// struct meta {
|
// struct meta {
|
||||||
// static const bool value = 1;
|
// static const bool value = 1;
|
||||||
|
|
|
@ -840,8 +840,9 @@ public class TemplateArgumentDeduction {
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean fromType(IType p, IType a, boolean allowCVQConversion, IASTNode point) throws DOMException {
|
private boolean fromType(IType p, IType a, boolean allowCVQConversion, IASTNode point) throws DOMException {
|
||||||
|
IType originalArgType = a;
|
||||||
|
a = SemanticUtil.getSimplifiedType(a);
|
||||||
while (p != null) {
|
while (p != null) {
|
||||||
IType argumentTypeBeforeTypedefResolution = a;
|
|
||||||
while (a instanceof ITypedef)
|
while (a instanceof ITypedef)
|
||||||
a = ((ITypedef) a).getType();
|
a = ((ITypedef) a).getType();
|
||||||
while (p instanceof ITypedef)
|
while (p instanceof ITypedef)
|
||||||
|
@ -945,7 +946,7 @@ public class TemplateArgumentDeduction {
|
||||||
if (a == null)
|
if (a == null)
|
||||||
return false;
|
return false;
|
||||||
return deduce(((ICPPTemplateParameter) p).getParameterID(),
|
return deduce(((ICPPTemplateParameter) p).getParameterID(),
|
||||||
new CPPTemplateTypeArgument(a, argumentTypeBeforeTypedefResolution));
|
new CPPTemplateTypeArgument(a, ExpressionTypes.restoreTypedefs(a, originalArgType)));
|
||||||
} else if (p instanceof ICPPTemplateInstance) {
|
} else if (p instanceof ICPPTemplateInstance) {
|
||||||
if (!(a instanceof ICPPTemplateInstance))
|
if (!(a instanceof ICPPTemplateInstance))
|
||||||
return false;
|
return false;
|
||||||
|
|
Loading…
Add table
Reference in a new issue