1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-08-08 08:45:44 +02:00

fix 72691 - [Parser] time_t is unresolved type

This commit is contained in:
Andrew Niefer 2004-09-17 20:58:49 +00:00
parent 4719df79d8
commit 05ca77b425
3 changed files with 45 additions and 2 deletions

View file

@ -2087,5 +2087,30 @@ public class CompleteParseASTTest extends CompleteParseBaseTest
parse( "enum DHCPFOBoolean { false, true } additionalHB, more_payload; \n", true, ParserLanguage.C ); parse( "enum DHCPFOBoolean { false, true } additionalHB, more_payload; \n", true, ParserLanguage.C );
assertTrue( callback.problems.isEmpty() ); assertTrue( callback.problems.isEmpty() );
} }
public void testBug72691() throws Exception{
StringWriter writer = new StringWriter();
writer.write( "typedef int * PINT; \n" );
writer.write( "typedef int * PINT; \n" );
writer.write( "PINT pint; \n" );
Iterator i = parse( writer.toString() ).getDeclarations();
assertTrue( i.next() instanceof IASTTypedefDeclaration );
assertTrue( i.next() instanceof IASTTypedefDeclaration );
assertTrue( i.next() instanceof IASTVariable);
assertFalse( i.hasNext() );
assertTrue( callback.problems.isEmpty() );
}
public void testBug72691_2() throws Exception{
StringWriter writer = new StringWriter();
writer.write( "typedef int * PINT; \n" );
writer.write( "namespace N { \n" );
writer.write( " typedef int * PINT; \n" );
writer.write( "} \n" );
writer.write( "using namespace N; \n" );
writer.write( "PINT pint; \n" );
parse( writer.toString() );
assertTrue( callback.problems.isEmpty() );
}
} }

View file

@ -3152,7 +3152,7 @@ public class CompleteParseASTFactory extends BaseASTFactory implements IASTFacto
} }
catch (ParserSymbolTableException e) catch (ParserSymbolTableException e)
{ {
handleProblem(e.createProblemID(), name ); handleProblem(e.createProblemID(), name, nameOffset, nameEndOffset, nameLine, true );
} }
ASTTypedef d = new ASTTypedef( typeSymbol, mapping, startingOffset, startingLine, nameOffset, nameEndOffset, nameLine, references, filename ); ASTTypedef d = new ASTTypedef( typeSymbol, mapping, startingOffset, startingLine, nameOffset, nameEndOffset, nameLine, references, filename );
attachSymbolExtension(typeSymbol, d, true ); attachSymbolExtension(typeSymbol, d, true );

View file

@ -529,7 +529,15 @@ public class ParserSymbolTable {
obj = foundSymbol; obj = foundSymbol;
else if( foundSymbol.isForwardDeclaration() && foundSymbol.getForwardSymbol() == obj ){ else if( foundSymbol.isForwardDeclaration() && foundSymbol.getForwardSymbol() == obj ){
//we already have what we want. //we already have what we want.
} else if( data.isPrefixLookup() ){ }
else if( foundSymbol.getTypeInfo().checkBit(ITypeInfo.isTypedef ) &&
obj.getTypeInfo().checkBit( ITypeInfo.isTypedef ) &&
foundSymbol.getTypeInfo().getFinalType( null ).equals(obj.getTypeInfo().getFinalType( null ) ))
{
//two typedef's with matching name, if they are typedefed to the same thing,
//then its all good and we already have the one we want. (7.1.3-2)
}
else if( data.isPrefixLookup() ){
data.addAmbiguity( foundSymbol.getName() ); data.addAmbiguity( foundSymbol.getName() );
} else { } else {
throw new ParserSymbolTableException( ParserSymbolTableException.r_Ambiguous ); throw new ParserSymbolTableException( ParserSymbolTableException.r_Ambiguous );
@ -835,6 +843,16 @@ public class ParserSymbolTable {
//allowable thing is if they are both functions. //allowable thing is if they are both functions.
if( origSymbol instanceof IParameterizedSymbol && newSymbol instanceof IParameterizedSymbol ) if( origSymbol instanceof IParameterizedSymbol && newSymbol instanceof IParameterizedSymbol )
return isValidFunctionOverload( (IParameterizedSymbol) origSymbol, (IParameterizedSymbol) newSymbol ); return isValidFunctionOverload( (IParameterizedSymbol) origSymbol, (IParameterizedSymbol) newSymbol );
if( origSymbol.getTypeInfo().checkBit( ITypeInfo.isTypedef ) && newSymbol.getTypeInfo().checkBit( ITypeInfo.isTypedef ) ){
TypeInfoProvider provider = origSymbol.getSymbolTable().getTypeInfoProvider();
ITypeInfo origFlat = origSymbol.getTypeInfo().getFinalType( provider );
ITypeInfo newFlat = origSymbol.getTypeInfo().getFinalType( provider );
boolean equals = origFlat.equals( newFlat );
provider.returnTypeInfo( origFlat );
provider.returnTypeInfo( newFlat );
return equals;
}
return false; return false;
} }