1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-04-29 19:45:01 +02:00

Fixed bug 213861.

This commit is contained in:
Sergey Prigogin 2007-12-27 01:46:17 +00:00
parent 68f33f47f4
commit 5ff70f6e97
3 changed files with 95 additions and 84 deletions

View file

@ -87,7 +87,6 @@ public class AST2TemplateTests extends AST2BaseTest {
ICPPClassTemplate A = (ICPPClassTemplate) col.getName(1).resolveBinding();
ICPPTemplateParameter T = (ICPPTemplateParameter) col.getName(0).resolveBinding();
ICPPTemplateScope scope = (ICPPTemplateScope) T.getScope();
IScope s2 = A.getScope();
assertSame( scope, s2 );
@ -1205,7 +1204,7 @@ public class AST2TemplateTests extends AST2BaseTest {
assertTrue( x4 instanceof ICPPSpecialization );
assertEquals( ((ICPPSpecialization)x4).getSpecializedBinding(), x2 );
}
public void _testNestedTypeSpecializations() throws Exception {
public void testNestedTypeSpecializations() throws Exception {
StringBuffer buffer = new StringBuffer();
buffer.append("template <class T> class A { \n"); //$NON-NLS-1$
buffer.append(" typedef T _T; \n"); //$NON-NLS-1$

View file

@ -540,6 +540,22 @@ public class IndexCPPTemplateResolutionTest extends IndexBindingResolutionTestBa
assertEquals("C", ((ICPPClassType)om1.getAt(0)).getName());
}
// template<typename T>
// class C {
// public:
// typedef T value_type;
// void m(value_type v) {}
// };
// void main() {
// C<int> x;
// x.m(1);
// }
public void testTypedefSpecialization_213861() throws Exception {
IBinding b0= getBindingFromASTName("m(1)", 1);
assertInstance(b0, ICPPMethod.class);
}
// template<typename X>
// void foo(X x) {}
//
@ -813,20 +829,4 @@ public class IndexCPPTemplateResolutionTest extends IndexBindingResolutionTestBa
assertInstance(b1, ICPPTemplateDefinition.class);
assertInstance(b1, ICPPClassType.class);
}
// template<typename T>
// class C {
// public:
// typedef T value_type;
// void m(value_type v) {}
// };
// void main() {
// C<int> x;
// x.m(0);
// }
public void _testTypedefInTemplateClass_213861() throws Exception {
IBinding b0= getBindingFromASTName("m(0)", 1);
assertInstance(b0, ICPPMethod.class);
}
}

View file

@ -9,6 +9,7 @@
* IBM - Initial API and implementation
* Bryan Wilkinson (QNX)
* Markus Schorn (Wind River Systems)
* Sergey Prigogin (Google)
*******************************************************************************/
/*
* Created on Mar 11, 2005
@ -175,6 +176,7 @@ public class CPPTemplates {
}
return (binding instanceof ICPPTemplateDefinition) ? (ICPPTemplateDefinition) binding : null;
}
public static IBinding createBinding( ICPPASTTemplateParameter templateParameter ){
ICPPTemplateDefinition template = getContainingTemplate( templateParameter );
@ -210,6 +212,7 @@ public class CPPTemplates {
return binding;
}
static public ICPPScope getContainingScope( IASTNode node ){
while( node != null ){
if( node instanceof ICPPASTTemplateParameter ){
@ -282,7 +285,7 @@ public class CPPTemplates {
return CPPSemantics.postResolution(template, id);
}
} else {
//functions are instatiated as part of the resolution process
//functions are instantiated as part of the resolution process
template = CPPVisitor.createBinding( id );
if( template instanceof ICPPTemplateInstance ){
IASTName templateName = id.getTemplateName();
@ -312,6 +315,7 @@ public class CPPTemplates {
}
return null;
}
protected static IBinding createClassSpecialization( ICPPASTDeclSpecifier compSpec ){
IASTName name = null;
if( compSpec instanceof ICPPASTElaboratedTypeSpecifier )
@ -680,6 +684,14 @@ public class CPPTemplates {
} catch (DOMException e) {
}
newType = new CPPFunctionType( ret, params, ((ICPPFunctionType)type).isConst(), ((ICPPFunctionType)type).isVolatile() );
} else if (type instanceof ITypedef) {
// Typedef requires special treatment (bug 213861).
try {
ITypedef typedef = (ITypedef) type;
newType = new CPPTypedefSpecialization(typedef, (ICPPScope) typedef.getScope(), argMap);
} catch (DOMException e) {
return type;
}
} else if( type instanceof ITypeContainer ){
try {
temp = ((ITypeContainer) type).getType();
@ -1466,9 +1478,9 @@ public class CPPTemplates {
if( !isValidArgument(param, argument) ){
return false;
}
if( param instanceof ICPPTemplateTypeParameter )
if( param instanceof ICPPTemplateTypeParameter ) {
return true;
else if( param instanceof ICPPTemplateTemplateParameter ){
} else if( param instanceof ICPPTemplateTemplateParameter ){
if( !( argument instanceof ICPPTemplateDefinition ) )
return false;