Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[cdt-patch] bug43834 : Empty Parameter list & void

Core:
- fixed bug 43834 : Empty Parameter list and parameter list taking one 
void do not match
- fix NPE if IScannerInfoProvider returns null IScannerInfo

Tests:
- added testbug43834 to ParserSymbolTableTest

tested on windows & linux

-Andrew
Index: parser/ChangeLog
===================================================================
RCS file: /home/tools/org.eclipse.cdt.core/parser/ChangeLog,v
retrieving revision 1.141
diff -u -r1.141 ChangeLog
--- parser/ChangeLog	29 Sep 2003 19:22:09 -0000	1.141
+++ parser/ChangeLog	29 Sep 2003 19:25:36 -0000
@@ -1,3 +1,6 @@
+2003-09-29 Andrew Niefer
+	fixed bug 43834 : Empty Parameter list and parameter list taking one void do not match
+
 2003-09-29 John Camelon
 	Continued work on Bug 43062 : Outline is confused on operator methods containing spaces 
 	Partial fix for   Bug 43680 : Fix Parser Error Handling 
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.21
diff -u -r1.21 ParserSymbolTable.java
--- parser/org/eclipse/cdt/internal/core/parser/pst/ParserSymbolTable.java	19 Sep 2003 16:00:53 -0000	1.21
+++ parser/org/eclipse/cdt/internal/core/parser/pst/ParserSymbolTable.java	29 Sep 2003 19:25:37 -0000
@@ -721,10 +721,20 @@
 			currFn = (IParameterizedSymbol) iterFns.next();
 			
 			sourceParams = data.parameters.iterator();
-			targetParams = currFn.getParameterList().iterator();
 			
-			//number of parameters in the current function
-			numTargetParams = currFn.getParameterList().size();
+			List parameterList = null;
+			if( currFn.getParameterList() == null ){
+				//the only way we get here and have no parameters, is if we are looking
+				//for a function that takes void parameters ie f( void )
+				parameterList = new LinkedList();
+				parameterList.add( currFn.getSymbolTable().newSymbol( "", TypeInfo.t_void ) );
+				targetParams = parameterList.iterator();
+			} else {
+				parameterList = currFn.getParameterList();
+			}
+			
+			targetParams = parameterList.iterator();
+			numTargetParams = parameterList.size();
 			
 			//we only need to look at the smaller number of parameters
 			//(a larger number in the Target means default parameters, a larger
@@ -825,9 +835,21 @@
 			if( num == numParameters ){
 				continue;
 			} 
+			//check for void
+			else if( numParameters == 0 && num == 1 ){
+				ISymbol param = (ISymbol)function.getParameterList().iterator().next();
+				if( param.isType( TypeInfo.t_void ) )
+					continue;
+			}
+			else if( numParameters == 1 && num == 0 ){
+				TypeInfo paramType = (TypeInfo) data.parameters.iterator().next();
+				if( paramType.isType( TypeInfo.t_void ) )
+					continue;
+			}
+			
 			//A candidate function having fewer than m parameters is viable only if it has an 
 			//ellipsis in its parameter list.
-			else if( num < numParameters ) {
+			if( num < numParameters ) {
 				//TODO ellipsis
 				//not enough parameters, remove it
 				iter.remove();		
Index: search/ChangeLog
===================================================================
RCS file: /home/tools/org.eclipse.cdt.core/search/ChangeLog,v
retrieving revision 1.30
diff -u -r1.30 ChangeLog
--- search/ChangeLog	26 Sep 2003 17:53:31 -0000	1.30
+++ search/ChangeLog	29 Sep 2003 19:25:38 -0000
@@ -1,3 +1,6 @@
+2003-09-29 Andrew Niefer
+	-fix NPE if IScannerInfoProvider returns null IScannerInfo
+
 2003-09-25 Andrew Niefer
 	- bug43129 - Cannot search for definitions of global variables
 		- check definitions for variables, fields, enumerators and namespaces
Index: search/org/eclipse/cdt/internal/core/search/matching/MatchLocator.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.core/search/org/eclipse/cdt/internal/core/search/matching/MatchLocator.java,v
retrieving revision 1.33
diff -u -r1.33 MatchLocator.java
--- search/org/eclipse/cdt/internal/core/search/matching/MatchLocator.java	26 Sep 2003 14:58:12 -0000	1.33
+++ search/org/eclipse/cdt/internal/core/search/matching/MatchLocator.java	29 Sep 2003 19:25:38 -0000
@@ -418,7 +418,8 @@
 			IScannerInfoProvider provider = CCorePlugin.getDefault().getScannerInfoProvider(project);
 			if (provider != null){
 				IScannerInfo buildScanInfo = provider.getScannerInformation(project);
-				scanInfo = new ScannerInfo(buildScanInfo.getDefinedSymbols(), buildScanInfo.getIncludePaths());
+				if( buildScanInfo != null )
+					scanInfo = new ScannerInfo(buildScanInfo.getDefinedSymbols(), buildScanInfo.getIncludePaths());
 			}
 			
 			ParserLanguage language = null;
Index: ChangeLog
===================================================================
RCS file: /home/tools/org.eclipse.cdt.core.tests/ChangeLog,v
retrieving revision 1.120
diff -u -r1.120 ChangeLog
--- ChangeLog	29 Sep 2003 19:21:57 -0000	1.120
+++ ChangeLog	29 Sep 2003 19:28:23 -0000
@@ -1,3 +1,6 @@
+2003-09-29 Andrew Niefer
+	added testbug43834() to ParserSymbolTableTest
+
 2003-09-29 John Camelon
 	Added testErrorHandling_1() to CompleteParseASTTest.java.  
 
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.20
diff -u -r1.20 ParserSymbolTableTest.java
--- parser/org/eclipse/cdt/core/parser/tests/ParserSymbolTableTest.java	19 Sep 2003 16:00:44 -0000	1.20
+++ parser/org/eclipse/cdt/core/parser/tests/ParserSymbolTableTest.java	29 Sep 2003 19:28:24 -0000
@@ -2822,5 +2822,27 @@
 		returned = ParserSymbolTable.getConditionalOperand( secondOp, thirdOp );
 		assertEquals( returned, secondOp );	
 	}
+	
+	public void testbug43834() throws Exception{
+		newTable();
+		
+		IParameterizedSymbol f = table.newParameterizedSymbol( "f", TypeInfo.t_function );
+		table.getCompilationUnit().addSymbol( f );
+		
+		LinkedList parameters = new LinkedList();
+		TypeInfo param = new TypeInfo( TypeInfo.t_void, 0, null );
+		parameters.add( param );
+		
+		
+		ISymbol look = table.getCompilationUnit().unqualifiedFunctionLookup( "f", parameters );
+		assertEquals( look, f );
+		
+		f.addParameter( TypeInfo.t_void, 0, null, false );
+		
+		parameters.clear();
+		
+		look = table.getCompilationUnit().unqualifiedFunctionLookup( "f", parameters );
+		assertEquals( look, f );
+	}
 }
 

Back to the top