mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-23 22:52:11 +02:00
Correct parsing of typeof-expressions, bug 226492.
This commit is contained in:
parent
c9e25b268b
commit
7aab1dfa1c
3 changed files with 14 additions and 3 deletions
|
@ -4494,6 +4494,15 @@ public class AST2Tests extends AST2BaseTest {
|
|||
parseAndCheckBindings(code, ParserLanguage.CPP, true);
|
||||
}
|
||||
|
||||
// void func() {
|
||||
// typeof(__attribute__((regparm(3)))void (*)(int *)) a;
|
||||
// }
|
||||
public void testTypeofExpressionWithAttribute_Bug226492() throws Exception {
|
||||
final String code = getAboveComment();
|
||||
parseAndCheckBindings(code, ParserLanguage.C, true);
|
||||
parseAndCheckBindings(code, ParserLanguage.CPP, true);
|
||||
}
|
||||
|
||||
// void test(int count) {
|
||||
// switch(count) {
|
||||
// case 1 ... 3: break;
|
||||
|
|
|
@ -864,7 +864,7 @@ public abstract class AbstractGNUSourceCodeParser implements ISourceCodeParser {
|
|||
backup(m);
|
||||
d = typeId(false);
|
||||
if (d == null)
|
||||
throw new BacktrackException();
|
||||
throw e;
|
||||
}
|
||||
lastOffset = consume(IToken.tRPAREN).getEndOffset();
|
||||
} else {
|
||||
|
@ -2052,6 +2052,7 @@ public abstract class AbstractGNUSourceCodeParser implements ISourceCodeParser {
|
|||
|
||||
// gcc-special
|
||||
case IGCCToken.t_typeof:
|
||||
case IGCCToken.t__attribute__:
|
||||
|
||||
// content assist
|
||||
case IToken.tCOMPLETION:
|
||||
|
|
|
@ -418,13 +418,14 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser {
|
|||
if (templateArgListCount > 0) {
|
||||
// bug 104706, don't allow usage of logical operators in template argument lists.
|
||||
if (expr instanceof IASTConditionalExpression)
|
||||
throw new BacktrackException();
|
||||
|
||||
if (expr instanceof IASTBinaryExpression) {
|
||||
IASTBinaryExpression bexpr= (IASTBinaryExpression) expr;
|
||||
switch (bexpr.getOperator()) {
|
||||
case IASTBinaryExpression.op_logicalAnd:
|
||||
case IASTBinaryExpression.op_logicalOr:
|
||||
throw new BacktrackException();
|
||||
final ASTNode node = (ASTNode) expr;
|
||||
throwBacktrack(node.getOffset(), node.getLength());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue