mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-29 19:45:01 +02:00
fix NPE and ClassCastException encountered while parsing <list>
fix bug in handling some template member templates
This commit is contained in:
parent
32abdb30e8
commit
daaf6bcf2b
6 changed files with 63 additions and 2 deletions
|
@ -1,3 +1,6 @@
|
|||
2004-04-09 Andrew Niefer
|
||||
added parser/org/eclipse/cdt/core/parser/tests/CompleteParseASTTemplateTest.testTemplateMemberTemplateDefinition()
|
||||
|
||||
2004-04-09 Andrew Niefer
|
||||
fixed bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=57754
|
||||
added parser/org/eclipse/cdt/core/parser/tests/CompleteParseASTTest.testBug57754()
|
||||
|
|
|
@ -735,4 +735,24 @@ public class CompleteParseASTTemplateTest extends CompleteParseBaseTest {
|
|||
IASTTemplateDeclaration template = (IASTTemplateDeclaration) i.next();
|
||||
IASTTemplateSpecialization spec = (IASTTemplateSpecialization) i.next();
|
||||
}
|
||||
|
||||
public void testTemplateMemberTemplateDefinition() throws Exception
|
||||
{
|
||||
Writer writer = new StringWriter();
|
||||
writer.write( "template< typename _Tp > ");
|
||||
writer.write( "class list ");
|
||||
writer.write( "{ ");
|
||||
writer.write( " template<typename _S> void merge(list&, _S); ");
|
||||
writer.write( "}; ");
|
||||
|
||||
writer.write( "template < typename _Tp > ");
|
||||
writer.write( "template < typename _S > ");
|
||||
writer.write( "void list<_Tp>::merge(list<_Tp>& __x, _S __comp) ");
|
||||
writer.write( "{} ");
|
||||
|
||||
Iterator i = parse( writer.toString() ).getDeclarations();
|
||||
|
||||
IASTTemplateDeclaration template = (IASTTemplateDeclaration) i.next();
|
||||
IASTTemplateDeclaration temp2 = (IASTTemplateDeclaration) i.next();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,3 +1,7 @@
|
|||
2004-04-09 Andrew Niefer
|
||||
handle NPE during template argument deduction
|
||||
fix bug in definitions of certain template member templates (fixes a ClassCastException encountered in <list>)
|
||||
|
||||
2004-04-09 Andrew Niefer
|
||||
fixed https://bugs.eclipse.org/bugs/show_bug.cgi?id=57754
|
||||
Fixed problems found after parsing iostream with discovered symbols, once 57754 was fixed:
|
||||
|
|
|
@ -443,6 +443,8 @@ public final class TemplateEngine {
|
|||
if( p.isType( TypeInfo.t_type ) ){
|
||||
symbol = p.getTypeSymbol();
|
||||
ISymbol aSymbol = a.getTypeSymbol();
|
||||
if( symbol == null || ( a.isType( TypeInfo.t_type) && aSymbol == null ) )
|
||||
throw new ParserSymbolTableException( ParserSymbolTableException.r_BadTypeInfo );
|
||||
if( symbol instanceof IDeferredTemplateInstance || symbol.isTemplateInstance() ){
|
||||
return deduceFromTemplateTemplateArguments(map, symbol, aSymbol);
|
||||
} else {
|
||||
|
@ -1273,4 +1275,30 @@ public final class TemplateEngine {
|
|||
}
|
||||
return (ITemplateSymbol) symbol.getContainingSymbol();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param instance
|
||||
* @param instance2
|
||||
* @return
|
||||
*/
|
||||
protected static boolean deferedInstancesAreEquivalent(IDeferredTemplateInstance instance, IDeferredTemplateInstance instance2) {
|
||||
if( instance.getTemplate() != instance2.getTemplate() )
|
||||
return false;
|
||||
|
||||
List args = instance.getArguments();
|
||||
List args2 = instance2.getArguments();
|
||||
|
||||
if( args.size() != args2.size() )
|
||||
return false;
|
||||
|
||||
Iterator iter1 = args.iterator(), iter2 = args2.iterator();
|
||||
while( iter1.hasNext() ){
|
||||
TypeInfo info1 = (TypeInfo) iter1.next();
|
||||
TypeInfo info2 = (TypeInfo) iter2.next();
|
||||
|
||||
if( ! info1.equals( info2 ) )
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -18,6 +18,7 @@ import java.util.ListIterator;
|
|||
import java.util.Map;
|
||||
|
||||
import org.eclipse.cdt.core.parser.ast.ASTAccessVisibility;
|
||||
import org.eclipse.cdt.core.parser.ast.IASTScope;
|
||||
import org.eclipse.cdt.internal.core.parser.ast.complete.ASTTemplateDeclaration;
|
||||
import org.eclipse.cdt.internal.core.parser.ast.complete.ASTTemplateInstantiation;
|
||||
import org.eclipse.cdt.internal.core.parser.pst.TypeInfo.PtrOp;
|
||||
|
|
|
@ -492,10 +492,15 @@ public class TypeInfo {
|
|||
else
|
||||
result &= (f1.getReturnType() == f2.getReturnType());
|
||||
} else if( _typeDeclaration.isType( TypeInfo.t_templateParameter ) &&
|
||||
type._typeDeclaration.isType( TypeInfo.t_templateParameter ) ){
|
||||
type._typeDeclaration.isType( TypeInfo.t_templateParameter ) )
|
||||
{
|
||||
//template parameters
|
||||
result &= TemplateEngine.templateParametersAreEquivalent( _typeDeclaration, type._typeDeclaration );
|
||||
} else {
|
||||
} else if ( _typeDeclaration instanceof IDeferredTemplateInstance &&
|
||||
type._typeDeclaration instanceof IDeferredTemplateInstance )
|
||||
{
|
||||
result &= TemplateEngine.deferedInstancesAreEquivalent( (IDeferredTemplateInstance) _typeDeclaration, (IDeferredTemplateInstance)type._typeDeclaration );
|
||||
}else {
|
||||
//otherwise, its a user defined type, need the decls the same
|
||||
result &= ( _typeDeclaration == type._typeDeclaration );
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue