mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-29 19:45:01 +02:00
Patch for Andrew Niefer.
Updates to handle _Bool Core: - modified CompleteParseASTFactory.getParameterTypeInfo CompleteParseASTFactory.createReference CompleteParseASTFactory.usualArithmeticConversions CompleteParseASTFactory.getTypeKind Parser.typeId TypeFilter.shouldAccept TypeInfo.equals Core.tests: - Added CompleteParseASTTest.testCBoolAsParameter
This commit is contained in:
parent
2ec990a2d5
commit
52351e60d8
7 changed files with 51 additions and 7 deletions
|
@ -1,3 +1,6 @@
|
||||||
|
2004-01-27 Andrew Niefer
|
||||||
|
Added CompleteParseASTTest.testCBoolAsParameter
|
||||||
|
|
||||||
2004-01-26 John Camelon
|
2004-01-26 John Camelon
|
||||||
Updated clients to use new Scanner logging service.
|
Updated clients to use new Scanner logging service.
|
||||||
Added ScannerTestCase.testBug46402().
|
Added ScannerTestCase.testBug46402().
|
||||||
|
|
|
@ -986,6 +986,25 @@ public class CompleteParseASTTest extends CompleteParseBaseTest
|
||||||
assertEquals( ((IASTSimpleTypeSpecifier)variable.getAbstractDeclaration().getTypeSpecifier()).getType(), IASTSimpleTypeSpecifier.Type._BOOL );
|
assertEquals( ((IASTSimpleTypeSpecifier)variable.getAbstractDeclaration().getTypeSpecifier()).getType(), IASTSimpleTypeSpecifier.Type._BOOL );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void testCBoolAsParameter() throws Exception
|
||||||
|
{
|
||||||
|
Iterator i = parse( "void f( _Bool b ) {} " +
|
||||||
|
"_Bool g( _Bool b ) {} " +
|
||||||
|
"void main(){" +
|
||||||
|
" _Bool b; " +
|
||||||
|
" f(b);" +
|
||||||
|
" f( g( (_Bool) 1 ) );" +
|
||||||
|
"}",
|
||||||
|
true, ParserLanguage.C ).getDeclarations();
|
||||||
|
|
||||||
|
IASTFunction f = (IASTFunction) i.next();
|
||||||
|
IASTFunction g = (IASTFunction) i.next();
|
||||||
|
IASTFunction main = (IASTFunction) i.next();
|
||||||
|
IASTVariable b = (IASTVariable) getDeclarations( main ).next();
|
||||||
|
|
||||||
|
assertAllReferences( 4, createTaskList( new Task( f, 2 ), new Task( b ), new Task( g ) ) );
|
||||||
|
}
|
||||||
|
|
||||||
public void testBug44510() throws Exception
|
public void testBug44510() throws Exception
|
||||||
{
|
{
|
||||||
Iterator i = parse( "int initialize(); " +
|
Iterator i = parse( "int initialize(); " +
|
||||||
|
|
|
@ -1,3 +1,13 @@
|
||||||
|
2004-01-27 Andrew Niefer
|
||||||
|
Updates to handle _Bool
|
||||||
|
- modified CompleteParseASTFactory.getParameterTypeInfo
|
||||||
|
CompleteParseASTFactory.createReference
|
||||||
|
CompleteParseASTFactory.usualArithmeticConversions
|
||||||
|
CompleteParseASTFactory.getTypeKind
|
||||||
|
Parser.typeId
|
||||||
|
TypeFilter.shouldAccept
|
||||||
|
TypeInfo.equals
|
||||||
|
|
||||||
2004-01-26 John Camelon
|
2004-01-26 John Camelon
|
||||||
Added traceLogs into Scanner.
|
Added traceLogs into Scanner.
|
||||||
Fixed Bug 46402 : expression evaluation error on branch not taken
|
Fixed Bug 46402 : expression evaluation error on branch not taken
|
||||||
|
|
|
@ -4078,6 +4078,12 @@ public abstract class Parser implements IParser
|
||||||
consume();
|
consume();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case IToken.t__Bool :
|
||||||
|
if( encounteredType ) break simpleMods;
|
||||||
|
encounteredType = true;
|
||||||
|
kind = IASTSimpleTypeSpecifier.Type._BOOL;
|
||||||
|
consume();
|
||||||
|
break;
|
||||||
|
|
||||||
default :
|
default :
|
||||||
break simpleMods;
|
break simpleMods;
|
||||||
|
|
|
@ -699,7 +699,8 @@ public class CompleteParseASTFactory extends BaseASTFactory implements IASTFacto
|
||||||
( symbol.getType() == TypeInfo.t_int ) ||
|
( symbol.getType() == TypeInfo.t_int ) ||
|
||||||
( symbol.getType() == TypeInfo.t_float )||
|
( symbol.getType() == TypeInfo.t_float )||
|
||||||
( symbol.getType() == TypeInfo.t_double ) ||
|
( symbol.getType() == TypeInfo.t_double ) ||
|
||||||
( symbol.getType() == TypeInfo.t_void ) )
|
( symbol.getType() == TypeInfo.t_void ) ||
|
||||||
|
( symbol.getType() == TypeInfo.t__Bool) )
|
||||||
|
|
||||||
{
|
{
|
||||||
if( symbol.getContainingSymbol().getType() == TypeInfo.t_class ||
|
if( symbol.getContainingSymbol().getType() == TypeInfo.t_class ||
|
||||||
|
@ -977,8 +978,8 @@ public class CompleteParseASTFactory extends BaseASTFactory implements IASTFacto
|
||||||
rhs = rhs.getTypeSymbol().getTypeInfo();
|
rhs = rhs.getTypeSymbol().getTypeInfo();
|
||||||
}
|
}
|
||||||
|
|
||||||
if( !lhs.isType(TypeInfo.t_bool, TypeInfo.t_enumerator ) &&
|
if( !lhs.isType(TypeInfo.t__Bool, TypeInfo.t_enumerator ) &&
|
||||||
!rhs.isType(TypeInfo.t_bool, TypeInfo.t_enumerator ) )
|
!rhs.isType(TypeInfo.t__Bool, TypeInfo.t_enumerator ) )
|
||||||
{
|
{
|
||||||
throw new ASTSemanticException();
|
throw new ASTSemanticException();
|
||||||
}
|
}
|
||||||
|
@ -1751,6 +1752,9 @@ public class CompleteParseASTFactory extends BaseASTFactory implements IASTFacto
|
||||||
type.setType(TypeInfo.t_wchar_t);
|
type.setType(TypeInfo.t_wchar_t);
|
||||||
else if( kind == IASTSimpleTypeSpecifier.Type.CLASS_OR_TYPENAME )
|
else if( kind == IASTSimpleTypeSpecifier.Type.CLASS_OR_TYPENAME )
|
||||||
type.setType(TypeInfo.t_type);
|
type.setType(TypeInfo.t_type);
|
||||||
|
else if( kind == IASTSimpleTypeSpecifier.Type._BOOL ){
|
||||||
|
type.setType( TypeInfo.t__Bool );
|
||||||
|
}
|
||||||
else
|
else
|
||||||
throw new ASTSemanticException();
|
throw new ASTSemanticException();
|
||||||
}
|
}
|
||||||
|
@ -2728,6 +2732,8 @@ public class CompleteParseASTFactory extends BaseASTFactory implements IASTFacto
|
||||||
IASTSimpleTypeSpecifier.Type type = id.getKind();
|
IASTSimpleTypeSpecifier.Type type = id.getKind();
|
||||||
if( type == IASTSimpleTypeSpecifier.Type.BOOL )
|
if( type == IASTSimpleTypeSpecifier.Type.BOOL )
|
||||||
return TypeInfo.t_bool;
|
return TypeInfo.t_bool;
|
||||||
|
else if( type == IASTSimpleTypeSpecifier.Type._BOOL )
|
||||||
|
return TypeInfo.t__Bool;
|
||||||
else if( type == IASTSimpleTypeSpecifier.Type.CHAR )
|
else if( type == IASTSimpleTypeSpecifier.Type.CHAR )
|
||||||
return TypeInfo.t_char;
|
return TypeInfo.t_char;
|
||||||
else if( type == IASTSimpleTypeSpecifier.Type.DOUBLE )
|
else if( type == IASTSimpleTypeSpecifier.Type.DOUBLE )
|
||||||
|
|
|
@ -74,7 +74,7 @@ public class TypeFilter {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if ( typeInfo.isType( TypeInfo.t_type ) || typeInfo.isType( TypeInfo.t_bool, TypeInfo.t_void ) )
|
else if ( typeInfo.isType( TypeInfo.t_type ) || typeInfo.isType( TypeInfo.t__Bool, TypeInfo.t_void ) )
|
||||||
{
|
{
|
||||||
if( ( acceptedKinds.contains( LookupKind.VARIABLES ) && !symbolIsMember && !symbolIsLocal ) ||
|
if( ( acceptedKinds.contains( LookupKind.VARIABLES ) && !symbolIsMember && !symbolIsLocal ) ||
|
||||||
( acceptedKinds.contains( LookupKind.LOCAL_VARIABLES ) && !symbolIsMember && symbolIsLocal ) ||
|
( acceptedKinds.contains( LookupKind.LOCAL_VARIABLES ) && !symbolIsMember && symbolIsLocal ) ||
|
||||||
|
|
|
@ -479,8 +479,8 @@ public class TypeInfo {
|
||||||
result &= _typeDeclaration.equals( type._typeDeclaration );
|
result &= _typeDeclaration.equals( type._typeDeclaration );
|
||||||
} else {
|
} else {
|
||||||
if( _typeDeclaration != null && type._typeDeclaration != null &&
|
if( _typeDeclaration != null && type._typeDeclaration != null &&
|
||||||
_typeDeclaration.isType( TypeInfo.t_bool, TypeInfo.t_void ) &&
|
_typeDeclaration.isType( TypeInfo.t__Bool, TypeInfo.t_void ) &&
|
||||||
type._typeDeclaration.isType( TypeInfo.t_bool, TypeInfo.t_void ) )
|
type._typeDeclaration.isType( TypeInfo.t__Bool, TypeInfo.t_void ) )
|
||||||
{
|
{
|
||||||
//if typeDeclaration is a basic type, then only need the types the same
|
//if typeDeclaration is a basic type, then only need the types the same
|
||||||
result &= ( _typeDeclaration.getType() == type._typeDeclaration.getType() );
|
result &= ( _typeDeclaration.getType() == type._typeDeclaration.getType() );
|
||||||
|
|
Loading…
Add table
Reference in a new issue