mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-07-19 15:05:36 +02:00
Patch for Devin Steffler.
Fixed 72692 - [Parser] illegitimate syntax errors IProblems for Shapes demo Fixed 74575 - [Parser][CompleteParseASTFactory] forward symbol being set improperly for similar but different functions Fixed 74603 - [Parser] float function with float parameters has no body but should
This commit is contained in:
parent
4ab98b6ee9
commit
f5618e3847
6 changed files with 83 additions and 10 deletions
|
@ -2164,5 +2164,65 @@ public class CompleteParseASTTest extends CompleteParseBaseTest
|
|||
parse( writer.toString() );
|
||||
assertFalse( callback.getProblems().hasNext() );
|
||||
}
|
||||
|
||||
|
||||
public void testBug72692A() throws Exception
|
||||
{
|
||||
Writer writer = new StringWriter();
|
||||
writer.write( "extern double pow(double, double);\n");
|
||||
writer.write( "extern double pow2(double, double){}\n");
|
||||
writer.write( "namespace DS {\n");
|
||||
writer.write( "using ::pow;\n");
|
||||
writer.write( "using ::pow2;\n");
|
||||
writer.write( "}\n");
|
||||
writer.write( "using DS::pow;\n");
|
||||
writer.write( "using DS::pow2;\n");
|
||||
parse( writer.toString() );
|
||||
}
|
||||
|
||||
public void testBug72692B() throws Exception
|
||||
{
|
||||
Writer writer = new StringWriter();
|
||||
writer.write( "extern double pow(double, double);\n");
|
||||
writer.write( "namespace DS {\n");
|
||||
writer.write( "using ::pow;\n");
|
||||
writer.write( "inline float pow(float __x, float __y)\n" );
|
||||
writer.write( "{ return ::pow(static_cast<double>(__x), static_cast<double>(__y)); }\n" );
|
||||
writer.write( "}\n");
|
||||
writer.write( "using namespace DS;\n");
|
||||
writer.write( "float foo() { double d1 = 3.0, d2 = 4.0; return pow(d1, d2); }");
|
||||
parse( writer.toString() );
|
||||
}
|
||||
|
||||
public void testBug72692C() throws Exception
|
||||
{
|
||||
Writer writer = new StringWriter();
|
||||
writer.write( "extern double pow(double, double){}\n");
|
||||
writer.write( "namespace DS {\n");
|
||||
writer.write( "using ::pow;\n");
|
||||
writer.write( "}\n");
|
||||
writer.write( "using DS::pow;\n");
|
||||
parse( writer.toString() );
|
||||
}
|
||||
|
||||
|
||||
public void testBug74575A() throws Exception
|
||||
{
|
||||
Writer writer = new StringWriter();
|
||||
writer.write( "double pow(double, double);\n");
|
||||
writer.write( "float pow(float __x, float __y)\n" );
|
||||
writer.write( "{ return 0; }\n");
|
||||
Iterator i = parse( writer.toString() ).getDeclarations();
|
||||
IASTFunction doublePow = (IASTFunction) i.next();
|
||||
IASTFunction floatPow = (IASTFunction) i.next();
|
||||
assertFalse( i.hasNext() );
|
||||
assertEquals( floatPow.getName(), "pow" );
|
||||
assertEquals( doublePow.getName(), "pow");
|
||||
assertEquals( ((IASTSimpleTypeSpecifier)doublePow.getReturnType().getTypeSpecifier()).getType(), IASTSimpleTypeSpecifier.Type.DOUBLE );
|
||||
assertEquals( ((IASTSimpleTypeSpecifier)floatPow.getReturnType().getTypeSpecifier()).getType(), IASTSimpleTypeSpecifier.Type.FLOAT );
|
||||
assertFalse( doublePow.hasFunctionBody() );
|
||||
assertTrue( floatPow.hasFunctionBody() );
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -1172,7 +1172,7 @@ public class ParserSymbolTableTest extends TestCase {
|
|||
|
||||
assertEquals( using.getReferencedSymbols().get(0), f1 );
|
||||
|
||||
IParameterizedSymbol usingF = (IParameterizedSymbol)using.getDeclaredSymbols().get(0);
|
||||
IParameterizedSymbol usingF = (IParameterizedSymbol)using.getReferencedSymbols().get(0);
|
||||
|
||||
look = compUnit.lookup("A".toCharArray()); //$NON-NLS-1$
|
||||
assertEquals( look, A );
|
||||
|
@ -1210,13 +1210,10 @@ public class ParserSymbolTableTest extends TestCase {
|
|||
assertTrue( list.contains( f1 ) );
|
||||
assertTrue( list.contains( f2 ) );
|
||||
assertEquals( list.size(), 2 );
|
||||
|
||||
int index = list.indexOf( f2 );
|
||||
list = using.getDeclaredSymbols();
|
||||
|
||||
look = bar.unqualifiedFunctionLookup( "f".toCharArray(), paramList ); //$NON-NLS-1$
|
||||
assertTrue( look != null );
|
||||
assertEquals( look, list.get( index ) );
|
||||
assertEquals( look, f2);
|
||||
assertEquals( table.getTypeInfoProvider().numAllocated(), 0 );
|
||||
}
|
||||
|
||||
|
|
|
@ -136,7 +136,7 @@ public class ASTFunction extends ASTScope implements IASTFunction
|
|||
*/
|
||||
public void setHasFunctionBody(boolean b)
|
||||
{
|
||||
hasFunctionBody = true;
|
||||
hasFunctionBody = b;
|
||||
}
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.parser.ast.IASTFunction#hasFunctionBody()
|
||||
|
|
|
@ -1969,8 +1969,10 @@ public class CompleteParseASTFactory extends BaseASTFactory implements IASTFacto
|
|||
type = ITypeInfo.t_bool;
|
||||
else if( kind == IASTSimpleTypeSpecifier.Type.CHAR )
|
||||
type = ITypeInfo.t_char;
|
||||
else if( kind == IASTSimpleTypeSpecifier.Type.DOUBLE ||kind == IASTSimpleTypeSpecifier.Type.FLOAT )
|
||||
else if( kind == IASTSimpleTypeSpecifier.Type.DOUBLE )
|
||||
type = ITypeInfo.t_double;
|
||||
else if( kind == IASTSimpleTypeSpecifier.Type.FLOAT )
|
||||
type = ITypeInfo.t_float;
|
||||
else if( kind == IASTSimpleTypeSpecifier.Type.INT )
|
||||
type = ITypeInfo.t_int;
|
||||
else if( kind == IASTSimpleTypeSpecifier.Type.VOID )
|
||||
|
@ -2187,8 +2189,12 @@ public class CompleteParseASTFactory extends BaseASTFactory implements IASTFacto
|
|||
symbol = functionDeclaration;
|
||||
}
|
||||
|
||||
ASTFunction function = new ASTFunction( symbol, nameEndOffset, parameters, returnType, exception, startOffset, startLine, nameOffset, nameLine, ownerTemplate, references, previouslyDeclared, hasFunctionTryBlock, isFriend, filename );
|
||||
attachSymbolExtension(symbol, function, isFunctionDefinition);
|
||||
ASTFunction function = new ASTFunction( symbol, nameEndOffset, parameters, returnType, exception, startOffset, startLine, nameOffset, nameLine, ownerTemplate, references, previouslyDeclared, hasFunctionTryBlock, isFriend, filename );
|
||||
|
||||
attachSymbolExtension(symbol, function, isFunctionDefinition);
|
||||
|
||||
function.setHasFunctionBody(isFunctionDefinition);
|
||||
|
||||
return function;
|
||||
}
|
||||
|
||||
|
|
|
@ -400,6 +400,10 @@ public class ContainerSymbol extends BasicSymbol implements IContainerSymbol {
|
|||
addedUsingToContained = true;
|
||||
}
|
||||
clone = (ISymbol) symbol.clone(); //7.3.3-9
|
||||
|
||||
clone.setForwardSymbol(symbol);
|
||||
clone.setIsForwardDeclaration(true);
|
||||
|
||||
addSymbol( clone );
|
||||
} else {
|
||||
throw new ParserSymbolTableException( ParserSymbolTableException.r_InvalidUsing );
|
||||
|
|
|
@ -487,7 +487,7 @@ public class ParserSymbolTable {
|
|||
|
||||
if( foundSymbol.isType( ITypeInfo.t_function ) ){
|
||||
if( foundSymbol.isForwardDeclaration() && foundSymbol.getForwardSymbol() != null &&
|
||||
foundSymbol.getForwardSymbol().getContainingSymbol() == foundSymbol.getContainingSymbol() )
|
||||
!foundSymbol.isTemplateInstance() && foundSymbol.getForwardSymbol().getContainingSymbol() != null)
|
||||
{
|
||||
foundSymbol = foundSymbol.getForwardSymbol();
|
||||
}
|
||||
|
@ -821,6 +821,12 @@ public class ParserSymbolTable {
|
|||
return true;
|
||||
newType = newSymbol.getType();
|
||||
}
|
||||
|
||||
// handle reverse-forward 'using' decls
|
||||
if( newSymbol.isForwardDeclaration() ){
|
||||
if( newSymbol.getForwardSymbol() == origSymbol )
|
||||
return true;
|
||||
}
|
||||
|
||||
//handle forward decls
|
||||
if( origSymbol.isForwardDeclaration() ){
|
||||
|
|
Loading…
Add table
Reference in a new issue