1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-06-09 18:56:02 +02:00

Correct parsing of typeof-expressions, bug 226492.

This commit is contained in:
Markus Schorn 2008-04-11 14:28:38 +00:00
parent c9e25b268b
commit 7aab1dfa1c
3 changed files with 14 additions and 3 deletions

View file

@ -4494,6 +4494,15 @@ public class AST2Tests extends AST2BaseTest {
parseAndCheckBindings(code, ParserLanguage.CPP, true); 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) { // void test(int count) {
// switch(count) { // switch(count) {
// case 1 ... 3: break; // case 1 ... 3: break;

View file

@ -864,7 +864,7 @@ public abstract class AbstractGNUSourceCodeParser implements ISourceCodeParser {
backup(m); backup(m);
d = typeId(false); d = typeId(false);
if (d == null) if (d == null)
throw new BacktrackException(); throw e;
} }
lastOffset = consume(IToken.tRPAREN).getEndOffset(); lastOffset = consume(IToken.tRPAREN).getEndOffset();
} else { } else {
@ -2052,6 +2052,7 @@ public abstract class AbstractGNUSourceCodeParser implements ISourceCodeParser {
// gcc-special // gcc-special
case IGCCToken.t_typeof: case IGCCToken.t_typeof:
case IGCCToken.t__attribute__:
// content assist // content assist
case IToken.tCOMPLETION: case IToken.tCOMPLETION:

View file

@ -418,13 +418,14 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser {
if (templateArgListCount > 0) { if (templateArgListCount > 0) {
// bug 104706, don't allow usage of logical operators in template argument lists. // bug 104706, don't allow usage of logical operators in template argument lists.
if (expr instanceof IASTConditionalExpression) if (expr instanceof IASTConditionalExpression)
throw new BacktrackException();
if (expr instanceof IASTBinaryExpression) { if (expr instanceof IASTBinaryExpression) {
IASTBinaryExpression bexpr= (IASTBinaryExpression) expr; IASTBinaryExpression bexpr= (IASTBinaryExpression) expr;
switch (bexpr.getOperator()) { switch (bexpr.getOperator()) {
case IASTBinaryExpression.op_logicalAnd: case IASTBinaryExpression.op_logicalAnd:
case IASTBinaryExpression.op_logicalOr: case IASTBinaryExpression.op_logicalOr:
throw new BacktrackException(); final ASTNode node = (ASTNode) expr;
throwBacktrack(node.getOffset(), node.getLength());
} }
} }
} }