mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-07-30 20:35:38 +02:00
Bug 317146: Problem binding in composite factory.
This commit is contained in:
parent
bc70607da5
commit
888b9c3af6
4 changed files with 34 additions and 17 deletions
|
@ -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());
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue