1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-07-23 17:05:26 +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();
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.tEOC:
endoffset[0]= consume().getEndOffset();
typeIdLA = LA(1);
break;
default:
typeId = null;
}
}
if (typeId != null) {
else {
endoffset[0]= calculateEndOffset(typeId);
typeIdLA = LA(1);
if (!typeIdWithParentheses) {
endoffset[0]= calculateEndOffset(typeId);
}
}
}
} catch (BacktrackException e) { }
@ -1784,8 +1783,11 @@ public abstract class AbstractGNUSourceCodeParser implements ISourceCodeParser {
endoffset[0]= calculateEndOffset(unaryExpression);
return new IASTNode[] {unaryExpression};
}
if (unaryExpression != null && typeId != null && typeIdLA == unaryExpressionLA) {
return new IASTNode[] {typeId, unaryExpression};
if (unaryExpression != null && typeId != null) {
if (typeIdLA == unaryExpressionLA) {
return new IASTNode[] {typeId, unaryExpression};
}
return new IASTNode[] {unaryExpression};
}
return EMPTY_NODE_ARRAY;