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

Patch for Andrew Niefer

Core:
PST changes for bug 43503 - parser needs to know the different between 
ambiguous functions
        and no functions when no parameter information is provided
        - throw r_UnableToResolveFunction if we have more than 1 function 
and no parameter info was given
        - handle this case in addUsingDeclaration.
        * note that r_UnableToResolveFunction doesn't necessarily mean 
ambiguous if we had enough information

Core.Tests:
added testBug43503_AmbiguousUsing() and 
testBug43503_UnableToResolveFunction() to ParserSymbolTableTest
This commit is contained in:
John Camelon 2003-09-30 18:03:20 +00:00
parent cde1f83a0c
commit e3e3ba0e9e
5 changed files with 89 additions and 2 deletions

View file

@ -1,3 +1,7 @@
2003-09-30 Andrew Niefer
added testBug43503_AmbiguousUsing() and testBug43503_UnableToResolveFunction() to
ParserSymbolTableTest
2003-09-29 Andrew Niefer
added testBug43062 and testConstructorDestructor to FunctionMethodPatternTests
modified resources/search/classDecl.cpp & include.h to include more operators and a constructor

View file

@ -2844,5 +2844,73 @@ public class ParserSymbolTableTest extends TestCase {
look = table.getCompilationUnit().unqualifiedFunctionLookup( "f", parameters );
assertEquals( look, f );
}
/**
*
* namespace A{
* void f();
* }
* namespace B{
* int f;
* }
* namespace C{
* using namespace A;
* using namespace B;
* using f; //ambiguous, int f or void f()?
* }
*/
public void testBug43503_AmbiguousUsing() throws Exception{
newTable();
IContainerSymbol NSA = table.newContainerSymbol( "A", TypeInfo.t_namespace );
table.getCompilationUnit().addSymbol( NSA );
IParameterizedSymbol f1 = table.newParameterizedSymbol( "f", TypeInfo.t_function );
NSA.addSymbol( f1 );
IContainerSymbol NSB = table.newContainerSymbol( "B", TypeInfo.t_namespace );
table.getCompilationUnit().addSymbol( NSB );
ISymbol f2 = table.newSymbol( "f", TypeInfo.t_int );
NSB.addSymbol( f2 );
IContainerSymbol NSC = table.newContainerSymbol( "C", TypeInfo.t_namespace );
table.getCompilationUnit().addSymbol( NSC );
NSC.addUsingDirective( NSA );
NSC.addUsingDirective( NSB );
try{
NSC.addUsingDeclaration( "f" );
assertTrue( false );
} catch ( ParserSymbolTableException e ){
assertEquals( e.reason, ParserSymbolTableException.r_Ambiguous );
}
}
/**
* void f( void );
* void f( int );
*
* void * pF = &f; //lookup without function parameters, should be ambiguous
* @throws Exception
*/
public void testBug43503_UnableToResolveFunction() throws Exception{
newTable();
IParameterizedSymbol f1 = table.newParameterizedSymbol( "f", TypeInfo.t_function );
IParameterizedSymbol f2 = table.newParameterizedSymbol( "f", TypeInfo.t_function );
f2.addParameter( TypeInfo.t_int, 0, null, false );
table.getCompilationUnit().addSymbol( f1 );
table.getCompilationUnit().addSymbol( f2 );
try{
table.getCompilationUnit().lookup( "f" );
assertTrue( false );
} catch( ParserSymbolTableException e ){
assertEquals( e.reason, ParserSymbolTableException.r_UnableToResolveFunction );
}
}
}

View file

@ -1,3 +1,10 @@
2003-09-30 Andrew Niefer
PST changes for bug 43503 - parser needs to know the different between ambiguous functions
and no functions when no parameter information is provided
- throw r_UnableToResolveFunction if we have more than 1 function and no parameter info was given
- handle this case in addUsingDeclaration.
* note that r_UnableToResolveFunction doesn't necessarily mean ambiguous if we had enough information
2003-09-29 Hoda Amer
Solution to bug#43679 : Exceptions in indexer

View file

@ -657,7 +657,7 @@ public class ParserSymbolTable {
return (ISymbol) functionList.getFirst();
} else {
data.foundItems.addAll( functionList );
return null;
throw new ParserSymbolTableException( ParserSymbolTableException.r_UnableToResolveFunction );
}
} else {
return resolveFunction( data, functionList );
@ -3074,7 +3074,14 @@ public class ParserSymbolTable {
//figure out which declaration we are talking about, if it is a set of functions,
//then they will be in data.foundItems (since we provided no parameter info);
BasicSymbol obj = (BasicSymbol)ParserSymbolTable.resolveAmbiguities( data );
BasicSymbol obj = null;
try{
obj = (BasicSymbol)ParserSymbolTable.resolveAmbiguities( data );
} catch ( ParserSymbolTableException e ) {
if( e.reason != ParserSymbolTableException.r_UnableToResolveFunction ){
throw e;
}
}
if( data.foundItems == null ){
throw new ParserSymbolTableException( ParserSymbolTableException.r_InvalidUsing );

View file

@ -44,6 +44,7 @@ public class ParserSymbolTableException extends Exception {
public static final int r_BadTemplate = 4;
public static final int r_InvalidUsing = 5;
public static final int r_BadVisibility = 6;
public static final int r_UnableToResolveFunction = 7;
public int reason = -1;
}