mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-23 06:32:10 +02:00
ClassCastException using template template parameters, bug 279619
This commit is contained in:
parent
5bbbd7720b
commit
de93e043c2
4 changed files with 13 additions and 7 deletions
|
@ -4051,4 +4051,12 @@ public class AST2TemplateTests extends AST2BaseTest {
|
|||
final String code = getAboveComment();
|
||||
parseAndCheckBindings(code, ParserLanguage.CPP);
|
||||
}
|
||||
|
||||
// template<unsigned int> struct ST{};
|
||||
// template<template<unsigned int> class T> class CT {};
|
||||
// typedef CT<ST> TDef;
|
||||
public void testUsingTemplateTemplateParameter_279619() throws Exception {
|
||||
final String code = getAboveComment();
|
||||
parseAndCheckBindings(code, ParserLanguage.CPP);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -70,13 +70,11 @@ public class CPPTemplateTemplateParameter extends CPPTemplateParameter implement
|
|||
if (templateParameters == null) {
|
||||
ICPPASTTemplatedTypeTemplateParameter template = (ICPPASTTemplatedTypeTemplateParameter) getPrimaryDeclaration().getParent();
|
||||
ICPPASTTemplateParameter[] params = template.getTemplateParameters();
|
||||
ICPPTemplateParameter p = null;
|
||||
ICPPTemplateParameter[] result = null;
|
||||
for (ICPPASTTemplateParameter param : params) {
|
||||
IBinding binding = CPPTemplates.getTemplateParameterName(param).resolveBinding();
|
||||
p= (ICPPTemplateParameter) binding;
|
||||
if (p != null) {
|
||||
result = (ICPPTemplateParameter[]) ArrayUtil.append(ICPPTemplateParameter.class, result, p);
|
||||
if (binding instanceof ICPPTemplateParameter) {
|
||||
result = (ICPPTemplateParameter[]) ArrayUtil.append(ICPPTemplateParameter.class, result, binding);
|
||||
}
|
||||
}
|
||||
templateParameters = (ICPPTemplateParameter[]) ArrayUtil.trim(ICPPTemplateParameter.class, result);
|
||||
|
|
|
@ -1981,8 +1981,8 @@ public class CPPTemplates {
|
|||
ab= aParam instanceof ICPPTemplateNonTypeParameter;
|
||||
if (pb != ab)
|
||||
return null;
|
||||
assert pParam instanceof ICPPTemplateTemplateParameter; // no other choice left
|
||||
assert aParam instanceof ICPPTemplateTemplateParameter; // no other choice left
|
||||
assert pb || pParam instanceof ICPPTemplateTemplateParameter; // no other choice left
|
||||
assert ab || aParam instanceof ICPPTemplateTemplateParameter; // no other choice left
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -526,7 +526,7 @@ public class CPPVisitor extends ASTQueries {
|
|||
|
||||
// function type for non-type template parameter
|
||||
ASTNodeProperty prop = parent.getPropertyInParent();
|
||||
if (prop == ICPPASTTemplateDeclaration.PARAMETER) {
|
||||
if (prop == ICPPASTTemplateDeclaration.PARAMETER || prop == ICPPASTTemplatedTypeTemplateParameter.PARAMETER) {
|
||||
return CPPTemplates.createBinding((ICPPASTTemplateParameter) parent);
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue