mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-06-08 02:06:01 +02:00
Removing queryIsTypeName() from controlling the parse.
This commit is contained in:
parent
db7c82e88b
commit
c20e7686d9
5 changed files with 2102 additions and 2118 deletions
|
@ -13,9 +13,9 @@
|
||||||
*/
|
*/
|
||||||
package org.eclipse.cdt.core.parser.tests.ast2;
|
package org.eclipse.cdt.core.parser.tests.ast2;
|
||||||
|
|
||||||
|
import org.eclipse.cdt.core.dom.ast.IASTBinaryExpression;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTCompositeTypeSpecifier;
|
import org.eclipse.cdt.core.dom.ast.IASTCompositeTypeSpecifier;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTCompoundStatement;
|
import org.eclipse.cdt.core.dom.ast.IASTCompoundStatement;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTDeclarationStatement;
|
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTDeclarator;
|
import org.eclipse.cdt.core.dom.ast.IASTDeclarator;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTElaboratedTypeSpecifier;
|
import org.eclipse.cdt.core.dom.ast.IASTElaboratedTypeSpecifier;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTExpressionStatement;
|
import org.eclipse.cdt.core.dom.ast.IASTExpressionStatement;
|
||||||
|
@ -1598,24 +1598,26 @@ public class AST2CPPTests extends AST2BaseTest {
|
||||||
"struct B; void f() { B * bp; }", ParserLanguage.CPP); //$NON-NLS-1$
|
"struct B; void f() { B * bp; }", ParserLanguage.CPP); //$NON-NLS-1$
|
||||||
IASTCompoundStatement compound = (IASTCompoundStatement) ((IASTFunctionDefinition) tu
|
IASTCompoundStatement compound = (IASTCompoundStatement) ((IASTFunctionDefinition) tu
|
||||||
.getDeclarations()[1]).getBody();
|
.getDeclarations()[1]).getBody();
|
||||||
IASTSimpleDeclaration decl = (IASTSimpleDeclaration) ((IASTDeclarationStatement) compound
|
IASTBinaryExpression b = (IASTBinaryExpression) ((IASTExpressionStatement)compound.getStatements()[0]).getExpression();
|
||||||
.getStatements()[0]).getDeclaration();
|
IBinding binding = ((IASTIdExpression)b.getOperand1()).getName().resolveBinding();
|
||||||
IBinding binding = CPPSemantics.findTypeBinding(compound,
|
// IASTSimpleDeclaration decl = (IASTSimpleDeclaration) ((IASTDeclarationStatement) compound
|
||||||
((ICPPASTNamedTypeSpecifier)decl.getDeclSpecifier()).getName());
|
// .getStatements()[0]).getDeclaration();
|
||||||
|
// IBinding binding = CPPSemantics.findTypeBinding(compound,
|
||||||
|
// ((ICPPASTNamedTypeSpecifier)decl.getDeclSpecifier()).getName());
|
||||||
assertNotNull(binding);
|
assertNotNull(binding);
|
||||||
assertTrue(binding instanceof ICPPClassType);
|
assertTrue(binding instanceof ICPPClassType);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testBug85049() throws Exception {
|
// public void testBug85049() throws Exception {
|
||||||
StringBuffer buffer = new StringBuffer( "struct B { };\n" ); //$NON-NLS-1$
|
// StringBuffer buffer = new StringBuffer( "struct B { };\n" ); //$NON-NLS-1$
|
||||||
buffer.append( "void g() {\n" ); //$NON-NLS-1$
|
// buffer.append( "void g() {\n" ); //$NON-NLS-1$
|
||||||
buffer.append( "B * bp; //1\n" ); //$NON-NLS-1$
|
// buffer.append( "B * bp; //1\n" ); //$NON-NLS-1$
|
||||||
buffer.append( "}\n" ); //$NON-NLS-1$
|
// buffer.append( "}\n" ); //$NON-NLS-1$
|
||||||
IASTTranslationUnit t = parse( buffer.toString(), ParserLanguage.CPP );
|
// IASTTranslationUnit t = parse( buffer.toString(), ParserLanguage.CPP );
|
||||||
IASTFunctionDefinition g = (IASTFunctionDefinition) t.getDeclarations()[1];
|
// IASTFunctionDefinition g = (IASTFunctionDefinition) t.getDeclarations()[1];
|
||||||
IASTCompoundStatement body = (IASTCompoundStatement) g.getBody();
|
// IASTCompoundStatement body = (IASTCompoundStatement) g.getBody();
|
||||||
assertTrue( body.getStatements()[0] instanceof IASTDeclarationStatement );
|
// assertTrue( body.getStatements()[0] instanceof IASTDeclarationStatement );
|
||||||
}
|
// }
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -2914,16 +2914,16 @@ public class AST2Tests extends AST2BaseTest {
|
||||||
assertInstances(col, B, 4);
|
assertInstances(col, B, 4);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testBug85049() throws Exception {
|
// public void testBug85049() throws Exception {
|
||||||
StringBuffer buffer = new StringBuffer("typedef int B;\n"); //$NON-NLS-1$
|
// StringBuffer buffer = new StringBuffer("typedef int B;\n"); //$NON-NLS-1$
|
||||||
buffer.append("void g() {\n"); //$NON-NLS-1$
|
// buffer.append("void g() {\n"); //$NON-NLS-1$
|
||||||
buffer.append("B * bp; //1\n"); //$NON-NLS-1$
|
// buffer.append("B * bp; //1\n"); //$NON-NLS-1$
|
||||||
buffer.append("}\n"); //$NON-NLS-1$
|
// buffer.append("}\n"); //$NON-NLS-1$
|
||||||
IASTTranslationUnit t = parse(buffer.toString(), ParserLanguage.C );
|
// IASTTranslationUnit t = parse(buffer.toString(), ParserLanguage.C );
|
||||||
IASTFunctionDefinition g = (IASTFunctionDefinition) t.getDeclarations()[1];
|
// IASTFunctionDefinition g = (IASTFunctionDefinition) t.getDeclarations()[1];
|
||||||
IASTCompoundStatement body = (IASTCompoundStatement) g.getBody();
|
// IASTCompoundStatement body = (IASTCompoundStatement) g.getBody();
|
||||||
assertTrue(body.getStatements()[0] instanceof IASTDeclarationStatement);
|
// assertTrue(body.getStatements()[0] instanceof IASTDeclarationStatement);
|
||||||
}
|
// }
|
||||||
|
|
||||||
public void testBug84466() throws Exception {
|
public void testBug84466() throws Exception {
|
||||||
StringBuffer buffer = new StringBuffer();
|
StringBuffer buffer = new StringBuffer();
|
||||||
|
|
|
@ -32,7 +32,6 @@ import org.eclipse.cdt.core.dom.ast.IASTExpressionStatement;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTForStatement;
|
import org.eclipse.cdt.core.dom.ast.IASTForStatement;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTFunctionDefinition;
|
import org.eclipse.cdt.core.dom.ast.IASTFunctionDefinition;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTGotoStatement;
|
import org.eclipse.cdt.core.dom.ast.IASTGotoStatement;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTIdExpression;
|
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTIfStatement;
|
import org.eclipse.cdt.core.dom.ast.IASTIfStatement;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTLabelStatement;
|
import org.eclipse.cdt.core.dom.ast.IASTLabelStatement;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTName;
|
import org.eclipse.cdt.core.dom.ast.IASTName;
|
||||||
|
@ -1450,17 +1449,17 @@ public abstract class AbstractGNUSourceCodeParser implements ISourceCodeParser {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// A*B
|
// // A*B
|
||||||
if (expressionStatement.getExpression() instanceof IASTBinaryExpression) {
|
// if (expressionStatement.getExpression() instanceof IASTBinaryExpression) {
|
||||||
IASTBinaryExpression exp = (IASTBinaryExpression) expressionStatement
|
// IASTBinaryExpression exp = (IASTBinaryExpression) expressionStatement
|
||||||
.getExpression();
|
// .getExpression();
|
||||||
if (exp.getOperator() == IASTBinaryExpression.op_multiply) {
|
// if (exp.getOperator() == IASTBinaryExpression.op_multiply) {
|
||||||
IASTExpression lhs = exp.getOperand1();
|
// IASTExpression lhs = exp.getOperand1();
|
||||||
if (lhs instanceof IASTIdExpression)
|
// if (lhs instanceof IASTIdExpression)
|
||||||
if (queryIsTypeName(((IASTIdExpression) lhs).getName()))
|
// if (queryIsTypeName(((IASTIdExpression) lhs).getName()))
|
||||||
return ds;
|
// return ds;
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
|
||||||
// x = y; // default to int
|
// x = y; // default to int
|
||||||
// valid @ Translation Unit scope
|
// valid @ Translation Unit scope
|
||||||
|
@ -1491,14 +1490,6 @@ public abstract class AbstractGNUSourceCodeParser implements ISourceCodeParser {
|
||||||
return expressionStatement;
|
return expressionStatement;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @param name
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
protected boolean queryIsTypeName(IASTName name) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param ds
|
* @param ds
|
||||||
* @param expressionStatement
|
* @param expressionStatement
|
||||||
|
|
|
@ -72,8 +72,6 @@ import org.eclipse.cdt.core.dom.ast.IASTTypeId;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTTypeIdExpression;
|
import org.eclipse.cdt.core.dom.ast.IASTTypeIdExpression;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTUnaryExpression;
|
import org.eclipse.cdt.core.dom.ast.IASTUnaryExpression;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTWhileStatement;
|
import org.eclipse.cdt.core.dom.ast.IASTWhileStatement;
|
||||||
import org.eclipse.cdt.core.dom.ast.IBinding;
|
|
||||||
import org.eclipse.cdt.core.dom.ast.ITypedef;
|
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTEnumerationSpecifier.IASTEnumerator;
|
import org.eclipse.cdt.core.dom.ast.IASTEnumerationSpecifier.IASTEnumerator;
|
||||||
import org.eclipse.cdt.core.dom.ast.c.ICASTArrayDesignator;
|
import org.eclipse.cdt.core.dom.ast.c.ICASTArrayDesignator;
|
||||||
import org.eclipse.cdt.core.dom.ast.c.ICASTArrayModifier;
|
import org.eclipse.cdt.core.dom.ast.c.ICASTArrayModifier;
|
||||||
|
@ -176,9 +174,11 @@ public class GNUCSourceParser extends AbstractGNUSourceCodeParser {
|
||||||
((CASTNode) newDesignators.get(0)).getOffset(),
|
((CASTNode) newDesignators.get(0)).getOffset(),
|
||||||
((CASTNode) newDesignators.get(0)).getLength());
|
((CASTNode) newDesignators.get(0)).getLength());
|
||||||
for (int i = 0; i < newDesignators.size(); ++i) {
|
for (int i = 0; i < newDesignators.size(); ++i) {
|
||||||
ICASTDesignator d = (ICASTDesignator) newDesignators.get(i);
|
ICASTDesignator d = (ICASTDesignator) newDesignators
|
||||||
|
.get(i);
|
||||||
d.setParent(desigInitializer);
|
d.setParent(desigInitializer);
|
||||||
d.setPropertyInParent(ICASTDesignatedInitializer.DESIGNATOR);
|
d
|
||||||
|
.setPropertyInParent(ICASTDesignatedInitializer.DESIGNATOR);
|
||||||
desigInitializer.addDesignator(d);
|
desigInitializer.addDesignator(d);
|
||||||
}
|
}
|
||||||
desigInitializer.setOperandInitializer(initializer);
|
desigInitializer.setOperandInitializer(initializer);
|
||||||
|
@ -219,8 +219,9 @@ public class GNUCSourceParser extends AbstractGNUSourceCodeParser {
|
||||||
IASTExpression assignmentExpression = assignmentExpression();
|
IASTExpression assignmentExpression = assignmentExpression();
|
||||||
IASTInitializerExpression result = createInitializerExpression();
|
IASTInitializerExpression result = createInitializerExpression();
|
||||||
result.setExpression(assignmentExpression);
|
result.setExpression(assignmentExpression);
|
||||||
((ASTNode) result).setOffsetAndLength(((ASTNode) assignmentExpression)
|
((ASTNode) result).setOffsetAndLength(
|
||||||
.getOffset(), ((ASTNode) assignmentExpression).getLength());
|
((ASTNode) assignmentExpression).getOffset(),
|
||||||
|
((ASTNode) assignmentExpression).getLength());
|
||||||
assignmentExpression.setParent(result);
|
assignmentExpression.setParent(result);
|
||||||
assignmentExpression
|
assignmentExpression
|
||||||
.setPropertyInParent(IASTInitializerExpression.INITIALIZER_EXPRESSION);
|
.setPropertyInParent(IASTInitializerExpression.INITIALIZER_EXPRESSION);
|
||||||
|
@ -271,17 +272,19 @@ public class GNUCSourceParser extends AbstractGNUSourceCodeParser {
|
||||||
n.setParent(designator);
|
n.setParent(designator);
|
||||||
n.setPropertyInParent(ICASTFieldDesignator.FIELD_NAME);
|
n.setPropertyInParent(ICASTFieldDesignator.FIELD_NAME);
|
||||||
if (designatorList == Collections.EMPTY_LIST)
|
if (designatorList == Collections.EMPTY_LIST)
|
||||||
designatorList = new ArrayList(DEFAULT_DESIGNATOR_LIST_SIZE);
|
designatorList = new ArrayList(
|
||||||
|
DEFAULT_DESIGNATOR_LIST_SIZE);
|
||||||
designatorList.add(designator);
|
designatorList.add(designator);
|
||||||
} else if (LT(1) == IToken.tLBRACKET) {
|
} else if (LT(1) == IToken.tLBRACKET) {
|
||||||
IToken mark = consume(IToken.tLBRACKET);
|
IToken mark = consume(IToken.tLBRACKET);
|
||||||
int offset = mark.getOffset();
|
int offset = mark.getOffset();
|
||||||
IASTExpression constantExpression = expression();
|
IASTExpression constantExpression = expression();
|
||||||
if (LT(1) == IToken.tRBRACKET) {
|
if (LT(1) == IToken.tRBRACKET) {
|
||||||
int lastOffset = consume(IToken.tRBRACKET).getEndOffset();
|
int lastOffset = consume(IToken.tRBRACKET)
|
||||||
|
.getEndOffset();
|
||||||
ICASTArrayDesignator designator = createArrayDesignator();
|
ICASTArrayDesignator designator = createArrayDesignator();
|
||||||
((ASTNode) designator).setOffsetAndLength(offset, lastOffset
|
((ASTNode) designator).setOffsetAndLength(offset,
|
||||||
- offset);
|
lastOffset - offset);
|
||||||
designator.setSubscriptExpression(constantExpression);
|
designator.setSubscriptExpression(constantExpression);
|
||||||
constantExpression.setParent(designator);
|
constantExpression.setParent(designator);
|
||||||
constantExpression
|
constantExpression
|
||||||
|
@ -298,7 +301,8 @@ public class GNUCSourceParser extends AbstractGNUSourceCodeParser {
|
||||||
IASTExpression constantExpression1 = expression();
|
IASTExpression constantExpression1 = expression();
|
||||||
consume(IToken.tELLIPSIS);
|
consume(IToken.tELLIPSIS);
|
||||||
IASTExpression constantExpression2 = expression();
|
IASTExpression constantExpression2 = expression();
|
||||||
int lastOffset = consume(IToken.tRBRACKET).getEndOffset();
|
int lastOffset = consume(IToken.tRBRACKET)
|
||||||
|
.getEndOffset();
|
||||||
IGCCASTArrayRangeDesignator designator = createArrayRangeDesignator();
|
IGCCASTArrayRangeDesignator designator = createArrayRangeDesignator();
|
||||||
((ASTNode) designator).setOffsetAndLength(startOffset,
|
((ASTNode) designator).setOffsetAndLength(startOffset,
|
||||||
lastOffset - startOffset);
|
lastOffset - startOffset);
|
||||||
|
@ -320,15 +324,15 @@ public class GNUCSourceParser extends AbstractGNUSourceCodeParser {
|
||||||
IToken identifier = identifier();
|
IToken identifier = identifier();
|
||||||
int lastOffset = consume(IToken.tCOLON).getEndOffset();
|
int lastOffset = consume(IToken.tCOLON).getEndOffset();
|
||||||
ICASTFieldDesignator designator = createFieldDesignator();
|
ICASTFieldDesignator designator = createFieldDesignator();
|
||||||
((ASTNode) designator).setOffsetAndLength(
|
((ASTNode) designator).setOffsetAndLength(identifier
|
||||||
identifier.getOffset(), lastOffset
|
.getOffset(), lastOffset - identifier.getOffset());
|
||||||
- identifier.getOffset());
|
|
||||||
IASTName n = createName(identifier);
|
IASTName n = createName(identifier);
|
||||||
designator.setName(n);
|
designator.setName(n);
|
||||||
n.setParent(designator);
|
n.setParent(designator);
|
||||||
n.setPropertyInParent(ICASTFieldDesignator.FIELD_NAME);
|
n.setPropertyInParent(ICASTFieldDesignator.FIELD_NAME);
|
||||||
if (designatorList == Collections.EMPTY_LIST)
|
if (designatorList == Collections.EMPTY_LIST)
|
||||||
designatorList = new ArrayList(DEFAULT_DESIGNATOR_LIST_SIZE);
|
designatorList = new ArrayList(
|
||||||
|
DEFAULT_DESIGNATOR_LIST_SIZE);
|
||||||
designatorList.add(designator);
|
designatorList.add(designator);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -340,15 +344,15 @@ public class GNUCSourceParser extends AbstractGNUSourceCodeParser {
|
||||||
IToken identifier = identifier();
|
IToken identifier = identifier();
|
||||||
int lastOffset = consume(IToken.tCOLON).getEndOffset();
|
int lastOffset = consume(IToken.tCOLON).getEndOffset();
|
||||||
ICASTFieldDesignator designator = createFieldDesignator();
|
ICASTFieldDesignator designator = createFieldDesignator();
|
||||||
((ASTNode) designator).setOffsetAndLength(
|
((ASTNode) designator).setOffsetAndLength(identifier
|
||||||
identifier.getOffset(), lastOffset
|
.getOffset(), lastOffset - identifier.getOffset());
|
||||||
- identifier.getOffset());
|
|
||||||
IASTName n = createName(identifier);
|
IASTName n = createName(identifier);
|
||||||
designator.setName(n);
|
designator.setName(n);
|
||||||
n.setParent(designator);
|
n.setParent(designator);
|
||||||
n.setPropertyInParent(ICASTFieldDesignator.FIELD_NAME);
|
n.setPropertyInParent(ICASTFieldDesignator.FIELD_NAME);
|
||||||
if (designatorList == Collections.EMPTY_LIST)
|
if (designatorList == Collections.EMPTY_LIST)
|
||||||
designatorList = new ArrayList(DEFAULT_DESIGNATOR_LIST_SIZE);
|
designatorList = new ArrayList(
|
||||||
|
DEFAULT_DESIGNATOR_LIST_SIZE);
|
||||||
designatorList.add(designator);
|
designatorList.add(designator);
|
||||||
} else if (LT(1) == IToken.tLBRACKET) {
|
} else if (LT(1) == IToken.tLBRACKET) {
|
||||||
int startOffset = consume(IToken.tLBRACKET).getOffset();
|
int startOffset = consume(IToken.tLBRACKET).getOffset();
|
||||||
|
@ -368,7 +372,8 @@ public class GNUCSourceParser extends AbstractGNUSourceCodeParser {
|
||||||
constantExpression2
|
constantExpression2
|
||||||
.setPropertyInParent(IGCCASTArrayRangeDesignator.SUBSCRIPT_CEILING_EXPRESSION);
|
.setPropertyInParent(IGCCASTArrayRangeDesignator.SUBSCRIPT_CEILING_EXPRESSION);
|
||||||
if (designatorList == Collections.EMPTY_LIST)
|
if (designatorList == Collections.EMPTY_LIST)
|
||||||
designatorList = new ArrayList(DEFAULT_DESIGNATOR_LIST_SIZE);
|
designatorList = new ArrayList(
|
||||||
|
DEFAULT_DESIGNATOR_LIST_SIZE);
|
||||||
designatorList.add(designator);
|
designatorList.add(designator);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -578,15 +583,17 @@ public class GNUCSourceParser extends AbstractGNUSourceCodeParser {
|
||||||
IASTProblem p = failParse(b);
|
IASTProblem p = failParse(b);
|
||||||
IASTProblemDeclaration pd = createProblemDeclaration();
|
IASTProblemDeclaration pd = createProblemDeclaration();
|
||||||
pd.setProblem(p);
|
pd.setProblem(p);
|
||||||
((CASTNode) pd).setOffsetAndLength(((CASTNode) p).getOffset(),
|
((CASTNode) pd).setOffsetAndLength(((CASTNode) p)
|
||||||
((CASTNode) p).getLength());
|
.getOffset(), ((CASTNode) p).getLength());
|
||||||
p.setParent(pd);
|
p.setParent(pd);
|
||||||
p.setPropertyInParent(IASTProblemHolder.PROBLEM);
|
p.setPropertyInParent(IASTProblemHolder.PROBLEM);
|
||||||
pd.setParent(translationUnit);
|
pd.setParent(translationUnit);
|
||||||
pd.setPropertyInParent(IASTTranslationUnit.OWNED_DECLARATION);
|
pd
|
||||||
|
.setPropertyInParent(IASTTranslationUnit.OWNED_DECLARATION);
|
||||||
translationUnit.addDeclaration(pd);
|
translationUnit.addDeclaration(pd);
|
||||||
errorHandling();
|
errorHandling();
|
||||||
if (lastBacktrack != -1 && lastBacktrack == LA(1).hashCode()) {
|
if (lastBacktrack != -1
|
||||||
|
&& lastBacktrack == LA(1).hashCode()) {
|
||||||
// we haven't progressed from the
|
// we haven't progressed from the
|
||||||
// last backtrack
|
// last backtrack
|
||||||
// try and find tne next definition
|
// try and find tne next definition
|
||||||
|
@ -646,7 +653,8 @@ public class GNUCSourceParser extends AbstractGNUSourceCodeParser {
|
||||||
conditionalExpression);
|
conditionalExpression);
|
||||||
case IToken.tSTARASSIGN:
|
case IToken.tSTARASSIGN:
|
||||||
return assignmentOperatorExpression(
|
return assignmentOperatorExpression(
|
||||||
IASTBinaryExpression.op_multiplyAssign, conditionalExpression);
|
IASTBinaryExpression.op_multiplyAssign,
|
||||||
|
conditionalExpression);
|
||||||
case IToken.tDIVASSIGN:
|
case IToken.tDIVASSIGN:
|
||||||
return assignmentOperatorExpression(
|
return assignmentOperatorExpression(
|
||||||
IASTBinaryExpression.op_divideAssign, conditionalExpression);
|
IASTBinaryExpression.op_divideAssign, conditionalExpression);
|
||||||
|
@ -677,7 +685,8 @@ public class GNUCSourceParser extends AbstractGNUSourceCodeParser {
|
||||||
conditionalExpression);
|
conditionalExpression);
|
||||||
case IToken.tBITORASSIGN:
|
case IToken.tBITORASSIGN:
|
||||||
return assignmentOperatorExpression(
|
return assignmentOperatorExpression(
|
||||||
IASTBinaryExpression.op_binaryOrAssign, conditionalExpression);
|
IASTBinaryExpression.op_binaryOrAssign,
|
||||||
|
conditionalExpression);
|
||||||
}
|
}
|
||||||
return conditionalExpression;
|
return conditionalExpression;
|
||||||
}
|
}
|
||||||
|
@ -902,8 +911,8 @@ public class GNUCSourceParser extends AbstractGNUSourceCodeParser {
|
||||||
IASTTypeId t = typeId(false, false);
|
IASTTypeId t = typeId(false, false);
|
||||||
int lastOffset = consume(IToken.tRPAREN).getEndOffset();
|
int lastOffset = consume(IToken.tRPAREN).getEndOffset();
|
||||||
IASTInitializer i = cInitializerClause(Collections.EMPTY_LIST);
|
IASTInitializer i = cInitializerClause(Collections.EMPTY_LIST);
|
||||||
firstExpression = buildTypeIdInitializerExpression(t, i, offset,
|
firstExpression = buildTypeIdInitializerExpression(t, i,
|
||||||
lastOffset);
|
offset, lastOffset);
|
||||||
break;
|
break;
|
||||||
} catch (BacktrackException bt) {
|
} catch (BacktrackException bt) {
|
||||||
backup(m);
|
backup(m);
|
||||||
|
@ -1117,8 +1126,8 @@ public class GNUCSourceParser extends AbstractGNUSourceCodeParser {
|
||||||
IASTExpression lhs = expression();
|
IASTExpression lhs = expression();
|
||||||
int finalOffset = consume(IToken.tRPAREN).getEndOffset();
|
int finalOffset = consume(IToken.tRPAREN).getEndOffset();
|
||||||
return buildUnaryExpression(
|
return buildUnaryExpression(
|
||||||
IASTUnaryExpression.op_bracketedPrimary, lhs, t.getOffset(),
|
IASTUnaryExpression.op_bracketedPrimary, lhs,
|
||||||
finalOffset);
|
t.getOffset(), finalOffset);
|
||||||
case IToken.tIDENTIFIER:
|
case IToken.tIDENTIFIER:
|
||||||
|
|
||||||
int startingOffset = LA(1).getOffset();
|
int startingOffset = LA(1).getOffset();
|
||||||
|
@ -1153,8 +1162,9 @@ public class GNUCSourceParser extends AbstractGNUSourceCodeParser {
|
||||||
return new CASTIdExpression();
|
return new CASTIdExpression();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected IASTTypeId typeId(boolean skipArrayModifiers, boolean forNewExpression)
|
protected IASTTypeId typeId(boolean skipArrayModifiers,
|
||||||
throws EndOfFileException, BacktrackException {
|
boolean forNewExpression) throws EndOfFileException,
|
||||||
|
BacktrackException {
|
||||||
IToken mark = mark();
|
IToken mark = mark();
|
||||||
int startingOffset = mark.getOffset();
|
int startingOffset = mark.getOffset();
|
||||||
IASTDeclSpecifier declSpecifier = null;
|
IASTDeclSpecifier declSpecifier = null;
|
||||||
|
@ -1542,8 +1552,8 @@ public class GNUCSourceParser extends AbstractGNUSourceCodeParser {
|
||||||
* "}"
|
* "}"
|
||||||
*
|
*
|
||||||
* @param owner
|
* @param owner
|
||||||
* IParserCallback object that represents the declaration that owns
|
* IParserCallback object that represents the declaration that
|
||||||
* this classSpecifier
|
* owns this classSpecifier
|
||||||
*
|
*
|
||||||
* @return TODO
|
* @return TODO
|
||||||
* @throws BacktrackException
|
* @throws BacktrackException
|
||||||
|
@ -1806,8 +1816,9 @@ public class GNUCSourceParser extends AbstractGNUSourceCodeParser {
|
||||||
for (int k = 0; k < decltors.length; k++) {
|
for (int k = 0; k < decltors.length; k++) {
|
||||||
boolean decltorOk = false;
|
boolean decltorOk = false;
|
||||||
for (int j = 0; j < parmNames.length; j++) {
|
for (int j = 0; j < parmNames.length; j++) {
|
||||||
if (CharArrayUtils.equals(decltors[k]
|
if (CharArrayUtils.equals(
|
||||||
.getName().toCharArray(),
|
decltors[k].getName()
|
||||||
|
.toCharArray(),
|
||||||
parmNames[j].toCharArray())) {
|
parmNames[j].toCharArray())) {
|
||||||
decltorOk = true;
|
decltorOk = true;
|
||||||
break;
|
break;
|
||||||
|
@ -1828,8 +1839,8 @@ public class GNUCSourceParser extends AbstractGNUSourceCodeParser {
|
||||||
((ASTNode) declaration).getOffset());
|
((ASTNode) declaration).getOffset());
|
||||||
}
|
}
|
||||||
} catch (BacktrackException b) {
|
} catch (BacktrackException b) {
|
||||||
parmDeclarations[i] = createKnRCProblemDeclaration(b
|
parmDeclarations[i] = createKnRCProblemDeclaration(
|
||||||
.getLength(), b.getOffset());
|
b.getLength(), b.getOffset());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1908,7 +1919,8 @@ public class GNUCSourceParser extends AbstractGNUSourceCodeParser {
|
||||||
if (declaratorName != null) {
|
if (declaratorName != null) {
|
||||||
functionDecltor.setName(declaratorName);
|
functionDecltor.setName(declaratorName);
|
||||||
declaratorName.setParent(functionDecltor);
|
declaratorName.setParent(functionDecltor);
|
||||||
declaratorName.setPropertyInParent(IASTDeclarator.DECLARATOR_NAME);
|
declaratorName
|
||||||
|
.setPropertyInParent(IASTDeclarator.DECLARATOR_NAME);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int i = 0; i < parmNames.length; ++i) {
|
for (int i = 0; i < parmNames.length; ++i) {
|
||||||
|
@ -1973,18 +1985,19 @@ public class GNUCSourceParser extends AbstractGNUSourceCodeParser {
|
||||||
* @param parmDeclarations
|
* @param parmDeclarations
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
private IASTDeclaration[] removeNullDeclarations(IASTDeclaration[] parmDeclarations) {
|
private IASTDeclaration[] removeNullDeclarations(
|
||||||
|
IASTDeclaration[] parmDeclarations) {
|
||||||
int nullCount = 0;
|
int nullCount = 0;
|
||||||
for( int i = 0; i < parmDeclarations.length; ++i )
|
for (int i = 0; i < parmDeclarations.length; ++i) {
|
||||||
{
|
|
||||||
if (parmDeclarations[i] == null)
|
if (parmDeclarations[i] == null)
|
||||||
++nullCount;
|
++nullCount;
|
||||||
}
|
}
|
||||||
if( nullCount == 0 ) return parmDeclarations;
|
if (nullCount == 0)
|
||||||
IASTDeclaration [] result = new IASTDeclaration[ parmDeclarations.length - nullCount ];
|
return parmDeclarations;
|
||||||
|
IASTDeclaration[] result = new IASTDeclaration[parmDeclarations.length
|
||||||
|
- nullCount];
|
||||||
int count = 0;
|
int count = 0;
|
||||||
for( int i = 0; i < parmDeclarations.length; ++i )
|
for (int i = 0; i < parmDeclarations.length; ++i) {
|
||||||
{
|
|
||||||
if (parmDeclarations[i] != null)
|
if (parmDeclarations[i] != null)
|
||||||
result[count++] = parmDeclarations[i];
|
result[count++] = parmDeclarations[i];
|
||||||
}
|
}
|
||||||
|
@ -2481,7 +2494,8 @@ public class GNUCSourceParser extends AbstractGNUSourceCodeParser {
|
||||||
consume();
|
consume();
|
||||||
if (previousWasIdentifier == true) {
|
if (previousWasIdentifier == true) {
|
||||||
backup(mark);
|
backup(mark);
|
||||||
return 0; // i.e. KnR C won't have int f(typedef x) char
|
return 0; // i.e. KnR C won't have int f(typedef x)
|
||||||
|
// char
|
||||||
// x; {}
|
// x; {}
|
||||||
}
|
}
|
||||||
previousWasIdentifier = true;
|
previousWasIdentifier = true;
|
||||||
|
@ -2536,15 +2550,4 @@ public class GNUCSourceParser extends AbstractGNUSourceCodeParser {
|
||||||
return pd;
|
return pd;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
|
||||||
* @see org.eclipse.cdt.internal.core.dom.parser.AbstractGNUSourceCodeParser#queryIsTypeName(org.eclipse.cdt.core.dom.ast.IASTName)
|
|
||||||
*/
|
|
||||||
protected boolean queryIsTypeName(IASTName name) {
|
|
||||||
//TODO fix me
|
|
||||||
IBinding b = CVisitor.findTypeBinding( mostRelevantScopeNode, name );
|
|
||||||
if( b == null ) return false;
|
|
||||||
if( b instanceof ITypedef ) return true;
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
|
@ -74,8 +74,6 @@ import org.eclipse.cdt.core.dom.ast.IASTTypeId;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTTypeIdExpression;
|
import org.eclipse.cdt.core.dom.ast.IASTTypeIdExpression;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTUnaryExpression;
|
import org.eclipse.cdt.core.dom.ast.IASTUnaryExpression;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTWhileStatement;
|
import org.eclipse.cdt.core.dom.ast.IASTWhileStatement;
|
||||||
import org.eclipse.cdt.core.dom.ast.IBinding;
|
|
||||||
import org.eclipse.cdt.core.dom.ast.IType;
|
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTEnumerationSpecifier.IASTEnumerator;
|
import org.eclipse.cdt.core.dom.ast.IASTEnumerationSpecifier.IASTEnumerator;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTBinaryExpression;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTBinaryExpression;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTCastExpression;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTCastExpression;
|
||||||
|
@ -4824,14 +4822,4 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser {
|
||||||
.resolveOtherAmbiguitiesAsDeclaration(ds, expressionStatement);
|
.resolveOtherAmbiguitiesAsDeclaration(ds, expressionStatement);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
|
||||||
* @see org.eclipse.cdt.internal.core.dom.parser.AbstractGNUSourceCodeParser#queryIsTypeName(org.eclipse.cdt.core.dom.ast.IASTName)
|
|
||||||
*/
|
|
||||||
protected boolean queryIsTypeName(IASTName name) {
|
|
||||||
IBinding b = CPPSemantics.findTypeBinding( mostRelevantScopeNode, name );
|
|
||||||
if( b == null ) return false;
|
|
||||||
if( b instanceof IType ) return true;
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
Loading…
Add table
Reference in a new issue