diff options
author | Markus Schorn | 2010-06-23 12:36:54 +0000 |
---|---|---|
committer | Markus Schorn | 2010-06-23 12:36:54 +0000 |
commit | 888b9c3af647389e94482c6211ccadd1a9e84e08 (patch) | |
tree | 43c738994c0310425327f59109628c0ad20db943 /core | |
parent | bc70607da5975b68f137bb57287767215349e8db (diff) | |
download | org.eclipse.cdt-888b9c3af647389e94482c6211ccadd1a9e84e08.tar.gz org.eclipse.cdt-888b9c3af647389e94482c6211ccadd1a9e84e08.tar.xz org.eclipse.cdt-888b9c3af647389e94482c6211ccadd1a9e84e08.zip |
Bug 317146: Problem binding in composite factory.
Diffstat (limited to 'core')
4 files changed, 34 insertions, 17 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 08c60d43fe7..1a38c8b556a 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 @@ -5905,7 +5905,7 @@ public class AST2Tests extends AST2BaseTest { IASTTranslationUnit tu= parse(code, lang, false, true, true); long diff= memoryUsed()-mem; // allow a copy of the buffer + not even 1 byte per initializer - final int expected = code.length()*2 + AMOUNT/2; + final int expected = code.length()*2 + AMOUNT + AMOUNT/2; assertTrue(String.valueOf(diff) + " expected < " + expected, diff < expected); assertTrue(tu.isFrozen()); } diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/index/tests/IndexCPPBindingResolutionBugs.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/index/tests/IndexCPPBindingResolutionBugs.java index b0d8ef0ccf2..afce606f7ac 100644 --- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/index/tests/IndexCPPBindingResolutionBugs.java +++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/index/tests/IndexCPPBindingResolutionBugs.java @@ -25,6 +25,7 @@ import org.eclipse.cdt.core.dom.ast.IField; import org.eclipse.cdt.core.dom.ast.IFunction; import org.eclipse.cdt.core.dom.ast.IParameter; import org.eclipse.cdt.core.dom.ast.IPointerType; +import org.eclipse.cdt.core.dom.ast.IProblemBinding; import org.eclipse.cdt.core.dom.ast.IScope; import org.eclipse.cdt.core.dom.ast.IType; import org.eclipse.cdt.core.dom.ast.ITypedef; @@ -40,6 +41,7 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPFunctionType; import org.eclipse.cdt.core.dom.ast.cpp.ICPPMethod; import org.eclipse.cdt.core.dom.ast.cpp.ICPPNamespace; import org.eclipse.cdt.core.dom.ast.cpp.ICPPNamespaceScope; +import org.eclipse.cdt.core.dom.ast.cpp.ICPPPointerToMemberType; import org.eclipse.cdt.core.dom.ast.cpp.ICPPSpecialization; import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateArgument; import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateDefinition; @@ -1195,5 +1197,16 @@ public class IndexCPPBindingResolutionBugs extends IndexBindingResolutionTestBas public void testElaboratedTypeSpecifier_Bug303739() throws Exception { getBindingFromASTName("member=0", -2, ICPPField.class); } - + + // typedef int xxx::* MBR_PTR; + + // void test() { + // MBR_PTR x; + // } + public void testProblemInIndexBinding_Bug317146() throws Exception { + ITypedef td= getBindingFromASTName("MBR_PTR", 0, ITypedef.class); + ICPPPointerToMemberType ptrMbr= (ICPPPointerToMemberType) td.getType(); + IType t= ptrMbr.getMemberOfClass(); + assertInstance(t, IProblemBinding.class); + } } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/CPPSemantics.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/CPPSemantics.java index 700be8c0413..5d34b60b2e5 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/CPPSemantics.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/CPPSemantics.java @@ -160,7 +160,6 @@ import org.eclipse.cdt.internal.core.dom.parser.ASTTranslationUnit; import org.eclipse.cdt.internal.core.dom.parser.IASTAmbiguousDeclarator; import org.eclipse.cdt.internal.core.dom.parser.IASTInternalScope; import org.eclipse.cdt.internal.core.dom.parser.ProblemBinding; -import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTDeclarator; import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTFieldReference; import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTIdExpression; import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTLiteralExpression; @@ -2785,21 +2784,25 @@ public class CPPSemantics { /** * Returns constructor called by a declarator, or <code>null</code> if no constructor is called. */ - public static ICPPConstructor findImplicitlyCalledConstructor(CPPASTDeclarator declarator) { - if (declarator.getInitializer() == null) { - IASTNode parent = declarator.getParent(); - if (parent instanceof IASTSimpleDeclaration) { - IASTDeclSpecifier declSpec = ((IASTSimpleDeclaration) parent).getDeclSpecifier(); - parent = parent.getParent(); - if (parent instanceof IASTCompositeTypeSpecifier || - declSpec.getStorageClass() == IASTDeclSpecifier.sc_extern) { - // No initialization is performed for class members and extern declarations - // without an initializer. - return null; - } + public static ICPPConstructor findImplicitlyCalledConstructor(final ICPPASTDeclarator declarator) { + if (declarator.getNestedDeclarator() != null) + return null; + IASTDeclarator dtor= ASTQueries.findOutermostDeclarator(declarator); + IASTNode parent = dtor.getParent(); + if (parent instanceof IASTSimpleDeclaration) { + if (dtor.getInitializer() == null) { + IASTDeclSpecifier declSpec = ((IASTSimpleDeclaration) parent).getDeclSpecifier(); + parent = parent.getParent(); + if (parent instanceof IASTCompositeTypeSpecifier || + declSpec.getStorageClass() == IASTDeclSpecifier.sc_extern) { + // No initialization is performed for class members and extern declarations + // without an initializer. + return null; + } } + return findImplicitlyCalledConstructor(declarator.getName(), dtor.getInitializer()); } - return findImplicitlyCalledConstructor(declarator.getName(), declarator.getInitializer()); + return null; } /** diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/composite/cpp/CPPCompositesFactory.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/composite/cpp/CPPCompositesFactory.java index b44349ff649..db65747d90e 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/composite/cpp/CPPCompositesFactory.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/composite/cpp/CPPCompositesFactory.java @@ -18,6 +18,7 @@ import org.eclipse.cdt.core.dom.ast.IBasicType; import org.eclipse.cdt.core.dom.ast.IBinding; import org.eclipse.cdt.core.dom.ast.IEnumerator; import org.eclipse.cdt.core.dom.ast.IPointerType; +import org.eclipse.cdt.core.dom.ast.IProblemBinding; import org.eclipse.cdt.core.dom.ast.IQualifierType; import org.eclipse.cdt.core.dom.ast.IType; import org.eclipse.cdt.core.dom.ast.ITypedef; @@ -196,7 +197,7 @@ public class CPPCompositesFactory extends AbstractCompositeFactory { } return at; } - if (rtype instanceof IBasicType || rtype == null) { + if (rtype instanceof IBasicType || rtype == null || rtype instanceof IProblemBinding) { return rtype; } |