mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-06-30 21:55:31 +02:00
Fixed Bug 95720 [Ambiguity] Cast Expression ambiguity
This commit is contained in:
parent
60679c4044
commit
cf31ad398a
2 changed files with 20 additions and 0 deletions
|
@ -3006,6 +3006,19 @@ public class AST2Tests extends AST2BaseTest {
|
|||
assertNoProblemBindings(nameResolver);
|
||||
}
|
||||
|
||||
public void testBug95720() throws Exception {
|
||||
StringBuffer buffer = new StringBuffer();
|
||||
buffer.append( "void func() {\n" );
|
||||
buffer.append( " int i=0;\n" );
|
||||
buffer.append( "i= i&0x00ff;\n" );
|
||||
buffer.append( "i= (i)&0x00ff;\n" );
|
||||
buffer.append( "}\n" );
|
||||
IASTTranslationUnit tu = parse( buffer.toString(), ParserLanguage.C );
|
||||
CNameCollector nameResolver = new CNameCollector();
|
||||
tu.accept(nameResolver);
|
||||
assertNoProblemBindings(nameResolver);
|
||||
}
|
||||
|
||||
protected void assertNoProblemBindings(CNameCollector col) {
|
||||
Iterator i = col.nameList.iterator();
|
||||
while (i.hasNext()) {
|
||||
|
|
|
@ -37,6 +37,7 @@ 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;
|
||||
|
@ -894,8 +895,14 @@ public abstract class AbstractGNUSourceCodeParser implements ISourceCodeParser {
|
|||
|
||||
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));
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue