mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-07-28 03:15:33 +02:00
Bug 486140 - Cast expression with label reference expression as operand
Change-Id: I77d8e7dabc64f68818f4222ffe3d6ba7eebae542
This commit is contained in:
parent
20cebd8f6f
commit
4c1a6e0ccd
2 changed files with 37 additions and 1 deletions
|
@ -7569,6 +7569,41 @@ public class AST2Tests extends AST2TestBase {
|
|||
parseAndCheckBindings(true);
|
||||
}
|
||||
|
||||
// void f() {
|
||||
// unsigned long long labelPtr;
|
||||
// labelPtr = (unsigned long long) &&L;
|
||||
// goto *labelPtr;
|
||||
// L:
|
||||
// return;
|
||||
// }
|
||||
public void testExpressionLabelReferenceCast_486140a() throws Exception {
|
||||
// Here, the cast-expression is the only valid parse.
|
||||
parseAndCheckBindings(true);
|
||||
}
|
||||
|
||||
// typedef unsigned long long ULL;
|
||||
// void f() {
|
||||
// unsigned long long labelPtr;
|
||||
// labelPtr = (ULL) &&L;
|
||||
// goto *labelPtr;
|
||||
// L:
|
||||
// return;
|
||||
// }
|
||||
public void testExpressionLabelReferenceCast_486140b() throws Exception {
|
||||
// Here, the cast-expression and the binary-expression are both
|
||||
// syntactically valid, but the correct parse is the cast-expression.
|
||||
parseAndCheckBindings(true);
|
||||
}
|
||||
|
||||
// int test(int waldo, int other) {
|
||||
// return (waldo) && other;
|
||||
// }
|
||||
public void testBinaryExprNotMisparsedAsCast_486140() throws Exception {
|
||||
// Again cast-expression and binary-expression are both syntactically
|
||||
// valid, but this time the correct parse is binary-expression.
|
||||
parseAndCheckBindings(true);
|
||||
}
|
||||
|
||||
// int version = 0;
|
||||
// int NextVersion() {
|
||||
// return __atomic_add_fetch(&version, 1, 5);
|
||||
|
|
|
@ -1097,6 +1097,7 @@ public abstract class AbstractGNUSourceCodeParser implements ISourceCodeParser {
|
|||
break;
|
||||
case IToken.tAND:
|
||||
op= IASTBinaryExpression.op_logicalAnd;
|
||||
unaryOp = IASTUnaryExpression.op_labelReference;
|
||||
break;
|
||||
case IToken.tBITOR:
|
||||
op= IASTBinaryExpression.op_binaryOr;
|
||||
|
@ -1269,6 +1270,7 @@ public abstract class AbstractGNUSourceCodeParser implements ISourceCodeParser {
|
|||
// ambiguity with unary operator
|
||||
case IToken.tPLUS: case IToken.tMINUS:
|
||||
case IToken.tSTAR: case IToken.tAMPER:
|
||||
case IToken.tAND:
|
||||
final int operatorOffset = LA(1).getOffset();
|
||||
IToken markEnd= mark();
|
||||
backup(mark);
|
||||
|
@ -2597,7 +2599,6 @@ public abstract class AbstractGNUSourceCodeParser implements ISourceCodeParser {
|
|||
skipBrackets(IToken.tLPAREN, IToken.tRPAREN, IToken.tSEMI);
|
||||
switch (LTcatchEOF(1)) {
|
||||
case IToken.tAMPERASSIGN:
|
||||
case IToken.tAND:
|
||||
case IToken.tARROW:
|
||||
case IToken.tARROWSTAR:
|
||||
case IToken.tASSIGN:
|
||||
|
|
Loading…
Add table
Reference in a new issue