Skip to main content
aboutsummaryrefslogtreecommitdiffstats
path: root/core
diff options
context:
space:
mode:
authorMarkus Schorn2008-04-11 10:28:38 -0400
committerMarkus Schorn2008-04-11 10:28:38 -0400
commit7aab1dfa1cfebf63ea4c8c3249cdcc81a44496fd (patch)
treecf2f6d3e63ab6374d80d27897d37b194df4abfee /core
parentc9e25b268beca731018ca703bf3fc9f22aa220ad (diff)
downloadorg.eclipse.cdt-7aab1dfa1cfebf63ea4c8c3249cdcc81a44496fd.tar.gz
org.eclipse.cdt-7aab1dfa1cfebf63ea4c8c3249cdcc81a44496fd.tar.xz
org.eclipse.cdt-7aab1dfa1cfebf63ea4c8c3249cdcc81a44496fd.zip
Correct parsing of typeof-expressions, bug 226492.
Diffstat (limited to 'core')
-rw-r--r--core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2Tests.java9
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/AbstractGNUSourceCodeParser.java3
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/GNUCPPSourceParser.java5
3 files changed, 14 insertions, 3 deletions
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());
}
}
}

Back to the top