diff --git a/core/org.eclipse.cdt.core.tests/ChangeLog b/core/org.eclipse.cdt.core.tests/ChangeLog index 7ee8739aec9..01307672f68 100644 --- a/core/org.eclipse.cdt.core.tests/ChangeLog +++ b/core/org.eclipse.cdt.core.tests/ChangeLog @@ -2,6 +2,11 @@ Updated clients to use new Scanner logging service. Added ScannerTestCase.testBug46402(). +2004-01-26 Andrew Niefer + Added ParserSymbolTableTest.testLongLong() + Added ParserSymbolTableTest.testComplex() + Added ParserSymbolTableTest.test_Bool() + 2004-01-22 John Camelon Updated Scanner tests for package updates in the core. diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ParserSymbolTableTest.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ParserSymbolTableTest.java index a1d403b092c..425dc92b74e 100644 --- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ParserSymbolTableTest.java +++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ParserSymbolTableTest.java @@ -3555,5 +3555,117 @@ public class ParserSymbolTableTest extends TestCase { assertFalse( iter.hasNext() ); } + + /** + * void f( long long int ){} //#1 + * void f( long int ) {} //#2 + * + * f( 1L ); //#2 + * f( 1LL ); //#1 + * + * @throws Exception + */ + public void testLongLong() throws Exception{ + newTable(); + IParameterizedSymbol f1 = table.newParameterizedSymbol( "f", TypeInfo.t_function ); + f1.addParameter( TypeInfo.t_int, TypeInfo.isLongLong, null, false ); + table.getCompilationUnit().addSymbol( f1 ); + + IParameterizedSymbol f2 = table.newParameterizedSymbol( "f", TypeInfo.t_function ); + f2.addParameter( TypeInfo.t_int, TypeInfo.isLong, null, false ); + table.getCompilationUnit().addSymbol( f2 ); + + List params = new LinkedList(); + params.add( new TypeInfo( TypeInfo.t_int, TypeInfo.isLong, null ) ); + + IParameterizedSymbol lookup = table.getCompilationUnit().unqualifiedFunctionLookup( "f", params ); + assertEquals( lookup, f2 ); + + params.clear(); + params.add( new TypeInfo( TypeInfo.t_int, TypeInfo.isLongLong, null ) ); + lookup = table.getCompilationUnit().unqualifiedFunctionLookup( "f", params ); + assertEquals( lookup, f1 ); + } + + /** + * void f( float _Complex ){} + * void g( float ) {} + * + * float _Complex c; + * float fl; + * float _Imaginary i; + * + * f( c ); + * f( fl ); + * g( c ); + * g( i ); + * @throws Exception + */ + public void testComplex() throws Exception{ + newTable(); + + IParameterizedSymbol f = table.newParameterizedSymbol( "f", TypeInfo.t_function ); + f.addParameter( TypeInfo.t_float, TypeInfo.isComplex, null, false ); + + table.getCompilationUnit().addSymbol( f ); + + IParameterizedSymbol g = table.newParameterizedSymbol( "g", TypeInfo.t_function ); + g.addParameter( TypeInfo.t_float, 0, null, false ); + table.getCompilationUnit().addSymbol( g ); + + List params = new LinkedList(); + params.add( new TypeInfo( TypeInfo.t_float, TypeInfo.isComplex, null ) ); + + IParameterizedSymbol lookup = table.getCompilationUnit().unqualifiedFunctionLookup( "f", params ); + + assertEquals( lookup, f ); + + params.clear(); + params.add( new TypeInfo( TypeInfo.t_float, 0, null ) ); + lookup = table.getCompilationUnit().unqualifiedFunctionLookup( "f", params ); + assertEquals( lookup, f ); + + params.clear(); + params.add( new TypeInfo( TypeInfo.t_float, TypeInfo.isComplex, null ) ); + lookup = table.getCompilationUnit().unqualifiedFunctionLookup( "g", params ); + assertEquals( lookup, g ); + + params.clear(); + params.add( new TypeInfo( TypeInfo.t_float, TypeInfo.isImaginary, null ) ); + lookup = table.getCompilationUnit().unqualifiedFunctionLookup( "g", params ); + assertEquals( lookup, g ); + + lookup = table.getCompilationUnit().unqualifiedFunctionLookup( "f", params ); + assertEquals( lookup, f ); + } + + public void test_Bool() throws Exception{ + newTable(); + + IParameterizedSymbol f = table.newParameterizedSymbol( "f", TypeInfo.t_function ); + f.addParameter( TypeInfo.t__Bool, 0, null, false ); + + table.getCompilationUnit().addSymbol( f ); + + IParameterizedSymbol g = table.newParameterizedSymbol( "g", TypeInfo.t_function ); + g.addParameter( TypeInfo.t_int, 0, null, false ); + + table.getCompilationUnit().addSymbol( g ); + + List params = new LinkedList(); + params.add( new TypeInfo( TypeInfo.t__Bool, 0, null ) ); + + IParameterizedSymbol look = table.getCompilationUnit().unqualifiedFunctionLookup( "f", params ); + assertEquals( look, f ); + + look = table.getCompilationUnit().unqualifiedFunctionLookup( "g", params ); + assertEquals( look, g ); + + params.clear(); + params.add( new TypeInfo( TypeInfo.t_int, 0, null ) ); + look = table.getCompilationUnit().unqualifiedFunctionLookup( "f", params ); + assertEquals( look, f ); + + } } diff --git a/core/org.eclipse.cdt.core/parser/ChangeLog-parser b/core/org.eclipse.cdt.core/parser/ChangeLog-parser index 4831e852e84..3987fd42c45 100644 --- a/core/org.eclipse.cdt.core/parser/ChangeLog-parser +++ b/core/org.eclipse.cdt.core/parser/ChangeLog-parser @@ -4,6 +4,12 @@ Added beginning of IScannerExtension and GCCScannerExtension support for gcc specific aspects. Added separate Scanner log category for tracing and updated clients to use it. +2004-01-26 Andrew Niefer + Handle the C types _Complex, _Imaginary, _Bool, & long long int: + modified ParserSymbolTable.promotion() & conversion() + added TypeInfo.isLongLong + modified TypeInfo.canHold() + 2004-01-23 John Camelon Added support for content assist in the scanner.. diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/pst/ParserSymbolTable.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/pst/ParserSymbolTable.java index e7bdcc40db8..a26381c5e60 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/pst/ParserSymbolTable.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/pst/ParserSymbolTable.java @@ -1495,9 +1495,9 @@ public class ParserSymbolTable { TypeInfo src = cost.source; TypeInfo trg = cost.target; - int mask = TypeInfo.isShort | TypeInfo.isLong | TypeInfo.isUnsigned; + int mask = TypeInfo.isShort | TypeInfo.isLong | TypeInfo.isUnsigned | TypeInfo.isLongLong; - if( (src.isType( TypeInfo.t_bool, TypeInfo.t_float ) || src.isType( TypeInfo.t_enumeration )) && + if( (src.isType( TypeInfo.t__Bool, TypeInfo.t_float ) || src.isType( TypeInfo.t_enumeration )) && (trg.isType( TypeInfo.t_int ) || trg.isType( TypeInfo.t_double )) ) { if( src.getType() == trg.getType() && (( src.getTypeInfo() & mask) == (trg.getTypeInfo() & mask)) ){ @@ -1594,11 +1594,11 @@ public class ParserSymbolTable { } else if( !src.hasPtrOperators() ) { //4.7 An rvalue of an integer type can be converted to an rvalue of another integer type. //An rvalue of an enumeration type can be converted to an rvalue of an integer type. - if( src.isType( TypeInfo.t_bool, TypeInfo.t_int ) || + if( src.isType( TypeInfo.t__Bool, TypeInfo.t_int ) || src.isType( TypeInfo.t_float, TypeInfo.t_double ) || src.isType( TypeInfo.t_enumeration ) ) { - if( trg.isType( TypeInfo.t_bool, TypeInfo.t_int ) || + if( trg.isType( TypeInfo.t__Bool, TypeInfo.t_int ) || trg.isType( TypeInfo.t_float, TypeInfo.t_double ) ) { cost.rank = Cost.CONVERSION_RANK; diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/pst/TypeInfo.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/pst/TypeInfo.java index 958832d87c1..84c91b0131e 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/pst/TypeInfo.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/pst/TypeInfo.java @@ -88,6 +88,7 @@ public class TypeInfo { public static final int isForward = 0x100000; public static final int isComplex = 0x200000; public static final int isImaginary= 0x400000; + public static final int isLongLong = 0x800000; // Types (maximum type is typeMask // Note that these should be considered ordered and if you change @@ -450,13 +451,18 @@ public class TypeInfo { * canHold * @param type * @return boolean - * return true is the our type can hold all the values of the passed in + * return true if our type can hold all the values of the passed in * type. * TODO, for now return true if our type is "larger" (based on ordering of * the type values) */ public boolean canHold( TypeInfo type ){ - return getType().compareTo( type.getType() ) >= 0; + if( getType().compareTo( type.getType()) > 0 ){ + return true; + } else { + int mask = TypeInfo.isShort | TypeInfo.isLong | TypeInfo.isLongLong; + return ( getTypeInfo() & mask ) >= ( type.getTypeInfo() & mask ); + } } public boolean equals( Object t ){