mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-07-29 11:55:40 +02:00
Bug 506529 - NPE when organizing includes
Change-Id: Ib6780aefd2febff4ffb953ae36b1f4312922a5b8
This commit is contained in:
parent
6c3779d38e
commit
d1528d0c5d
2 changed files with 34 additions and 3 deletions
|
@ -419,6 +419,18 @@ public class BindingClassifierTest extends OneSourceMultipleHeadersTestCase {
|
||||||
assertDeclared("A", "B");
|
assertDeclared("A", "B");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// class A {};
|
||||||
|
// class B : public A {};
|
||||||
|
// extern A* a;
|
||||||
|
// extern B* b;
|
||||||
|
|
||||||
|
// void test() {
|
||||||
|
// a = { b };
|
||||||
|
// }
|
||||||
|
public void testInitializerList_506529() throws Exception {
|
||||||
|
assertDefined("B", "a", "b");
|
||||||
|
}
|
||||||
|
|
||||||
// namespace ns1 {
|
// namespace ns1 {
|
||||||
// namespace ns2 {
|
// namespace ns2 {
|
||||||
// class A {};
|
// class A {};
|
||||||
|
|
|
@ -90,6 +90,7 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTCompositeTypeSpecifier.ICPPASTBas
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTConstructorChainInitializer;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTConstructorChainInitializer;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTConstructorInitializer;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTConstructorInitializer;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTDeleteExpression;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTDeleteExpression;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTInitializerList;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTLambdaExpression;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTLambdaExpression;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTNameSpecifier;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTNameSpecifier;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTNamedTypeSpecifier;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTNamedTypeSpecifier;
|
||||||
|
@ -641,7 +642,26 @@ public class BindingClassifier {
|
||||||
}
|
}
|
||||||
|
|
||||||
IType operand1Type = binaryExpression.getOperand1().getExpressionType();
|
IType operand1Type = binaryExpression.getOperand1().getExpressionType();
|
||||||
IType operand2Type = binaryExpression.getOperand2().getExpressionType();
|
IASTInitializerClause operand2 = binaryExpression.getInitOperand2();
|
||||||
|
IType operand2Type;
|
||||||
|
if (operand2 instanceof IASTExpression) {
|
||||||
|
operand2Type = ((IASTExpression) operand2).getExpressionType();
|
||||||
|
} else if (operand2 instanceof ICPPASTInitializerList) {
|
||||||
|
ICPPASTInitializerList initializerList = (ICPPASTInitializerList) operand2;
|
||||||
|
if (binaryExpression.getOperator() == IASTBinaryExpression.op_assign
|
||||||
|
&& initializerList.getSize() == 1) {
|
||||||
|
IASTInitializerClause element = initializerList.getClauses()[0];
|
||||||
|
if (element instanceof IASTExpression) {
|
||||||
|
operand2Type = ((IASTExpression) element).getExpressionType();
|
||||||
|
} else {
|
||||||
|
operand2Type = initializerList.getEvaluation().getType(operand2);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
operand2Type = initializerList.getEvaluation().getType(operand2);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
operand2Type = operand1Type;
|
||||||
|
}
|
||||||
|
|
||||||
boolean expression1DefinitionRequired = true;
|
boolean expression1DefinitionRequired = true;
|
||||||
boolean expression2DefinitionRequired = true;
|
boolean expression2DefinitionRequired = true;
|
||||||
|
@ -664,8 +684,7 @@ public class BindingClassifier {
|
||||||
case IASTBinaryExpression.op_greaterThan:
|
case IASTBinaryExpression.op_greaterThan:
|
||||||
case IASTBinaryExpression.op_lessEqual:
|
case IASTBinaryExpression.op_lessEqual:
|
||||||
case IASTBinaryExpression.op_lessThan:
|
case IASTBinaryExpression.op_lessThan:
|
||||||
// If both operands are identical pointer types, then they don't need to be
|
// If both operands are identical pointer types, then they don't need to be defined.
|
||||||
// defined.
|
|
||||||
if (operand1Type instanceof IPointerType && operand2Type instanceof IPointerType) {
|
if (operand1Type instanceof IPointerType && operand2Type instanceof IPointerType) {
|
||||||
if (!isTypeDefinitionRequiredForConversion(operand2Type, operand1Type)) {
|
if (!isTypeDefinitionRequiredForConversion(operand2Type, operand1Type)) {
|
||||||
expression1DefinitionRequired = false;
|
expression1DefinitionRequired = false;
|
||||||
|
|
Loading…
Add table
Reference in a new issue