mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-23 14:42: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
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -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;
|
||||
|
@ -4823,15 +4821,5 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser {
|
|||
return super
|
||||
.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