[
Date Prev][
Date Next][
Thread Prev][
Thread Next][
Date Index][
Thread Index]
[
List Home]
[cdt-patch] PST changes for bug 43503
|
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
tested on windows & linux
-Andrew
Index: parser/ChangeLog
===================================================================
RCS file: /home/tools/org.eclipse.cdt.core/parser/ChangeLog,v
retrieving revision 1.143
diff -u -r1.143 ChangeLog
--- parser/ChangeLog 30 Sep 2003 13:51:51 -0000 1.143
+++ parser/ChangeLog 30 Sep 2003 16:25:51 -0000
@@ -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
Index: parser/org/eclipse/cdt/internal/core/parser/pst/ParserSymbolTable.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/pst/ParserSymbolTable.java,v
retrieving revision 1.22
diff -u -r1.22 ParserSymbolTable.java
--- parser/org/eclipse/cdt/internal/core/parser/pst/ParserSymbolTable.java 29 Sep 2003 19:49:13 -0000 1.22
+++ parser/org/eclipse/cdt/internal/core/parser/pst/ParserSymbolTable.java 30 Sep 2003 16:25:52 -0000
@@ -657,7 +657,7 @@
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 @@
//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 );
Index: parser/org/eclipse/cdt/internal/core/parser/pst/ParserSymbolTableException.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/pst/ParserSymbolTableException.java,v
retrieving revision 1.4
diff -u -r1.4 ParserSymbolTableException.java
--- parser/org/eclipse/cdt/internal/core/parser/pst/ParserSymbolTableException.java 19 Sep 2003 16:00:53 -0000 1.4
+++ parser/org/eclipse/cdt/internal/core/parser/pst/ParserSymbolTableException.java 30 Sep 2003 16:25:52 -0000
@@ -44,6 +44,7 @@
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;
}
Index: ChangeLog
===================================================================
RCS file: /home/tools/org.eclipse.cdt.core.tests/ChangeLog,v
retrieving revision 1.124
diff -u -r1.124 ChangeLog
--- ChangeLog 30 Sep 2003 14:10:28 -0000 1.124
+++ ChangeLog 30 Sep 2003 16:30:10 -0000
@@ -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
Index: parser/org/eclipse/cdt/core/parser/tests/ParserSymbolTableTest.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ParserSymbolTableTest.java,v
retrieving revision 1.21
diff -u -r1.21 ParserSymbolTableTest.java
--- parser/org/eclipse/cdt/core/parser/tests/ParserSymbolTableTest.java 29 Sep 2003 19:49:19 -0000 1.21
+++ parser/org/eclipse/cdt/core/parser/tests/ParserSymbolTableTest.java 30 Sep 2003 16:30:11 -0000
@@ -2844,5 +2844,73 @@
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 );
+ }
+
+ }
}