mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-29 19:45:01 +02:00
[98528] Fixed EOC handling in sizeof and cast expression in C and the cpp style condition.
This commit is contained in:
parent
4732db0ae8
commit
892cf79f6e
3 changed files with 31 additions and 8 deletions
|
@ -1485,9 +1485,12 @@ public abstract class AbstractGNUSourceCodeParser implements ISourceCodeParser {
|
||||||
result.setTypeId(typeId);
|
result.setTypeId(typeId);
|
||||||
typeId.setParent(result);
|
typeId.setParent(result);
|
||||||
typeId.setPropertyInParent(IASTCastExpression.TYPE_ID);
|
typeId.setPropertyInParent(IASTCastExpression.TYPE_ID);
|
||||||
result.setOperand(subExpression);
|
if (subExpression != null) { // which it can be in a completion
|
||||||
subExpression.setParent(result);
|
result.setOperand(subExpression);
|
||||||
subExpression.setPropertyInParent(IASTCastExpression.OPERAND);
|
subExpression.setParent(result);
|
||||||
|
subExpression.setPropertyInParent(IASTCastExpression.OPERAND);
|
||||||
|
}
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -819,8 +819,16 @@ public class GNUCSourceParser extends AbstractGNUSourceCodeParser {
|
||||||
try {
|
try {
|
||||||
try {
|
try {
|
||||||
typeId = typeId(false);
|
typeId = typeId(false);
|
||||||
consume(IToken.tRPAREN);
|
switch (LT(1)) {
|
||||||
castExpression = castExpression();
|
case IToken.tRPAREN:
|
||||||
|
consume();
|
||||||
|
castExpression = castExpression();
|
||||||
|
break;
|
||||||
|
case IToken.tEOC:
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
throw backtrack;
|
||||||
|
}
|
||||||
} catch (BacktrackException bte) {
|
} catch (BacktrackException bte) {
|
||||||
backup(mark);
|
backup(mark);
|
||||||
throwBacktrack(bte);
|
throwBacktrack(bte);
|
||||||
|
@ -828,7 +836,7 @@ public class GNUCSourceParser extends AbstractGNUSourceCodeParser {
|
||||||
|
|
||||||
return buildTypeIdUnaryExpression(IASTCastExpression.op_cast,
|
return buildTypeIdUnaryExpression(IASTCastExpression.op_cast,
|
||||||
typeId, castExpression, startingOffset,
|
typeId, castExpression, startingOffset,
|
||||||
calculateEndOffset(castExpression));
|
LT(1) == IToken.tEOC ? LA(1).getEndOffset() : calculateEndOffset(castExpression));
|
||||||
} catch (BacktrackException b) {
|
} catch (BacktrackException b) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -869,7 +877,14 @@ public class GNUCSourceParser extends AbstractGNUSourceCodeParser {
|
||||||
try {
|
try {
|
||||||
consume(IToken.tLPAREN);
|
consume(IToken.tLPAREN);
|
||||||
typeId = typeId(false);
|
typeId = typeId(false);
|
||||||
lastOffset = consume(IToken.tRPAREN).getEndOffset();
|
switch (LT(1)) {
|
||||||
|
case IToken.tRPAREN:
|
||||||
|
case IToken.tEOC:
|
||||||
|
lastOffset = consume().getEndOffset();
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
throw backtrack;
|
||||||
|
}
|
||||||
} catch (BacktrackException bt) {
|
} catch (BacktrackException bt) {
|
||||||
backup(mark);
|
backup(mark);
|
||||||
typeId = null;
|
typeId = null;
|
||||||
|
|
|
@ -5115,8 +5115,13 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser {
|
||||||
IToken mark = mark();
|
IToken mark = mark();
|
||||||
try {
|
try {
|
||||||
IASTExpression e = expression();
|
IASTExpression e = expression();
|
||||||
if (LT(1) != IToken.tRPAREN)
|
switch (LT(1)) {
|
||||||
|
case IToken.tRPAREN:
|
||||||
|
case IToken.tEOC:
|
||||||
|
return e;
|
||||||
|
default:
|
||||||
throwBacktrack(LA(1));
|
throwBacktrack(LA(1));
|
||||||
|
}
|
||||||
return e;
|
return e;
|
||||||
} catch (BacktrackException bt) {
|
} catch (BacktrackException bt) {
|
||||||
backup(mark);
|
backup(mark);
|
||||||
|
|
Loading…
Add table
Reference in a new issue