Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[cdt-patch] RE: [FIXED][71317][Parser] invalid overload of the name


This is a more solid fix for 71317 as the previous one didn't handle a certain case.

[FIXED][71317][Parser] invalid overload of the name

Devin Steffler
IBM's Eclipse CDT
Ottawa (Palladium), Ontario, Canada


Index: parser/org/eclipse/cdt/core/parser/tests/CompleteParseASTTest.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt-core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/CompleteParseASTTest.java,v
retrieving revision 1.135
diff -u -r1.135 CompleteParseASTTest.java
--- parser/org/eclipse/cdt/core/parser/tests/CompleteParseASTTest.java	18 Nov 2004 14:34:36 -0000	1.135
+++ parser/org/eclipse/cdt/core/parser/tests/CompleteParseASTTest.java	18 Nov 2004 20:47:13 -0000
@@ -2341,5 +2341,36 @@
     	writer.write("temp = (TYPE*)(pType + 1); /* Parser error is here */\n}\n"); //$NON-NLS-1$
     	parse(writer.toString());
     }
+    
+    public void testBug71317A() throws Exception {
+    	Writer writer = new StringWriter();
+    	writer.write("void f();\n"); //$NON-NLS-1$
+	    writer.write("namespace NS {\n"); //$NON-NLS-1$
+	    writer.write("using ::f;\n"); //$NON-NLS-1$
+	    writer.write("using ::f;\n}"); //$NON-NLS-1$
+	    parse(writer.toString());
+    }
+
+    public void testBug71317B() throws Exception {
+    	Writer writer = new StringWriter();
+    	writer.write("void f();\n"); //$NON-NLS-1$
+	    writer.write("namespace NS {\n"); //$NON-NLS-1$
+	    writer.write("void f();\n"); //$NON-NLS-1$
+	    writer.write("using ::f;\n}"); //$NON-NLS-1$
+	    
+	    try{
+	    	parse(writer.toString());
+	    	assertTrue(false);
+		} catch (ParserException pe) {
+			// expected IProblem
+		} finally {
+	    	Iterator probs = callback.getProblems();
+			assertTrue( probs.hasNext() );
+	    	Object ipo = probs.next();
+	    	assertTrue( ipo instanceof IProblem );
+	    	IProblem ip = (IProblem)ipo;
+	    	assertEquals(ip.getSourceLineNumber(), 4);
+		}
+    }
 }
 
Index: parser/org/eclipse/cdt/internal/core/parser/pst/ParserSymbolTable.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt-core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/pst/ParserSymbolTable.java,v
retrieving revision 1.93
diff -u -r1.93 ParserSymbolTable.java
--- parser/org/eclipse/cdt/internal/core/parser/pst/ParserSymbolTable.java	16 Nov 2004 20:06:20 -0000	1.93
+++ parser/org/eclipse/cdt/internal/core/parser/pst/ParserSymbolTable.java	18 Nov 2004 20:47:00 -0000
@@ -939,6 +939,15 @@
 				return true;
 			}
 			
+			// fix 71317, see C++ spec 7.3.3-11
+			if (newSymbol.isForwardDeclaration() && newSymbol.getForwardSymbol() != null 
+					&& newSymbol.getContainingSymbol() == origSymbol.getContainingSymbol() 
+					&& newSymbol.getForwardSymbol().getContainingSymbol() != newSymbol.getContainingSymbol() 
+					&& origSymbol.isForwardDeclaration() && origSymbol.getForwardSymbol() != null 
+					&& origSymbol.getForwardSymbol().getContainingSymbol() != origSymbol.getContainingSymbol()) {
+				return true;
+			}
+			
 			return false;
 		}

Back to the top