mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-06-08 18:26:01 +02:00
fix bug 84186
This commit is contained in:
parent
993bdc690d
commit
ec8969b5e6
2 changed files with 21 additions and 13 deletions
|
@ -651,20 +651,23 @@ public class AST2Tests extends AST2BaseTest {
|
|||
|
||||
// test tu.getDeclarations(IBinding)
|
||||
IASTName[] decls = tu.getDeclarations(name_A1.resolveBinding());
|
||||
assertEquals(decls.length, 1);
|
||||
assertEquals(decls.length, 2);
|
||||
assertEquals(decls[0], name_A1);
|
||||
assertEquals(decls[1], name_Adef);
|
||||
|
||||
decls = tu.getDeclarations(name_A2.resolveBinding());
|
||||
assertEquals(decls.length, 1);
|
||||
assertEquals(decls.length, 2);
|
||||
assertEquals(decls[0], name_A1);
|
||||
assertEquals(decls[1], name_Adef);
|
||||
|
||||
decls = tu.getDeclarations(name_a.resolveBinding());
|
||||
assertEquals(decls.length, 1);
|
||||
assertEquals(decls[0], name_a);
|
||||
|
||||
decls = tu.getDeclarations(name_Adef.resolveBinding());
|
||||
assertEquals(decls.length, 1);
|
||||
assertEquals(decls.length, 2);
|
||||
assertEquals(decls[0], name_A1);
|
||||
assertEquals(decls[1], name_Adef);
|
||||
|
||||
decls = tu.getDeclarations(name_i.resolveBinding());
|
||||
assertEquals(decls.length, 1);
|
||||
|
|
|
@ -55,7 +55,6 @@ import org.eclipse.cdt.core.dom.ast.IASTPointerOperator;
|
|||
import org.eclipse.cdt.core.dom.ast.IASTProblem;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTProblemHolder;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTReturnStatement;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTSimpleDeclSpecifier;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTSimpleDeclaration;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTStandardFunctionDeclarator;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTStatement;
|
||||
|
@ -340,28 +339,34 @@ public class CVisitor {
|
|||
* @see org.eclipse.cdt.internal.core.dom.parser.c.CVisitor.CBaseVisitorAction#processDeclSpecifier(org.eclipse.cdt.core.dom.ast.IASTDeclSpecifier)
|
||||
*/
|
||||
public int processDeclSpecifier(IASTDeclSpecifier declSpec) {
|
||||
if ( declSpec instanceof IASTSimpleDeclSpecifier || declSpec instanceof ICASTTypedefNameSpecifier )
|
||||
if ( compositeTypeDeclared && declSpec instanceof ICASTTypedefNameSpecifier )
|
||||
return PROCESS_CONTINUE;
|
||||
|
||||
//if the binding isn't declared in a decl spec, skip it
|
||||
if( !(binding instanceof ICompositeType) && !(binding instanceof IEnumeration) )
|
||||
return PROCESS_CONTINUE;
|
||||
|
||||
if ( !compositeTypeDeclared && declSpec != null && declSpec instanceof IASTCompositeTypeSpecifier ) {
|
||||
if ( binding instanceof ICompositeType && declSpec instanceof IASTCompositeTypeSpecifier ) {
|
||||
if( ((IASTCompositeTypeSpecifier)declSpec).getName().resolveBinding() == binding) {
|
||||
compositeTypeDeclared = true;
|
||||
addName(((IASTCompositeTypeSpecifier)declSpec).getName());
|
||||
}
|
||||
} else if (!compositeTypeDeclared && declSpec instanceof IASTElaboratedTypeSpecifier ) {
|
||||
if (((IASTElaboratedTypeSpecifier)declSpec).getName().resolveBinding() == binding) {
|
||||
compositeTypeDeclared = true;
|
||||
addName(((IASTElaboratedTypeSpecifier)declSpec).getName());
|
||||
}
|
||||
} else if (!compositeTypeDeclared && declSpec instanceof IASTEnumerationSpecifier ) {
|
||||
} else if ( binding instanceof IEnumeration && declSpec instanceof IASTEnumerationSpecifier ) {
|
||||
if( ((IASTEnumerationSpecifier)declSpec).getName().resolveBinding() == binding ) {
|
||||
compositeTypeDeclared = true;
|
||||
addName(((IASTEnumerationSpecifier)declSpec).getName());
|
||||
}
|
||||
} else if( declSpec instanceof IASTElaboratedTypeSpecifier ) {
|
||||
if( compositeTypeDeclared ){
|
||||
IASTNode parent = declSpec.getParent();
|
||||
if( !(parent instanceof IASTSimpleDeclaration) || ((IASTSimpleDeclaration)parent).getDeclarators().length > 0 ){
|
||||
return PROCESS_CONTINUE;
|
||||
}
|
||||
}
|
||||
if (((IASTElaboratedTypeSpecifier)declSpec).getName().resolveBinding() == binding) {
|
||||
compositeTypeDeclared = true;
|
||||
addName(((IASTElaboratedTypeSpecifier)declSpec).getName());
|
||||
}
|
||||
}
|
||||
|
||||
return PROCESS_CONTINUE;
|
||||
|
|
Loading…
Add table
Reference in a new issue