Skip to main content
aboutsummaryrefslogtreecommitdiffstats
path: root/core
diff options
context:
space:
mode:
authorMarkus Schorn2008-04-15 09:55:26 -0400
committerMarkus Schorn2008-04-15 09:55:26 -0400
commit7f62ac03bf4e8768b2885f744a60cefe0f1f3f4c (patch)
tree2b1bdf5e76973e2c0b866e2d2d41b3011a0ee4b4 /core
parent77a468323dc14c47a3bdb4d325885b9997409a08 (diff)
downloadorg.eclipse.cdt-7f62ac03bf4e8768b2885f744a60cefe0f1f3f4c.tar.gz
org.eclipse.cdt-7f62ac03bf4e8768b2885f744a60cefe0f1f3f4c.tar.xz
org.eclipse.cdt-7f62ac03bf4e8768b2885f744a60cefe0f1f3f4c.zip
Specific sizeof expression, bug 227122.
Diffstat (limited to 'core')
-rw-r--r--core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2Tests.java8
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/AbstractGNUSourceCodeParser.java14
2 files changed, 16 insertions, 6 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 0891c1167e0..37a4d4c5974 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
@@ -4537,4 +4537,12 @@ public class AST2Tests extends AST2BaseTest {
final String code = getAboveComment();
parseAndCheckBindings(code, ParserLanguage.CPP, true);
}
+
+ // char buf[256];
+ // int x= sizeof(buf)[0];
+ public void testSizeofUnaryWithParenthesis_Bug227122() throws Exception {
+ final String code = getAboveComment();
+ parseAndCheckBindings(code, ParserLanguage.C);
+ parseAndCheckBindings(code, ParserLanguage.CPP);
+ }
}
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 fc5156d6d8a..3cd5c59cfa1 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
@@ -1753,16 +1753,15 @@ public abstract class AbstractGNUSourceCodeParser implements ISourceCodeParser {
case IToken.tRPAREN:
case IToken.tEOC:
endoffset[0]= consume().getEndOffset();
+ typeIdLA = LA(1);
break;
default:
typeId = null;
}
}
- if (typeId != null) {
+ else {
+ endoffset[0]= calculateEndOffset(typeId);
typeIdLA = LA(1);
- if (!typeIdWithParentheses) {
- endoffset[0]= calculateEndOffset(typeId);
- }
}
}
} catch (BacktrackException e) { }
@@ -1784,8 +1783,11 @@ public abstract class AbstractGNUSourceCodeParser implements ISourceCodeParser {
endoffset[0]= calculateEndOffset(unaryExpression);
return new IASTNode[] {unaryExpression};
}
- if (unaryExpression != null && typeId != null && typeIdLA == unaryExpressionLA) {
- return new IASTNode[] {typeId, unaryExpression};
+ if (unaryExpression != null && typeId != null) {
+ if (typeIdLA == unaryExpressionLA) {
+ return new IASTNode[] {typeId, unaryExpression};
+ }
+ return new IASTNode[] {unaryExpression};
}
return EMPTY_NODE_ARRAY;

Back to the top