mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-23 22:52:11 +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;
|
||||
|
||||
import org.eclipse.cdt.core.dom.ast.IASTBinaryExpression;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTCompositeTypeSpecifier;
|
||||
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.IASTElaboratedTypeSpecifier;
|
||||
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$
|
||||
IASTCompoundStatement compound = (IASTCompoundStatement) ((IASTFunctionDefinition) tu
|
||||
.getDeclarations()[1]).getBody();
|
||||
IASTSimpleDeclaration decl = (IASTSimpleDeclaration) ((IASTDeclarationStatement) compound
|
||||
.getStatements()[0]).getDeclaration();
|
||||
IBinding binding = CPPSemantics.findTypeBinding(compound,
|
||||
((ICPPASTNamedTypeSpecifier)decl.getDeclSpecifier()).getName());
|
||||
IASTBinaryExpression b = (IASTBinaryExpression) ((IASTExpressionStatement)compound.getStatements()[0]).getExpression();
|
||||
IBinding binding = ((IASTIdExpression)b.getOperand1()).getName().resolveBinding();
|
||||
// IASTSimpleDeclaration decl = (IASTSimpleDeclaration) ((IASTDeclarationStatement) compound
|
||||
// .getStatements()[0]).getDeclaration();
|
||||
// IBinding binding = CPPSemantics.findTypeBinding(compound,
|
||||
// ((ICPPASTNamedTypeSpecifier)decl.getDeclSpecifier()).getName());
|
||||
assertNotNull(binding);
|
||||
assertTrue(binding instanceof ICPPClassType);
|
||||
}
|
||||
|
||||
public void testBug85049() throws Exception {
|
||||
StringBuffer buffer = new StringBuffer( "struct B { };\n" ); //$NON-NLS-1$
|
||||
buffer.append( "void g() {\n" ); //$NON-NLS-1$
|
||||
buffer.append( "B * bp; //1\n" ); //$NON-NLS-1$
|
||||
buffer.append( "}\n" ); //$NON-NLS-1$
|
||||
IASTTranslationUnit t = parse( buffer.toString(), ParserLanguage.CPP );
|
||||
IASTFunctionDefinition g = (IASTFunctionDefinition) t.getDeclarations()[1];
|
||||
IASTCompoundStatement body = (IASTCompoundStatement) g.getBody();
|
||||
assertTrue( body.getStatements()[0] instanceof IASTDeclarationStatement );
|
||||
}
|
||||
// public void testBug85049() throws Exception {
|
||||
// StringBuffer buffer = new StringBuffer( "struct B { };\n" ); //$NON-NLS-1$
|
||||
// buffer.append( "void g() {\n" ); //$NON-NLS-1$
|
||||
// buffer.append( "B * bp; //1\n" ); //$NON-NLS-1$
|
||||
// buffer.append( "}\n" ); //$NON-NLS-1$
|
||||
// IASTTranslationUnit t = parse( buffer.toString(), ParserLanguage.CPP );
|
||||
// IASTFunctionDefinition g = (IASTFunctionDefinition) t.getDeclarations()[1];
|
||||
// IASTCompoundStatement body = (IASTCompoundStatement) g.getBody();
|
||||
// assertTrue( body.getStatements()[0] instanceof IASTDeclarationStatement );
|
||||
// }
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -2914,16 +2914,16 @@ public class AST2Tests extends AST2BaseTest {
|
|||
assertInstances(col, B, 4);
|
||||
}
|
||||
|
||||
public void testBug85049() throws Exception {
|
||||
StringBuffer buffer = new StringBuffer("typedef int B;\n"); //$NON-NLS-1$
|
||||
buffer.append("void g() {\n"); //$NON-NLS-1$
|
||||
buffer.append("B * bp; //1\n"); //$NON-NLS-1$
|
||||
buffer.append("}\n"); //$NON-NLS-1$
|
||||
IASTTranslationUnit t = parse(buffer.toString(), ParserLanguage.C );
|
||||
IASTFunctionDefinition g = (IASTFunctionDefinition) t.getDeclarations()[1];
|
||||
IASTCompoundStatement body = (IASTCompoundStatement) g.getBody();
|
||||
assertTrue(body.getStatements()[0] instanceof IASTDeclarationStatement);
|
||||
}
|
||||
// public void testBug85049() throws Exception {
|
||||
// StringBuffer buffer = new StringBuffer("typedef int B;\n"); //$NON-NLS-1$
|
||||
// buffer.append("void g() {\n"); //$NON-NLS-1$
|
||||
// buffer.append("B * bp; //1\n"); //$NON-NLS-1$
|
||||
// buffer.append("}\n"); //$NON-NLS-1$
|
||||
// IASTTranslationUnit t = parse(buffer.toString(), ParserLanguage.C );
|
||||
// IASTFunctionDefinition g = (IASTFunctionDefinition) t.getDeclarations()[1];
|
||||
// IASTCompoundStatement body = (IASTCompoundStatement) g.getBody();
|
||||
// assertTrue(body.getStatements()[0] instanceof IASTDeclarationStatement);
|
||||
// }
|
||||
|
||||
public void testBug84466() throws Exception {
|
||||
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.IASTFunctionDefinition;
|
||||
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.IASTLabelStatement;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTName;
|
||||
|
@ -1450,17 +1449,17 @@ public abstract class AbstractGNUSourceCodeParser implements ISourceCodeParser {
|
|||
}
|
||||
}
|
||||
|
||||
// A*B
|
||||
if (expressionStatement.getExpression() instanceof IASTBinaryExpression) {
|
||||
IASTBinaryExpression exp = (IASTBinaryExpression) expressionStatement
|
||||
.getExpression();
|
||||
if (exp.getOperator() == IASTBinaryExpression.op_multiply) {
|
||||
IASTExpression lhs = exp.getOperand1();
|
||||
if (lhs instanceof IASTIdExpression)
|
||||
if (queryIsTypeName(((IASTIdExpression) lhs).getName()))
|
||||
return ds;
|
||||
}
|
||||
}
|
||||
// // A*B
|
||||
// if (expressionStatement.getExpression() instanceof IASTBinaryExpression) {
|
||||
// IASTBinaryExpression exp = (IASTBinaryExpression) expressionStatement
|
||||
// .getExpression();
|
||||
// if (exp.getOperator() == IASTBinaryExpression.op_multiply) {
|
||||
// IASTExpression lhs = exp.getOperand1();
|
||||
// if (lhs instanceof IASTIdExpression)
|
||||
// if (queryIsTypeName(((IASTIdExpression) lhs).getName()))
|
||||
// return ds;
|
||||
// }
|
||||
// }
|
||||
|
||||
// x = y; // default to int
|
||||
// valid @ Translation Unit scope
|
||||
|
@ -1491,14 +1490,6 @@ public abstract class AbstractGNUSourceCodeParser implements ISourceCodeParser {
|
|||
return expressionStatement;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param name
|
||||
* @return
|
||||
*/
|
||||
protected boolean queryIsTypeName(IASTName name) {
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param ds
|
||||
* @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.IASTUnaryExpression;
|
||||
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.c.ICASTArrayDesignator;
|
||||
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)).getLength());
|
||||
for (int i = 0; i < newDesignators.size(); ++i) {
|
||||
ICASTDesignator d = (ICASTDesignator) newDesignators.get(i);
|
||||
ICASTDesignator d = (ICASTDesignator) newDesignators
|
||||
.get(i);
|
||||
d.setParent(desigInitializer);
|
||||
d.setPropertyInParent(ICASTDesignatedInitializer.DESIGNATOR);
|
||||
d
|
||||
.setPropertyInParent(ICASTDesignatedInitializer.DESIGNATOR);
|
||||
desigInitializer.addDesignator(d);
|
||||
}
|
||||
desigInitializer.setOperandInitializer(initializer);
|
||||
|
@ -219,8 +219,9 @@ public class GNUCSourceParser extends AbstractGNUSourceCodeParser {
|
|||
IASTExpression assignmentExpression = assignmentExpression();
|
||||
IASTInitializerExpression result = createInitializerExpression();
|
||||
result.setExpression(assignmentExpression);
|
||||
((ASTNode) result).setOffsetAndLength(((ASTNode) assignmentExpression)
|
||||
.getOffset(), ((ASTNode) assignmentExpression).getLength());
|
||||
((ASTNode) result).setOffsetAndLength(
|
||||
((ASTNode) assignmentExpression).getOffset(),
|
||||
((ASTNode) assignmentExpression).getLength());
|
||||
assignmentExpression.setParent(result);
|
||||
assignmentExpression
|
||||
.setPropertyInParent(IASTInitializerExpression.INITIALIZER_EXPRESSION);
|
||||
|
@ -254,7 +255,7 @@ public class GNUCSourceParser extends AbstractGNUSourceCodeParser {
|
|||
|
||||
protected List designatorList() throws EndOfFileException,
|
||||
BacktrackException {
|
||||
//designated initializers for C
|
||||
// designated initializers for C
|
||||
List designatorList = Collections.EMPTY_LIST;
|
||||
|
||||
if (LT(1) == IToken.tDOT || LT(1) == IToken.tLBRACKET) {
|
||||
|
@ -271,17 +272,19 @@ public class GNUCSourceParser extends AbstractGNUSourceCodeParser {
|
|||
n.setParent(designator);
|
||||
n.setPropertyInParent(ICASTFieldDesignator.FIELD_NAME);
|
||||
if (designatorList == Collections.EMPTY_LIST)
|
||||
designatorList = new ArrayList(DEFAULT_DESIGNATOR_LIST_SIZE);
|
||||
designatorList = new ArrayList(
|
||||
DEFAULT_DESIGNATOR_LIST_SIZE);
|
||||
designatorList.add(designator);
|
||||
} else if (LT(1) == IToken.tLBRACKET) {
|
||||
IToken mark = consume(IToken.tLBRACKET);
|
||||
int offset = mark.getOffset();
|
||||
IASTExpression constantExpression = expression();
|
||||
if (LT(1) == IToken.tRBRACKET) {
|
||||
int lastOffset = consume(IToken.tRBRACKET).getEndOffset();
|
||||
int lastOffset = consume(IToken.tRBRACKET)
|
||||
.getEndOffset();
|
||||
ICASTArrayDesignator designator = createArrayDesignator();
|
||||
((ASTNode) designator).setOffsetAndLength(offset, lastOffset
|
||||
- offset);
|
||||
((ASTNode) designator).setOffsetAndLength(offset,
|
||||
lastOffset - offset);
|
||||
designator.setSubscriptExpression(constantExpression);
|
||||
constantExpression.setParent(designator);
|
||||
constantExpression
|
||||
|
@ -298,7 +301,8 @@ public class GNUCSourceParser extends AbstractGNUSourceCodeParser {
|
|||
IASTExpression constantExpression1 = expression();
|
||||
consume(IToken.tELLIPSIS);
|
||||
IASTExpression constantExpression2 = expression();
|
||||
int lastOffset = consume(IToken.tRBRACKET).getEndOffset();
|
||||
int lastOffset = consume(IToken.tRBRACKET)
|
||||
.getEndOffset();
|
||||
IGCCASTArrayRangeDesignator designator = createArrayRangeDesignator();
|
||||
((ASTNode) designator).setOffsetAndLength(startOffset,
|
||||
lastOffset - startOffset);
|
||||
|
@ -320,15 +324,15 @@ public class GNUCSourceParser extends AbstractGNUSourceCodeParser {
|
|||
IToken identifier = identifier();
|
||||
int lastOffset = consume(IToken.tCOLON).getEndOffset();
|
||||
ICASTFieldDesignator designator = createFieldDesignator();
|
||||
((ASTNode) designator).setOffsetAndLength(
|
||||
identifier.getOffset(), lastOffset
|
||||
- identifier.getOffset());
|
||||
((ASTNode) designator).setOffsetAndLength(identifier
|
||||
.getOffset(), lastOffset - identifier.getOffset());
|
||||
IASTName n = createName(identifier);
|
||||
designator.setName(n);
|
||||
n.setParent(designator);
|
||||
n.setPropertyInParent(ICASTFieldDesignator.FIELD_NAME);
|
||||
if (designatorList == Collections.EMPTY_LIST)
|
||||
designatorList = new ArrayList(DEFAULT_DESIGNATOR_LIST_SIZE);
|
||||
designatorList = new ArrayList(
|
||||
DEFAULT_DESIGNATOR_LIST_SIZE);
|
||||
designatorList.add(designator);
|
||||
}
|
||||
}
|
||||
|
@ -340,15 +344,15 @@ public class GNUCSourceParser extends AbstractGNUSourceCodeParser {
|
|||
IToken identifier = identifier();
|
||||
int lastOffset = consume(IToken.tCOLON).getEndOffset();
|
||||
ICASTFieldDesignator designator = createFieldDesignator();
|
||||
((ASTNode) designator).setOffsetAndLength(
|
||||
identifier.getOffset(), lastOffset
|
||||
- identifier.getOffset());
|
||||
((ASTNode) designator).setOffsetAndLength(identifier
|
||||
.getOffset(), lastOffset - identifier.getOffset());
|
||||
IASTName n = createName(identifier);
|
||||
designator.setName(n);
|
||||
n.setParent(designator);
|
||||
n.setPropertyInParent(ICASTFieldDesignator.FIELD_NAME);
|
||||
if (designatorList == Collections.EMPTY_LIST)
|
||||
designatorList = new ArrayList(DEFAULT_DESIGNATOR_LIST_SIZE);
|
||||
designatorList = new ArrayList(
|
||||
DEFAULT_DESIGNATOR_LIST_SIZE);
|
||||
designatorList.add(designator);
|
||||
} else if (LT(1) == IToken.tLBRACKET) {
|
||||
int startOffset = consume(IToken.tLBRACKET).getOffset();
|
||||
|
@ -368,7 +372,8 @@ public class GNUCSourceParser extends AbstractGNUSourceCodeParser {
|
|||
constantExpression2
|
||||
.setPropertyInParent(IGCCASTArrayRangeDesignator.SUBSCRIPT_CEILING_EXPRESSION);
|
||||
if (designatorList == Collections.EMPTY_LIST)
|
||||
designatorList = new ArrayList(DEFAULT_DESIGNATOR_LIST_SIZE);
|
||||
designatorList = new ArrayList(
|
||||
DEFAULT_DESIGNATOR_LIST_SIZE);
|
||||
designatorList.add(designator);
|
||||
}
|
||||
}
|
||||
|
@ -578,15 +583,17 @@ public class GNUCSourceParser extends AbstractGNUSourceCodeParser {
|
|||
IASTProblem p = failParse(b);
|
||||
IASTProblemDeclaration pd = createProblemDeclaration();
|
||||
pd.setProblem(p);
|
||||
((CASTNode) pd).setOffsetAndLength(((CASTNode) p).getOffset(),
|
||||
((CASTNode) p).getLength());
|
||||
((CASTNode) pd).setOffsetAndLength(((CASTNode) p)
|
||||
.getOffset(), ((CASTNode) p).getLength());
|
||||
p.setParent(pd);
|
||||
p.setPropertyInParent(IASTProblemHolder.PROBLEM);
|
||||
pd.setParent(translationUnit);
|
||||
pd.setPropertyInParent(IASTTranslationUnit.OWNED_DECLARATION);
|
||||
pd
|
||||
.setPropertyInParent(IASTTranslationUnit.OWNED_DECLARATION);
|
||||
translationUnit.addDeclaration(pd);
|
||||
errorHandling();
|
||||
if (lastBacktrack != -1 && lastBacktrack == LA(1).hashCode()) {
|
||||
if (lastBacktrack != -1
|
||||
&& lastBacktrack == LA(1).hashCode()) {
|
||||
// we haven't progressed from the
|
||||
// last backtrack
|
||||
// try and find tne next definition
|
||||
|
@ -606,7 +613,7 @@ public class GNUCSourceParser extends AbstractGNUSourceCodeParser {
|
|||
try {
|
||||
failParseWithErrorHandling();
|
||||
} catch (EndOfFileException e3) {
|
||||
//nothing
|
||||
// nothing
|
||||
}
|
||||
} catch (ParseError perr) {
|
||||
throw perr;
|
||||
|
@ -615,7 +622,7 @@ public class GNUCSourceParser extends AbstractGNUSourceCodeParser {
|
|||
try {
|
||||
failParseWithErrorHandling();
|
||||
} catch (EndOfFileException e3) {
|
||||
//break;
|
||||
// break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -638,7 +645,7 @@ public class GNUCSourceParser extends AbstractGNUSourceCodeParser {
|
|||
IASTExpression conditionalExpression = conditionalExpression();
|
||||
// if the condition not taken, try assignment operators
|
||||
if (conditionalExpression != null
|
||||
&& conditionalExpression instanceof IASTConditionalExpression) //&&
|
||||
&& conditionalExpression instanceof IASTConditionalExpression) // &&
|
||||
return conditionalExpression;
|
||||
switch (LT(1)) {
|
||||
case IToken.tASSIGN:
|
||||
|
@ -646,7 +653,8 @@ public class GNUCSourceParser extends AbstractGNUSourceCodeParser {
|
|||
conditionalExpression);
|
||||
case IToken.tSTARASSIGN:
|
||||
return assignmentOperatorExpression(
|
||||
IASTBinaryExpression.op_multiplyAssign, conditionalExpression);
|
||||
IASTBinaryExpression.op_multiplyAssign,
|
||||
conditionalExpression);
|
||||
case IToken.tDIVASSIGN:
|
||||
return assignmentOperatorExpression(
|
||||
IASTBinaryExpression.op_divideAssign, conditionalExpression);
|
||||
|
@ -677,7 +685,8 @@ public class GNUCSourceParser extends AbstractGNUSourceCodeParser {
|
|||
conditionalExpression);
|
||||
case IToken.tBITORASSIGN:
|
||||
return assignmentOperatorExpression(
|
||||
IASTBinaryExpression.op_binaryOrAssign, conditionalExpression);
|
||||
IASTBinaryExpression.op_binaryOrAssign,
|
||||
conditionalExpression);
|
||||
}
|
||||
return conditionalExpression;
|
||||
}
|
||||
|
@ -902,8 +911,8 @@ public class GNUCSourceParser extends AbstractGNUSourceCodeParser {
|
|||
IASTTypeId t = typeId(false, false);
|
||||
int lastOffset = consume(IToken.tRPAREN).getEndOffset();
|
||||
IASTInitializer i = cInitializerClause(Collections.EMPTY_LIST);
|
||||
firstExpression = buildTypeIdInitializerExpression(t, i, offset,
|
||||
lastOffset);
|
||||
firstExpression = buildTypeIdInitializerExpression(t, i,
|
||||
offset, lastOffset);
|
||||
break;
|
||||
} catch (BacktrackException bt) {
|
||||
backup(m);
|
||||
|
@ -1109,16 +1118,16 @@ public class GNUCSourceParser extends AbstractGNUSourceCodeParser {
|
|||
literalExpression.setKind(IASTLiteralExpression.lk_char_constant);
|
||||
literalExpression.setValue(t.getImage());
|
||||
((ASTNode) literalExpression).setOffsetAndLength(t.getOffset(), t
|
||||
.getLength() );
|
||||
.getLength());
|
||||
return literalExpression;
|
||||
case IToken.tLPAREN:
|
||||
t = consume();
|
||||
//TODO - do we need to return a wrapper?
|
||||
// TODO - do we need to return a wrapper?
|
||||
IASTExpression lhs = expression();
|
||||
int finalOffset = consume(IToken.tRPAREN).getEndOffset();
|
||||
return buildUnaryExpression(
|
||||
IASTUnaryExpression.op_bracketedPrimary, lhs, t.getOffset(),
|
||||
finalOffset);
|
||||
IASTUnaryExpression.op_bracketedPrimary, lhs,
|
||||
t.getOffset(), finalOffset);
|
||||
case IToken.tIDENTIFIER:
|
||||
|
||||
int startingOffset = LA(1).getOffset();
|
||||
|
@ -1153,8 +1162,9 @@ public class GNUCSourceParser extends AbstractGNUSourceCodeParser {
|
|||
return new CASTIdExpression();
|
||||
}
|
||||
|
||||
protected IASTTypeId typeId(boolean skipArrayModifiers, boolean forNewExpression)
|
||||
throws EndOfFileException, BacktrackException {
|
||||
protected IASTTypeId typeId(boolean skipArrayModifiers,
|
||||
boolean forNewExpression) throws EndOfFileException,
|
||||
BacktrackException {
|
||||
IToken mark = mark();
|
||||
int startingOffset = mark.getOffset();
|
||||
IASTDeclSpecifier declSpecifier = null;
|
||||
|
@ -1282,7 +1292,7 @@ public class GNUCSourceParser extends AbstractGNUSourceCodeParser {
|
|||
|
||||
declSpecifiers: for (;;) {
|
||||
switch (LT(1)) {
|
||||
//Storage Class Specifiers
|
||||
// Storage Class Specifiers
|
||||
case IToken.t_auto:
|
||||
last = consume();
|
||||
storageClass = IASTDeclSpecifier.sc_auto;
|
||||
|
@ -1305,13 +1315,13 @@ public class GNUCSourceParser extends AbstractGNUSourceCodeParser {
|
|||
last = consume();
|
||||
break;
|
||||
|
||||
//Function Specifier
|
||||
// Function Specifier
|
||||
case IToken.t_inline:
|
||||
isInline = true;
|
||||
last = consume();
|
||||
break;
|
||||
|
||||
//Type Qualifiers
|
||||
// Type Qualifiers
|
||||
case IToken.t_const:
|
||||
isConst = true;
|
||||
last = consume();
|
||||
|
@ -1325,7 +1335,7 @@ public class GNUCSourceParser extends AbstractGNUSourceCodeParser {
|
|||
last = consume();
|
||||
break;
|
||||
|
||||
//Type Specifiers
|
||||
// Type Specifiers
|
||||
case IToken.t_void:
|
||||
flags.setEncounteredRawType(true);
|
||||
last = consume();
|
||||
|
@ -1406,7 +1416,7 @@ public class GNUCSourceParser extends AbstractGNUSourceCodeParser {
|
|||
break;
|
||||
case IToken.tSEMI:
|
||||
case IToken.tASSIGN:
|
||||
//TODO more
|
||||
// TODO more
|
||||
break declSpecifiers;
|
||||
}
|
||||
|
||||
|
@ -1542,8 +1552,8 @@ public class GNUCSourceParser extends AbstractGNUSourceCodeParser {
|
|||
* "}"
|
||||
*
|
||||
* @param owner
|
||||
* IParserCallback object that represents the declaration that owns
|
||||
* this classSpecifier
|
||||
* IParserCallback object that represents the declaration that
|
||||
* owns this classSpecifier
|
||||
*
|
||||
* @return TODO
|
||||
* @throws BacktrackException
|
||||
|
@ -1806,8 +1816,9 @@ public class GNUCSourceParser extends AbstractGNUSourceCodeParser {
|
|||
for (int k = 0; k < decltors.length; k++) {
|
||||
boolean decltorOk = false;
|
||||
for (int j = 0; j < parmNames.length; j++) {
|
||||
if (CharArrayUtils.equals(decltors[k]
|
||||
.getName().toCharArray(),
|
||||
if (CharArrayUtils.equals(
|
||||
decltors[k].getName()
|
||||
.toCharArray(),
|
||||
parmNames[j].toCharArray())) {
|
||||
decltorOk = true;
|
||||
break;
|
||||
|
@ -1828,8 +1839,8 @@ public class GNUCSourceParser extends AbstractGNUSourceCodeParser {
|
|||
((ASTNode) declaration).getOffset());
|
||||
}
|
||||
} catch (BacktrackException b) {
|
||||
parmDeclarations[i] = createKnRCProblemDeclaration(b
|
||||
.getLength(), b.getOffset());
|
||||
parmDeclarations[i] = createKnRCProblemDeclaration(
|
||||
b.getLength(), b.getOffset());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1893,7 +1904,7 @@ public class GNUCSourceParser extends AbstractGNUSourceCodeParser {
|
|||
IASTDeclarator d = null;
|
||||
if (numKnRCParms > 0) {
|
||||
ICASTKnRFunctionDeclarator functionDecltor = createKnRFunctionDeclarator();
|
||||
parmDeclarations = removeNullDeclarations( parmDeclarations );
|
||||
parmDeclarations = removeNullDeclarations(parmDeclarations);
|
||||
for (int i = 0; i < parmDeclarations.length; ++i) {
|
||||
if (parmDeclarations[i] != null
|
||||
&& !(parmDeclarations[i] instanceof IASTProblemDeclaration)) {
|
||||
|
@ -1908,7 +1919,8 @@ public class GNUCSourceParser extends AbstractGNUSourceCodeParser {
|
|||
if (declaratorName != null) {
|
||||
functionDecltor.setName(declaratorName);
|
||||
declaratorName.setParent(functionDecltor);
|
||||
declaratorName.setPropertyInParent(IASTDeclarator.DECLARATOR_NAME);
|
||||
declaratorName
|
||||
.setPropertyInParent(IASTDeclarator.DECLARATOR_NAME);
|
||||
}
|
||||
|
||||
for (int i = 0; i < parmNames.length; ++i) {
|
||||
|
@ -1941,8 +1953,8 @@ public class GNUCSourceParser extends AbstractGNUSourceCodeParser {
|
|||
} else if (bitField != null) {
|
||||
IASTFieldDeclarator fl = createFieldDeclarator();
|
||||
fl.setBitFieldSize(bitField);
|
||||
bitField.setParent( fl );
|
||||
bitField.setPropertyInParent( IASTFieldDeclarator.FIELD_SIZE );
|
||||
bitField.setParent(fl);
|
||||
bitField.setPropertyInParent(IASTFieldDeclarator.FIELD_SIZE);
|
||||
d = fl;
|
||||
} else {
|
||||
d = createDeclarator();
|
||||
|
@ -1973,19 +1985,20 @@ public class GNUCSourceParser extends AbstractGNUSourceCodeParser {
|
|||
* @param parmDeclarations
|
||||
* @return
|
||||
*/
|
||||
private IASTDeclaration[] removeNullDeclarations(IASTDeclaration[] parmDeclarations) {
|
||||
private IASTDeclaration[] removeNullDeclarations(
|
||||
IASTDeclaration[] parmDeclarations) {
|
||||
int nullCount = 0;
|
||||
for( int i = 0; i < parmDeclarations.length; ++i )
|
||||
{
|
||||
if( parmDeclarations[i] == null )
|
||||
for (int i = 0; i < parmDeclarations.length; ++i) {
|
||||
if (parmDeclarations[i] == null)
|
||||
++nullCount;
|
||||
}
|
||||
if( nullCount == 0 ) return parmDeclarations;
|
||||
IASTDeclaration [] result = new IASTDeclaration[ parmDeclarations.length - nullCount ];
|
||||
if (nullCount == 0)
|
||||
return parmDeclarations;
|
||||
IASTDeclaration[] result = new IASTDeclaration[parmDeclarations.length
|
||||
- nullCount];
|
||||
int count = 0;
|
||||
for( int i = 0; i < parmDeclarations.length; ++i )
|
||||
{
|
||||
if( parmDeclarations[i] != null )
|
||||
for (int i = 0; i < parmDeclarations.length; ++i) {
|
||||
if (parmDeclarations[i] != null)
|
||||
result[count++] = parmDeclarations[i];
|
||||
}
|
||||
return result;
|
||||
|
@ -2038,7 +2051,7 @@ public class GNUCSourceParser extends AbstractGNUSourceCodeParser {
|
|||
throws EndOfFileException, BacktrackException {
|
||||
|
||||
while (LT(1) == IToken.tLBRACKET) {
|
||||
//eat the '['
|
||||
// eat the '['
|
||||
int startOffset = consume(IToken.tLBRACKET).getOffset();
|
||||
|
||||
boolean isStatic = false;
|
||||
|
@ -2068,7 +2081,7 @@ public class GNUCSourceParser extends AbstractGNUSourceCodeParser {
|
|||
case IToken.tSTAR:
|
||||
isVarSized = true;
|
||||
consume();
|
||||
//deliberate fall through
|
||||
// deliberate fall through
|
||||
default:
|
||||
break outerLoop;
|
||||
}
|
||||
|
@ -2085,7 +2098,7 @@ public class GNUCSourceParser extends AbstractGNUSourceCodeParser {
|
|||
int lastOffset = consume(IToken.tRBRACKET).getEndOffset();
|
||||
|
||||
IASTArrayModifier arrayMod = null;
|
||||
if (!(isStatic || isRestrict || isConst || isVolatile || isVarSized ))
|
||||
if (!(isStatic || isRestrict || isConst || isVolatile || isVarSized))
|
||||
arrayMod = createArrayModifier();
|
||||
else {
|
||||
ICASTArrayModifier temp = createCArrayModifier();
|
||||
|
@ -2165,7 +2178,7 @@ public class GNUCSourceParser extends AbstractGNUSourceCodeParser {
|
|||
try {
|
||||
IASTExpression e = expression();
|
||||
consume(IToken.tSEMI);
|
||||
//TODO is this a problem? Should we wrap this in an expression
|
||||
// TODO is this a problem? Should we wrap this in an expression
|
||||
// statement?
|
||||
return e;
|
||||
} catch (BacktrackException bt) {
|
||||
|
@ -2395,14 +2408,14 @@ public class GNUCSourceParser extends AbstractGNUSourceCodeParser {
|
|||
return parseIfStatement();
|
||||
case IToken.t_switch:
|
||||
return parseSwitchStatement();
|
||||
//iteration statements
|
||||
// iteration statements
|
||||
case IToken.t_while:
|
||||
return parseWhileStatement();
|
||||
case IToken.t_do:
|
||||
return parseDoStatement();
|
||||
case IToken.t_for:
|
||||
return parseForStatement();
|
||||
//jump statement
|
||||
// jump statement
|
||||
case IToken.t_break:
|
||||
return parseBreakStatement();
|
||||
case IToken.t_continue:
|
||||
|
@ -2481,7 +2494,8 @@ public class GNUCSourceParser extends AbstractGNUSourceCodeParser {
|
|||
consume();
|
||||
if (previousWasIdentifier == true) {
|
||||
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; {}
|
||||
}
|
||||
previousWasIdentifier = true;
|
||||
|
@ -2536,15 +2550,4 @@ public class GNUCSourceParser extends AbstractGNUSourceCodeParser {
|
|||
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.IASTUnaryExpression;
|
||||
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.cpp.ICPPASTBinaryExpression;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTCastExpression;
|
||||
|
@ -4824,14 +4822,4 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser {
|
|||
.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