Skip to main content
aboutsummaryrefslogtreecommitdiffstats
path: root/core
diff options
context:
space:
mode:
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