1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-07-25 01:45:33 +02:00

Specific sizeof expression, bug 227122.

This commit is contained in:
Markus Schorn 2008-04-15 13:55:26 +00:00
parent 77a468323d
commit 7f62ac03bf
2 changed files with 16 additions and 6 deletions

View file

@ -4537,4 +4537,12 @@ public class AST2Tests extends AST2BaseTest {
final String code = getAboveComment(); final String code = getAboveComment();
parseAndCheckBindings(code, ParserLanguage.CPP, true); parseAndCheckBindings(code, ParserLanguage.CPP, true);
} }
// char buf[256];
// int x= sizeof(buf)[0];
public void testSizeofUnaryWithParenthesis_Bug227122() throws Exception {
final String code = getAboveComment();
parseAndCheckBindings(code, ParserLanguage.C);
parseAndCheckBindings(code, ParserLanguage.CPP);
}
} }

View file

@ -1753,16 +1753,15 @@ public abstract class AbstractGNUSourceCodeParser implements ISourceCodeParser {
case IToken.tRPAREN: case IToken.tRPAREN:
case IToken.tEOC: case IToken.tEOC:
endoffset[0]= consume().getEndOffset(); endoffset[0]= consume().getEndOffset();
typeIdLA = LA(1);
break; break;
default: default:
typeId = null; typeId = null;
} }
} }
if (typeId != null) { else {
endoffset[0]= calculateEndOffset(typeId);
typeIdLA = LA(1); typeIdLA = LA(1);
if (!typeIdWithParentheses) {
endoffset[0]= calculateEndOffset(typeId);
}
} }
} }
} catch (BacktrackException e) { } } catch (BacktrackException e) { }
@ -1784,8 +1783,11 @@ public abstract class AbstractGNUSourceCodeParser implements ISourceCodeParser {
endoffset[0]= calculateEndOffset(unaryExpression); endoffset[0]= calculateEndOffset(unaryExpression);
return new IASTNode[] {unaryExpression}; return new IASTNode[] {unaryExpression};
} }
if (unaryExpression != null && typeId != null && typeIdLA == unaryExpressionLA) { if (unaryExpression != null && typeId != null) {
return new IASTNode[] {typeId, unaryExpression}; if (typeIdLA == unaryExpressionLA) {
return new IASTNode[] {typeId, unaryExpression};
}
return new IASTNode[] {unaryExpression};
} }
return EMPTY_NODE_ARRAY; return EMPTY_NODE_ARRAY;