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
|
@ -7853,6 +7853,30 @@ public class AST2TemplateTests extends AST2TestBase {
|
|||
public void testPartialSpecializationForRefQualifiedFunctionType_485888() throws Exception {
|
||||
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>
|
||||
// struct meta {
|
||||
|
|
|
@ -840,8 +840,9 @@ public class TemplateArgumentDeduction {
|
|||
}
|
||||
|
||||
private boolean fromType(IType p, IType a, boolean allowCVQConversion, IASTNode point) throws DOMException {
|
||||
IType originalArgType = a;
|
||||
a = SemanticUtil.getSimplifiedType(a);
|
||||
while (p != null) {
|
||||
IType argumentTypeBeforeTypedefResolution = a;
|
||||
while (a instanceof ITypedef)
|
||||
a = ((ITypedef) a).getType();
|
||||
while (p instanceof ITypedef)
|
||||
|
@ -945,7 +946,7 @@ public class TemplateArgumentDeduction {
|
|||
if (a == null)
|
||||
return false;
|
||||
return deduce(((ICPPTemplateParameter) p).getParameterID(),
|
||||
new CPPTemplateTypeArgument(a, argumentTypeBeforeTypedefResolution));
|
||||
new CPPTemplateTypeArgument(a, ExpressionTypes.restoreTypedefs(a, originalArgType)));
|
||||
} else if (p instanceof ICPPTemplateInstance) {
|
||||
if (!(a instanceof ICPPTemplateInstance))
|
||||
return false;
|
||||
|
|
Loading…
Add table
Reference in a new issue