mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-07-29 20:05:35 +02:00
Removed more warnings. Fixed https://bugs.eclipse.org/bugs/show_bug.cgi?id=66543.
This commit is contained in:
parent
47dd3dc302
commit
b7caa59093
7 changed files with 36 additions and 18 deletions
|
@ -1196,4 +1196,23 @@ public class CompletionParseTest extends CompletionParseBaseTest {
|
|||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public void testBug66543() throws Exception
|
||||
{
|
||||
Writer writer = new StringWriter();
|
||||
writer.write( "struct packet { int a; int b; };\n" ); //$NON-NLS-1$
|
||||
writer.write( "struct packet buffer[5];\n" ); //$NON-NLS-1$
|
||||
writer.write( "int main(int argc, char **argv) {\n" ); //$NON-NLS-1$
|
||||
writer.write( " buffer[2]." ); //$NON-NLS-1$
|
||||
String code = writer.toString();
|
||||
IASTCompletionNode node = parse( code, code.indexOf( "[2].") + 4 ); //$NON-NLS-1$
|
||||
assertNotNull( node );
|
||||
assertNotNull( node.getCompletionContext() );
|
||||
IASTNode.LookupKind [] kinds = new LookupKind[ 1 ];
|
||||
kinds[0] = LookupKind.FIELDS;
|
||||
ILookupResult result = node.getCompletionScope().lookup( node.getCompletionPrefix(), kinds, node.getCompletionContext(), node.getFunctionParameters() );
|
||||
assertNotNull( result );
|
||||
assertEquals( result.getResultsSize(), 2 );
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -82,8 +82,7 @@ public class ASTCodeScope extends ASTScope implements IASTCodeScope {
|
|||
{
|
||||
if(declarations != null)
|
||||
return declarations.iterator();
|
||||
else
|
||||
return super.getDeclarations();
|
||||
return super.getDeclarations();
|
||||
}
|
||||
|
||||
public void addDeclaration(IASTDeclaration declaration)
|
||||
|
|
|
@ -330,8 +330,7 @@ public class ASTFunction extends ASTScope implements IASTFunction
|
|||
{
|
||||
if(declarations != null)
|
||||
return declarations.iterator();
|
||||
else
|
||||
return super.getDeclarations();
|
||||
return super.getDeclarations();
|
||||
}
|
||||
|
||||
public void addDeclaration(IASTDeclaration declaration)
|
||||
|
|
|
@ -1636,6 +1636,7 @@ public class CompleteParseASTFactory extends BaseASTFactory implements IASTFacto
|
|||
if ((info != null))
|
||||
{
|
||||
info.addOperatorExpression( TypeInfo.OperatorExpression.subscript );
|
||||
info = info.getFinalType( null );
|
||||
}else {
|
||||
handleProblem( scope, IProblem.SEMANTIC_MALFORMED_EXPRESSION, null );
|
||||
}
|
||||
|
|
|
@ -19,7 +19,6 @@ import java.util.List;
|
|||
import org.eclipse.cdt.core.parser.GCCKeywords;
|
||||
import org.eclipse.cdt.core.parser.ITokenDuple;
|
||||
import org.eclipse.cdt.core.parser.ParserMode;
|
||||
import org.eclipse.cdt.core.parser.ast.ASTExpressionEvaluationException;
|
||||
import org.eclipse.cdt.core.parser.ast.ASTUtil;
|
||||
import org.eclipse.cdt.core.parser.ast.IASTExpression;
|
||||
import org.eclipse.cdt.core.parser.ast.IASTScope;
|
||||
|
@ -29,7 +28,6 @@ import org.eclipse.cdt.core.parser.ast.IASTExpression.Kind;
|
|||
import org.eclipse.cdt.core.parser.ast.gcc.IASTGCCExpression;
|
||||
import org.eclipse.cdt.internal.core.parser.ast.GCCASTExtension;
|
||||
import org.eclipse.cdt.internal.core.parser.ast.complete.ASTBinaryExpression;
|
||||
import org.eclipse.cdt.internal.core.parser.ast.complete.ASTIdExpression;
|
||||
import org.eclipse.cdt.internal.core.parser.ast.complete.ASTTypeIdExpression;
|
||||
import org.eclipse.cdt.internal.core.parser.ast.complete.ASTUnaryExpression;
|
||||
import org.eclipse.cdt.internal.core.parser.ast.complete.ExpressionFactory;
|
||||
|
@ -59,10 +57,10 @@ public class GCCASTCompleteExtension extends GCCASTExtension {
|
|||
{
|
||||
return new ASTBinaryExpression( kind, references, lhs, rhs ){
|
||||
public String toString(){
|
||||
IASTExpression.Kind kind = getExpressionKind();
|
||||
IASTExpression.Kind k = getExpressionKind();
|
||||
StringBuffer buffer = new StringBuffer();
|
||||
buffer.append( ASTUtil.getExpressionString( getLHSExpression() ) );
|
||||
if( kind == IASTGCCExpression.Kind.RELATIONAL_MAX )
|
||||
if( k == IASTGCCExpression.Kind.RELATIONAL_MAX )
|
||||
buffer.append( " >? " ); //$NON-NLS-1$
|
||||
else
|
||||
buffer.append( " <? " ); //$NON-NLS-1$
|
||||
|
@ -77,9 +75,9 @@ public class GCCASTCompleteExtension extends GCCASTExtension {
|
|||
{
|
||||
return new ASTUnaryExpression( kind, references, lhs ){
|
||||
public String toString(){
|
||||
IASTExpression.Kind kind = getExpressionKind();
|
||||
IASTExpression.Kind k = getExpressionKind();
|
||||
StringBuffer buffer = new StringBuffer();
|
||||
if( kind == IASTGCCExpression.Kind.UNARY_ALIGNOF_UNARYEXPRESSION )
|
||||
if( k == IASTGCCExpression.Kind.UNARY_ALIGNOF_UNARYEXPRESSION )
|
||||
buffer.append( GCCKeywords.__ALIGNOF__ );
|
||||
else
|
||||
buffer.append( GCCKeywords.TYPEOF );
|
||||
|
@ -95,9 +93,9 @@ public class GCCASTCompleteExtension extends GCCASTExtension {
|
|||
{
|
||||
return new ASTTypeIdExpression( kind, references, typeId ){
|
||||
public String toString(){
|
||||
IASTExpression.Kind kind = getExpressionKind();
|
||||
IASTExpression.Kind k = getExpressionKind();
|
||||
StringBuffer buffer = new StringBuffer();
|
||||
if( kind == IASTGCCExpression.Kind.UNARY_ALIGNOF_TYPEID )
|
||||
if( k == IASTGCCExpression.Kind.UNARY_ALIGNOF_TYPEID )
|
||||
buffer.append( GCCKeywords.__ALIGNOF__ );
|
||||
else
|
||||
buffer.append( GCCKeywords.TYPEOF );
|
||||
|
|
|
@ -75,10 +75,10 @@ public class GCCASTExpressionExtension extends GCCASTExtension {
|
|||
{
|
||||
return new ASTBinaryExpression( kind, lhs, rhs ){
|
||||
public String toString(){
|
||||
IASTExpression.Kind kind = getExpressionKind();
|
||||
IASTExpression.Kind k = getExpressionKind();
|
||||
StringBuffer buffer = new StringBuffer();
|
||||
buffer.append( ASTUtil.getExpressionString( getLHSExpression() ) );
|
||||
if( kind == IASTGCCExpression.Kind.RELATIONAL_MAX )
|
||||
if( k == IASTGCCExpression.Kind.RELATIONAL_MAX )
|
||||
buffer.append( " >? " ); //$NON-NLS-1$
|
||||
else
|
||||
buffer.append( " <? " ); //$NON-NLS-1$
|
||||
|
@ -93,9 +93,9 @@ public class GCCASTExpressionExtension extends GCCASTExtension {
|
|||
{
|
||||
return new ASTUnaryExpression( kind, lhs ){
|
||||
public String toString(){
|
||||
IASTExpression.Kind kind = getExpressionKind();
|
||||
IASTExpression.Kind k = getExpressionKind();
|
||||
StringBuffer buffer = new StringBuffer();
|
||||
if( kind == IASTGCCExpression.Kind.UNARY_ALIGNOF_UNARYEXPRESSION )
|
||||
if( k == IASTGCCExpression.Kind.UNARY_ALIGNOF_UNARYEXPRESSION )
|
||||
buffer.append( GCCKeywords.__ALIGNOF__ );
|
||||
else
|
||||
buffer.append( GCCKeywords.TYPEOF );
|
||||
|
@ -111,9 +111,9 @@ public class GCCASTExpressionExtension extends GCCASTExtension {
|
|||
{
|
||||
return new ASTTypeIdExpression( kind, typeId ){
|
||||
public String toString(){
|
||||
IASTExpression.Kind kind = getExpressionKind();
|
||||
IASTExpression.Kind k = getExpressionKind();
|
||||
StringBuffer buffer = new StringBuffer();
|
||||
if( kind == IASTGCCExpression.Kind.UNARY_ALIGNOF_TYPEID )
|
||||
if( k == IASTGCCExpression.Kind.UNARY_ALIGNOF_TYPEID )
|
||||
buffer.append( GCCKeywords.__ALIGNOF__ );
|
||||
else
|
||||
buffer.append( GCCKeywords.TYPEOF );
|
||||
|
|
|
@ -2137,6 +2137,8 @@ public class ParserSymbolTable {
|
|||
returnInfo.copy( topInfo );
|
||||
} else
|
||||
returnInfo = new TypeInfo( topInfo );
|
||||
returnInfo.applyOperatorExpressions( topInfo.getOperatorExpressions() );
|
||||
returnInfo.getOperatorExpressions().clear();
|
||||
}
|
||||
|
||||
return returnInfo;
|
||||
|
|
Loading…
Add table
Reference in a new issue