diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2Tests.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2Tests.java index 0f46b607f46..560506012e6 100644 --- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2Tests.java +++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2Tests.java @@ -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; diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/AbstractGNUSourceCodeParser.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/AbstractGNUSourceCodeParser.java index c1e39dab151..fc5156d6d8a 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/AbstractGNUSourceCodeParser.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/AbstractGNUSourceCodeParser.java @@ -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: diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/GNUCPPSourceParser.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/GNUCPPSourceParser.java index 8167cbba2d0..f1a52df2c6e 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/GNUCPPSourceParser.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/GNUCPPSourceParser.java @@ -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()); } } }