1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-08-01 21:35:40 +02:00

Bug 317146: Problem binding in composite factory.

This commit is contained in:
Markus Schorn 2010-06-23 12:36:54 +00:00
parent bc70607da5
commit 888b9c3af6
4 changed files with 34 additions and 17 deletions

View file

@ -5905,7 +5905,7 @@ public class AST2Tests extends AST2BaseTest {
IASTTranslationUnit tu= parse(code, lang, false, true, true); IASTTranslationUnit tu= parse(code, lang, false, true, true);
long diff= memoryUsed()-mem; long diff= memoryUsed()-mem;
// allow a copy of the buffer + not even 1 byte per initializer // 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(String.valueOf(diff) + " expected < " + expected, diff < expected);
assertTrue(tu.isFrozen()); assertTrue(tu.isFrozen());
} }

View file

@ -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.IFunction;
import org.eclipse.cdt.core.dom.ast.IParameter; import org.eclipse.cdt.core.dom.ast.IParameter;
import org.eclipse.cdt.core.dom.ast.IPointerType; 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.IScope;
import org.eclipse.cdt.core.dom.ast.IType; import org.eclipse.cdt.core.dom.ast.IType;
import org.eclipse.cdt.core.dom.ast.ITypedef; 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.ICPPMethod;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPNamespace; 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.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.ICPPSpecialization;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateArgument; import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateArgument;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateDefinition; import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateDefinition;
@ -1195,5 +1197,16 @@ public class IndexCPPBindingResolutionBugs extends IndexBindingResolutionTestBas
public void testElaboratedTypeSpecifier_Bug303739() throws Exception { public void testElaboratedTypeSpecifier_Bug303739() throws Exception {
getBindingFromASTName("member=0", -2, ICPPField.class); 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);
}
} }

View file

@ -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.IASTAmbiguousDeclarator;
import org.eclipse.cdt.internal.core.dom.parser.IASTInternalScope; 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.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.CPPASTFieldReference;
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTIdExpression; import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTIdExpression;
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTLiteralExpression; 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. * Returns constructor called by a declarator, or <code>null</code> if no constructor is called.
*/ */
public static ICPPConstructor findImplicitlyCalledConstructor(CPPASTDeclarator declarator) { public static ICPPConstructor findImplicitlyCalledConstructor(final ICPPASTDeclarator declarator) {
if (declarator.getInitializer() == null) { if (declarator.getNestedDeclarator() != null)
IASTNode parent = declarator.getParent(); return null;
if (parent instanceof IASTSimpleDeclaration) { IASTDeclarator dtor= ASTQueries.findOutermostDeclarator(declarator);
IASTDeclSpecifier declSpec = ((IASTSimpleDeclaration) parent).getDeclSpecifier(); IASTNode parent = dtor.getParent();
parent = parent.getParent(); if (parent instanceof IASTSimpleDeclaration) {
if (parent instanceof IASTCompositeTypeSpecifier || if (dtor.getInitializer() == null) {
declSpec.getStorageClass() == IASTDeclSpecifier.sc_extern) { IASTDeclSpecifier declSpec = ((IASTSimpleDeclaration) parent).getDeclSpecifier();
// No initialization is performed for class members and extern declarations parent = parent.getParent();
// without an initializer. if (parent instanceof IASTCompositeTypeSpecifier ||
return null; 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;
} }
/** /**

View file

@ -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.IBinding;
import org.eclipse.cdt.core.dom.ast.IEnumerator; import org.eclipse.cdt.core.dom.ast.IEnumerator;
import org.eclipse.cdt.core.dom.ast.IPointerType; 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.IQualifierType;
import org.eclipse.cdt.core.dom.ast.IType; import org.eclipse.cdt.core.dom.ast.IType;
import org.eclipse.cdt.core.dom.ast.ITypedef; import org.eclipse.cdt.core.dom.ast.ITypedef;
@ -196,7 +197,7 @@ public class CPPCompositesFactory extends AbstractCompositeFactory {
} }
return at; return at;
} }
if (rtype instanceof IBasicType || rtype == null) { if (rtype instanceof IBasicType || rtype == null || rtype instanceof IProblemBinding) {
return rtype; return rtype;
} }