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

Fixed Bug 100408 [ProblemBinding] invalid ProblemBinding on (x)*3;

This commit is contained in:
John Camelon 2005-06-16 17:35:34 +00:00
parent 3915950c5d
commit 1b6e13f52d
7 changed files with 61 additions and 15 deletions

View file

@ -4756,4 +4756,11 @@ public class AST2CPPTests extends AST2BaseTest {
assertTrue(((IASTIdExpression)((IASTFunctionCallExpression)((IASTReturnStatement)((IASTCompoundStatement)((IASTFunctionDefinition)tu.getDeclarations()[1]).getBody()).getStatements()[0]).getReturnValue()).getFunctionNameExpression()).getName().resolveBinding() instanceof IFunction);
}
public void testBug100408() throws Exception {
IASTTranslationUnit tu = parse( "int foo() { int x=1; (x)*3; }", ParserLanguage.CPP );
CPPNameCollector col = new CPPNameCollector();
tu.accept( col );
assertNoProblemBindings( col );
}
}

View file

@ -3195,4 +3195,12 @@ public class AST2Tests extends AST2BaseTest {
assertSame( a1, a2 );
assertNotSame( a2, a3 );
}
public void testBug100408() throws Exception {
IASTTranslationUnit tu = parse( "int foo() { int x=1; (x)*3; }", ParserLanguage.C );
CNameCollector col = new CNameCollector();
tu.accept( col );
assertNoProblemBindings( col );
}
}

View file

@ -0,0 +1,10 @@
#Thu Jun 16 13:15:47 EDT 2005
eclipse.preferences.version=1
org.eclipse.jdt.core.codeComplete.argumentPrefixes=
org.eclipse.jdt.core.codeComplete.argumentSuffixes=
org.eclipse.jdt.core.codeComplete.fieldPrefixes=
org.eclipse.jdt.core.codeComplete.fieldSuffixes=
org.eclipse.jdt.core.codeComplete.localPrefixes=
org.eclipse.jdt.core.codeComplete.localSuffixes=
org.eclipse.jdt.core.codeComplete.staticFieldPrefixes=
org.eclipse.jdt.core.codeComplete.staticFieldSuffixes=

View file

@ -0,0 +1,6 @@
#Thu Jun 16 13:15:47 EDT 2005
eclipse.preferences.version=1
internal.default.compliance=default
org.eclipse.jdt.ui.exception.name=e
org.eclipse.jdt.ui.gettersetter.use.is=true
org.eclipse.jdt.ui.overrideannotation=true

View file

@ -37,7 +37,6 @@ import org.eclipse.cdt.core.dom.ast.IASTGotoStatement;
import org.eclipse.cdt.core.dom.ast.IASTIdExpression;
import org.eclipse.cdt.core.dom.ast.IASTIfStatement;
import org.eclipse.cdt.core.dom.ast.IASTLabelStatement;
import org.eclipse.cdt.core.dom.ast.IASTLiteralExpression;
import org.eclipse.cdt.core.dom.ast.IASTName;
import org.eclipse.cdt.core.dom.ast.IASTNamedTypeSpecifier;
import org.eclipse.cdt.core.dom.ast.IASTNode;
@ -893,20 +892,6 @@ public abstract class AbstractGNUSourceCodeParser implements ISourceCodeParser {
*/
protected abstract IASTConditionalExpression createConditionalExpression();
protected IASTExpression unaryOperatorCastExpression(int operator)
throws EndOfFileException, BacktrackException {
IToken mark = mark();
int offset = consume().getOffset();
IASTExpression castExpression = castExpression();
if( castExpression instanceof IASTLiteralExpression && operator == IASTUnaryExpression.op_amper )
{
backup( mark );
throwBacktrack( mark );
}
return buildUnaryExpression(operator, castExpression, offset,
calculateEndOffset(castExpression));
}
/**
* @param operator
* @param operand

View file

@ -2778,5 +2778,18 @@ public class GNUCSourceParser extends AbstractGNUSourceCodeParser {
return result;
}
protected IASTExpression unaryOperatorCastExpression(int operator) throws EndOfFileException, BacktrackException {
IToken mark = mark();
int offset = consume().getOffset();
IASTExpression castExpression = castExpression();
if( castExpression instanceof IASTLiteralExpression && ( operator == IASTUnaryExpression.op_amper || operator == IASTUnaryExpression.op_star ) )
{
backup( mark );
throwBacktrack( mark );
}
return buildUnaryExpression(operator, castExpression, offset,
calculateEndOffset(castExpression));
}
}

View file

@ -5311,4 +5311,21 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser {
protected IASTDeclaration simpleDeclaration() throws BacktrackException, EndOfFileException {
return simpleDeclarationStrategyUnion();
}
protected IASTExpression unaryOperatorCastExpression(int operator) throws EndOfFileException, BacktrackException {
IToken mark = mark();
int offset = consume().getOffset();
IASTExpression castExpression = castExpression();
if( castExpression instanceof IASTLiteralExpression && ( operator == IASTUnaryExpression.op_amper || operator == IASTUnaryExpression.op_star ) )
{
IASTLiteralExpression literal = (IASTLiteralExpression) castExpression;
if( literal.getKind() != ICPPASTLiteralExpression.lk_this )
{
backup( mark );
throwBacktrack( mark );
}
}
return buildUnaryExpression(operator, castExpression, offset,
calculateEndOffset(castExpression));
}
}