1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-07-29 20:05:35 +02:00
This commit is contained in:
John Camelon 2004-06-28 12:27:09 +00:00
parent c95ad28dcb
commit 942779ea3e
5 changed files with 40 additions and 10 deletions

View file

@ -20,7 +20,6 @@ import org.eclipse.cdt.core.parser.ast.ASTClassKind;
import org.eclipse.cdt.core.parser.ast.ASTPointerOperator;
import org.eclipse.cdt.core.parser.ast.ASTUtil;
import org.eclipse.cdt.core.parser.ast.IASTASMDefinition;
import org.eclipse.cdt.core.parser.ast.IASTAbstractDeclaration;
import org.eclipse.cdt.core.parser.ast.IASTAbstractTypeSpecifierDeclaration;
import org.eclipse.cdt.core.parser.ast.IASTBaseSpecifier;
import org.eclipse.cdt.core.parser.ast.IASTClassReference;
@ -2022,4 +2021,19 @@ public class CompleteParseASTTest extends CompleteParseBaseTest
simple = (IASTSimpleTypeSpecifier) y.getAbstractDeclaration().getTypeSpecifier();
assertEquals( simple.getTypeSpecifier(), yType );
}
public void testBug60407() throws Exception
{
Writer writer = new StringWriter();
writer.write( "struct ZZZ { int x, y, z; };\n" );
writer.write( "typedef struct ZZZ _FILE;\n" );
writer.write( "typedef _FILE FILE;\n" );
writer.write( "static void static_function(FILE * lcd){}\n" );
writer.write( "int main(int argc, char **argv) {\n" );
writer.write( "FILE * file = 0;\n" );
writer.write( "static_function( file );\n" );
writer.write( "return 0;\n" );
writer.write( "}\n" );
parse( writer.toString() );
}
}

View file

@ -314,4 +314,21 @@ public class SelectionParseTest extends SelectionParseBaseTest {
int startIndex = code.indexOf( "X anA"); //$NON-NLS-1$
parse( code, startIndex, startIndex + 1 );
}
public void testBug60407() throws Exception
{
Writer writer = new StringWriter();
writer.write( "struct ZZZ { int x, y, z; };\n" ); //$NON-NLS-1$
writer.write( "typedef struct ZZZ _FILE;\n" ); //$NON-NLS-1$
writer.write( "typedef _FILE FILE;\n" ); //$NON-NLS-1$
writer.write( "static void static_function(FILE * lcd){}\n" ); //$NON-NLS-1$
writer.write( "int main(int argc, char **argv) {\n" ); //$NON-NLS-1$
writer.write( "FILE * file = 0;\n" ); //$NON-NLS-1$
writer.write( "static_function( file );\n" ); //$NON-NLS-1$
writer.write( "return 0;\n" ); //$NON-NLS-1$
writer.write( "}\n" ); //$NON-NLS-1$
String code = writer.toString();
int startIndex = code.indexOf( "static_function( file )"); //$NON-NLS-1$
parse( code, startIndex, startIndex + "static_function".length() ); //$NON-NLS-1$
}
}

View file

@ -3541,7 +3541,9 @@ public class CompleteParseASTFactory extends BaseASTFactory implements IASTFacto
if( reference instanceof ASTExpression )
{
ASTExpression expression = (ASTExpression) reference;
if( expression.getExpressionKind() == IASTExpression.Kind.ID_EXPRESSION )
final String dupleAsString = duple.toString();
if( expression.getExpressionKind() == IASTExpression.Kind.ID_EXPRESSION &&
expression.getLHSExpression().equals( dupleAsString ))
{
try {
s = lookupQualifiedName( scopeToSymbol( scope ), duple, null, false );
@ -3583,7 +3585,8 @@ public class CompleteParseASTFactory extends BaseASTFactory implements IASTFacto
}
}
else if( expression.getExpressionKind() == Kind.POSTFIX_FUNCTIONCALL )
else if( expression.getExpressionKind() == Kind.POSTFIX_FUNCTIONCALL &&
expression.getLHSExpression().getIdExpression().equals( dupleAsString ))
{
try {
ISymbol symbol = getExpressionSymbol( scope, expression.getExpressionKind(), expression.getLHSExpression(), expression.getRHSExpression(), null, null );

View file

@ -1583,14 +1583,9 @@ public class ParserSymbolTable {
if( source.isType( TypeInfo.t_type ) ){
source = getFlatTypeInfo( source, null );
}
if( target.isType( TypeInfo.t_type ) ){
ISymbol symbol = target.getTypeSymbol();
if( symbol != null && symbol.isForwardDeclaration() && symbol.getTypeSymbol() != null ){
target = new TypeInfo( target );
target.setType( TypeInfo.t_type );
target.setTypeSymbol( symbol.getTypeSymbol() );
}
target = getFlatTypeInfo( target, null );
}
Cost cost = new Cost( provider, source, target );

View file

@ -185,6 +185,7 @@ public class OpenDeclarationsAction extends SelectionParseAction implements IUpd
}
private String findProjectName(IFile resourceFile) {
if( resourceFile == null ) return ""; //$NON-NLS-1$
IProject [] projects = ResourcesPlugin.getWorkspace().getRoot().getProjects();
for( int i = 0; i < projects.length; ++i )
{