mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-23 22:52:11 +02:00
Fixed Bug 88662 - [DOM] Problem parsing postfix expression
This commit is contained in:
parent
e2e1f585eb
commit
17481123ab
2 changed files with 18 additions and 6 deletions
|
@ -55,6 +55,7 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTConversionName;
|
|||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTOperatorName;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTPointerToMember;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTQualifiedName;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTSimpleTypeConstructorExpression;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTWhileStatement;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPBinding;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPBlockScope;
|
||||
|
@ -3267,6 +3268,12 @@ public class AST2CPPTests extends AST2BaseTest {
|
|||
assertTrue(((ICPPASTQualifiedName)col.getName(16)).isConversionOrOperator());
|
||||
}
|
||||
|
||||
|
||||
public void testBug88662() throws Exception {
|
||||
IASTTranslationUnit tu = parse( "int foo() { return int();}", ParserLanguage.CPP ); //$NON-NLS-1$
|
||||
IASTReturnStatement returnStatement = (IASTReturnStatement) ((IASTCompoundStatement)((IASTFunctionDefinition)tu.getDeclarations()[0]).getBody()).getStatements()[0];
|
||||
ICPPASTSimpleTypeConstructorExpression expression = (ICPPASTSimpleTypeConstructorExpression) returnStatement.getReturnValue();
|
||||
assertEquals( expression.getInitialValue(), null );
|
||||
assertEquals( expression.getSimpleType(), ICPPASTSimpleTypeConstructorExpression.t_int );
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1623,15 +1623,20 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser {
|
|||
int startingOffset = LA(1).getOffset();
|
||||
consume();
|
||||
consume(IToken.tLPAREN);
|
||||
IASTExpression operand = expression();
|
||||
IASTExpression operand = null;
|
||||
if( LT(1) != IToken.tRPAREN )
|
||||
operand = expression();
|
||||
int l = consume(IToken.tRPAREN).getEndOffset();
|
||||
ICPPASTSimpleTypeConstructorExpression result = createSimpleTypeConstructorExpression();
|
||||
((ASTNode) result).setOffsetAndLength(startingOffset, l - startingOffset);
|
||||
result.setSimpleType(operator);
|
||||
result.setInitialValue(operand);
|
||||
operand.setParent(result);
|
||||
operand
|
||||
.setPropertyInParent(ICPPASTSimpleTypeConstructorExpression.INITIALIZER_VALUE);
|
||||
if( operand != null )
|
||||
{
|
||||
result.setInitialValue(operand);
|
||||
operand.setParent(result);
|
||||
operand
|
||||
.setPropertyInParent(ICPPASTSimpleTypeConstructorExpression.INITIALIZER_VALUE);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue