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

patch from Devin Steffler : fix for 71317 invalid overload of the name

This commit is contained in:
Andrew Niefer 2004-11-18 21:05:26 +00:00
parent 9293cb16fb
commit 235b6312f0
3 changed files with 39 additions and 21 deletions

View file

@ -139,25 +139,4 @@ public class FailedCompleteParseASTTest extends CompleteParseBaseTest
// assertFalse( i.hasNext() );
// assertAllReferences( 4 /*should be 5 */, createTaskList( new Task( cl /* , 2 */ ), new Task( a), new Task( pm), new Task( f2)));
}
public void testUsingOverloadedName_bug71317() throws Exception {
// using a globaly defined function overloaded in a namespace
try {
parse("int foo(int); \n namespace NS { \n int foo(int); \n using ::foo; \n } \n");//$NON-NLS-1$
fail();
} catch ( ParserException e ){
assertTrue( e.getMessage().equals( "FAILURE" ) ); //$NON-NLS-1$
}
// Iterator i = parse("int foo(); \n namespace NS { int bar(); \n using ::foo; \n } \n").getDeclarations();//$NON-NLS-1$
// IASTFunction fd1 = (IASTFunction) i.next();
// IASTNamespaceDefinition nd = (IASTNamespaceDefinition) i.next();
// assertFalse(i.hasNext());
// Iterator j = nd.getDeclarations();
// IASTFunction fd2 = (IASTFunction) j.next();
// IASTUsingDeclaration ud = (IASTUsingDeclaration) j.next();
// assertFalse(j.hasNext());
}
}

View file

@ -2386,6 +2386,35 @@ public class CompleteParseASTTest extends CompleteParseBaseTest
assertFalse( i.hasNext() );
}
}
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);
}
}
}

View file

@ -939,6 +939,16 @@ public class ParserSymbolTable {
return true;
}
// fix 71317, see C++ spec 7.3.3-11, two using declarations may introduce functions with the same
//name and parameter types
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;
}