mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-06-08 18:26:01 +02:00
Bug 488456 - Handle unknown class instance that resolves to alias
template specialization Change-Id: I8e57ebffb8d93b22948a6822b566988d5b2f91ad
This commit is contained in:
parent
3a923c84ec
commit
1171bc168c
2 changed files with 25 additions and 1 deletions
|
@ -7289,6 +7289,22 @@ public class AST2TemplateTests extends AST2TestBase {
|
||||||
parseAndCheckBindings();
|
parseAndCheckBindings();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// template <class>
|
||||||
|
// struct Traits {
|
||||||
|
// template <class U>
|
||||||
|
// using rebind = U;
|
||||||
|
// };
|
||||||
|
// template <class T>
|
||||||
|
// struct Meta {
|
||||||
|
// typedef typename Traits<T>::template rebind<int> type;
|
||||||
|
// };
|
||||||
|
// typedef Meta<int>::type Waldo;
|
||||||
|
public void testNestedAliasTemplate_488456() throws Exception {
|
||||||
|
BindingAssertionHelper helper = getAssertionHelper();
|
||||||
|
ITypedef waldo = helper.assertNonProblem("Waldo");
|
||||||
|
assertSameType(waldo, CommonCPPTypes.int_);
|
||||||
|
}
|
||||||
|
|
||||||
// template<typename U>
|
// template<typename U>
|
||||||
// struct A {
|
// struct A {
|
||||||
// typedef U type1;
|
// typedef U type1;
|
||||||
|
|
|
@ -2904,7 +2904,9 @@ public class CPPTemplates {
|
||||||
IScope s = ((ICPPClassType) ot1).getCompositeScope();
|
IScope s = ((ICPPClassType) ot1).getCompositeScope();
|
||||||
if (s != null) {
|
if (s != null) {
|
||||||
result= CPPSemantics.resolveUnknownName(s, unknown, context.getPoint());
|
result= CPPSemantics.resolveUnknownName(s, unknown, context.getPoint());
|
||||||
if (unknown instanceof ICPPUnknownMemberClassInstance && result instanceof ICPPTemplateDefinition) {
|
if (unknown instanceof ICPPUnknownMemberClassInstance &&
|
||||||
|
(result instanceof ICPPTemplateDefinition ||
|
||||||
|
result instanceof ICPPAliasTemplateInstance)) {
|
||||||
ICPPTemplateArgument[] args1 = instantiateArguments(
|
ICPPTemplateArgument[] args1 = instantiateArguments(
|
||||||
((ICPPUnknownMemberClassInstance) unknown).getArguments(), context, false);
|
((ICPPUnknownMemberClassInstance) unknown).getArguments(), context, false);
|
||||||
if (result instanceof ICPPClassTemplate) {
|
if (result instanceof ICPPClassTemplate) {
|
||||||
|
@ -2912,6 +2914,12 @@ public class CPPTemplates {
|
||||||
} else if (result instanceof ICPPAliasTemplate) {
|
} else if (result instanceof ICPPAliasTemplate) {
|
||||||
result = instantiateAliasTemplate((ICPPAliasTemplate) result, args1,
|
result = instantiateAliasTemplate((ICPPAliasTemplate) result, args1,
|
||||||
context.getPoint());
|
context.getPoint());
|
||||||
|
} else if (result instanceof ICPPAliasTemplateInstance) {
|
||||||
|
// TODO(nathanridge): Remove this branch once we properly represent
|
||||||
|
// specializations of alias templates (which will then implement
|
||||||
|
// ICPPAliasTemplate and be caught by the previous branch).
|
||||||
|
result = instantiateAliasTemplateInstance((ICPPAliasTemplateInstance) result,
|
||||||
|
args1, context.getPoint());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue