mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-29 19:45:01 +02:00
206187: Apply fix, add regression test
This commit is contained in:
parent
af01f4320d
commit
e27f022a1f
2 changed files with 88 additions and 71 deletions
|
@ -63,6 +63,52 @@ public class IndexCPPBindingResolutionBugs extends IndexBindingResolutionTestBas
|
||||||
setStrategy(new SinglePDOMTestStrategy(true));
|
setStrategy(new SinglePDOMTestStrategy(true));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// class testdef{
|
||||||
|
//
|
||||||
|
// public:
|
||||||
|
// void testagain();
|
||||||
|
//
|
||||||
|
// };
|
||||||
|
//
|
||||||
|
// typedef void TAny;
|
||||||
|
//
|
||||||
|
// inline void testCall(TAny* aExpected){}
|
||||||
|
//
|
||||||
|
// testdef* global_cBase;
|
||||||
|
// testdef*& global_cBaseRef = global_cBase;
|
||||||
|
|
||||||
|
// #include "typedefHeader.h"
|
||||||
|
//
|
||||||
|
//
|
||||||
|
// int main(void)
|
||||||
|
// {
|
||||||
|
// testdef* local_cBase;
|
||||||
|
// testdef*& local_cBaseRef = local_cBase;
|
||||||
|
//
|
||||||
|
// testCall( /*1*/ (void *) local_cBase);
|
||||||
|
// testCall( /*2*/ local_cBase);
|
||||||
|
//
|
||||||
|
// testCall( /*3*/ (void *) local_cBaseRef);
|
||||||
|
// testCall( /*4*/ local_cBaseRef);
|
||||||
|
//
|
||||||
|
// testCall( /*5*/ (void *) global_cBase);
|
||||||
|
// testCall( /*6*/ global_cBase);
|
||||||
|
//
|
||||||
|
// testCall( /*7*/ (void *)global_cBaseRef);
|
||||||
|
// testCall( /*8*/ global_cBaseRef);
|
||||||
|
// }
|
||||||
|
public void testBug206187() throws Exception {
|
||||||
|
IBinding b1= getBindingFromASTName("testCall( /*1*/", 8);
|
||||||
|
IBinding b2= getBindingFromASTName("testCall( /*2*/", 8);
|
||||||
|
IBinding b3= getBindingFromASTName("testCall( /*3*/", 8);
|
||||||
|
IBinding b4= getBindingFromASTName("testCall( /*4*/", 8);
|
||||||
|
IBinding b5= getBindingFromASTName("testCall( /*5*/", 8);
|
||||||
|
IBinding b6= getBindingFromASTName("testCall( /*6*/", 8);
|
||||||
|
IBinding b7= getBindingFromASTName("testCall( /*7*/", 8);
|
||||||
|
IBinding b8= getBindingFromASTName("testCall( /*8*/", 8);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// template<typename T1>
|
// template<typename T1>
|
||||||
// class A {};
|
// class A {};
|
||||||
//
|
//
|
||||||
|
|
|
@ -491,12 +491,19 @@ public class CPPSemantics {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static protected class Cost
|
static protected class Cost {
|
||||||
{
|
//Some constants to help clarify things
|
||||||
public Cost( IType s, IType t ){
|
public static final int AMBIGUOUS_USERDEFINED_CONVERSION = 1;
|
||||||
source = s;
|
|
||||||
target = t;
|
public static final int NO_MATCH_RANK = -1;
|
||||||
}
|
public static final int IDENTITY_RANK = 0;
|
||||||
|
public static final int LVALUE_OR_QUALIFICATION_RANK = 0;
|
||||||
|
public static final int PROMOTION_RANK = 1;
|
||||||
|
public static final int CONVERSION_RANK = 2;
|
||||||
|
public static final int DERIVED_TO_BASE_CONVERSION = 3;
|
||||||
|
public static final int USERDEFINED_CONVERSION_RANK = 4;
|
||||||
|
public static final int ELLIPSIS_CONVERSION = 5;
|
||||||
|
public static final int FUZZY_TEMPLATE_PARAMETERS = 6;
|
||||||
|
|
||||||
public IType source;
|
public IType source;
|
||||||
public IType target;
|
public IType target;
|
||||||
|
@ -511,18 +518,10 @@ public class CPPSemantics {
|
||||||
public int rank = -1;
|
public int rank = -1;
|
||||||
public int detail;
|
public int detail;
|
||||||
|
|
||||||
//Some constants to help clarify things
|
public Cost( IType s, IType t ){
|
||||||
public static final int AMBIGUOUS_USERDEFINED_CONVERSION = 1;
|
source = s;
|
||||||
|
target = t;
|
||||||
public static final int NO_MATCH_RANK = -1;
|
}
|
||||||
public static final int IDENTITY_RANK = 0;
|
|
||||||
public static final int LVALUE_OR_QUALIFICATION_RANK = 0;
|
|
||||||
public static final int PROMOTION_RANK = 1;
|
|
||||||
public static final int CONVERSION_RANK = 2;
|
|
||||||
public static final int DERIVED_TO_BASE_CONVERSION = 3;
|
|
||||||
public static final int USERDEFINED_CONVERSION_RANK = 4;
|
|
||||||
public static final int ELLIPSIS_CONVERSION = 5;
|
|
||||||
public static final int FUZZY_TEMPLATE_PARAMETERS = 6;
|
|
||||||
|
|
||||||
public int compare( Cost cost ) throws DOMException{
|
public int compare( Cost cost ) throws DOMException{
|
||||||
int result = 0;
|
int result = 0;
|
||||||
|
@ -2896,27 +2895,35 @@ public class CPPSemantics {
|
||||||
return type;
|
return type;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static IType getUltimateType(IType type, boolean stopAtPointerToMember) {
|
private static IType getUltimateType(IType type, IType[] lastPointerType, boolean stopAtPointerToMember) {
|
||||||
try {
|
try {
|
||||||
while( true ){
|
while( true ){
|
||||||
if( type instanceof ITypedef )
|
if( type instanceof ITypedef )
|
||||||
type = ((ITypedef)type).getType();
|
type= ((ITypedef)type).getType();
|
||||||
else if( type instanceof IQualifierType )
|
else if( type instanceof IQualifierType )
|
||||||
type = ((IQualifierType)type).getType();
|
type= ((IQualifierType)type).getType();
|
||||||
else if( stopAtPointerToMember && type instanceof ICPPPointerToMemberType )
|
else if( stopAtPointerToMember && type instanceof ICPPPointerToMemberType )
|
||||||
return type;
|
return type;
|
||||||
else if( type instanceof IPointerType )
|
else if( type instanceof IPointerType ) {
|
||||||
type = ((IPointerType) type).getType();
|
if(lastPointerType!=null) {
|
||||||
else if( type instanceof ICPPReferenceType )
|
lastPointerType[0]= type;
|
||||||
type = ((ICPPReferenceType)type).getType();
|
}
|
||||||
|
type= ((IPointerType) type).getType();
|
||||||
|
} else if( type instanceof ICPPReferenceType )
|
||||||
|
type= ((ICPPReferenceType)type).getType();
|
||||||
else
|
else
|
||||||
return type;
|
return type;
|
||||||
|
|
||||||
}
|
}
|
||||||
} catch ( DOMException e ) {
|
} catch ( DOMException e ) {
|
||||||
return e.getProblem();
|
return e.getProblem();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static IType getUltimateType(IType type, boolean stopAtPointerToMember) {
|
||||||
|
return getUltimateType(type, null, stopAtPointerToMember);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Descends into type containers, stopping at pointer or
|
* Descends into type containers, stopping at pointer or
|
||||||
* pointer-to-member types.
|
* pointer-to-member types.
|
||||||
|
@ -3002,30 +3009,14 @@ public class CPPSemantics {
|
||||||
boolean canConvert = true;
|
boolean canConvert = true;
|
||||||
int requiredConversion = Cost.IDENTITY_RANK;
|
int requiredConversion = Cost.IDENTITY_RANK;
|
||||||
|
|
||||||
IPointerType op1, op2;
|
|
||||||
IType s = cost.source, t = cost.target;
|
IType s = cost.source, t = cost.target;
|
||||||
boolean constInEveryCV2k = true;
|
boolean constInEveryCV2k = true;
|
||||||
while( true ){
|
while( true ){
|
||||||
op1 = null;
|
s= getUltimateTypeViaTypedefs(s);
|
||||||
op2 = null;
|
t= getUltimateTypeViaTypedefs(t);
|
||||||
while( true ){
|
IPointerType op1= s instanceof IPointerType ? (IPointerType) s : null;
|
||||||
if( s instanceof ITypedef )
|
IPointerType op2= t instanceof IPointerType ? (IPointerType) t : null;
|
||||||
s = ((ITypedef)s).getType();
|
|
||||||
else {
|
|
||||||
if( s instanceof IPointerType )
|
|
||||||
op1 = (IPointerType) s;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
while( true ){
|
|
||||||
if( t instanceof ITypedef )
|
|
||||||
t = ((ITypedef)t).getType();
|
|
||||||
else {
|
|
||||||
if( t instanceof IPointerType )
|
|
||||||
op2 = (IPointerType) t;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if( op1 == null && op2 == null )
|
if( op1 == null && op2 == null )
|
||||||
break;
|
break;
|
||||||
else if( op1 == null ^ op2 == null) {
|
else if( op1 == null ^ op2 == null) {
|
||||||
|
@ -3164,20 +3155,11 @@ public class CPPSemantics {
|
||||||
cost.conversion = 0;
|
cost.conversion = 0;
|
||||||
cost.detail = 0;
|
cost.detail = 0;
|
||||||
|
|
||||||
IType s = getUltimateType( src, true );
|
IType[] sHolder= new IType[1], tHolder= new IType[1];
|
||||||
IType t = getUltimateType( trg, true );
|
IType s = getUltimateType( src, sHolder, true );
|
||||||
|
IType t = getUltimateType( trg, tHolder, true );
|
||||||
IType sPrev = src;
|
IType sPrev= sHolder[0], tPrev= tHolder[0];
|
||||||
while( sPrev instanceof ITypeContainer ){
|
|
||||||
IType next = ((ITypeContainer)sPrev).getType();
|
|
||||||
while( next instanceof IQualifierType || next instanceof ITypedef ){
|
|
||||||
next = ((ITypeContainer)next).getType();
|
|
||||||
}
|
|
||||||
if( next == s )
|
|
||||||
break;
|
|
||||||
sPrev = next;
|
|
||||||
}
|
|
||||||
|
|
||||||
if( src instanceof IBasicType && trg instanceof IPointerType ){
|
if( src instanceof IBasicType && trg instanceof IPointerType ){
|
||||||
//4.10-1 an integral constant expression of integer type that evaluates to 0 can be converted to a pointer type
|
//4.10-1 an integral constant expression of integer type that evaluates to 0 can be converted to a pointer type
|
||||||
IASTExpression exp = ((IBasicType)src).getValue();
|
IASTExpression exp = ((IBasicType)src).getValue();
|
||||||
|
@ -3195,17 +3177,6 @@ public class CPPSemantics {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if( sPrev instanceof IPointerType ){
|
} else if( sPrev instanceof IPointerType ){
|
||||||
IType tPrev = trg;
|
|
||||||
while( tPrev instanceof ITypeContainer ){
|
|
||||||
IType next = ((ITypeContainer)tPrev).getType();
|
|
||||||
while( next instanceof IQualifierType || next instanceof ITypedef ){
|
|
||||||
next = ((ITypeContainer)next).getType();
|
|
||||||
}
|
|
||||||
if( next == t )
|
|
||||||
break;
|
|
||||||
tPrev = next;
|
|
||||||
}
|
|
||||||
|
|
||||||
//4.10-2 an rvalue of type "pointer to cv T", where T is an object type can be
|
//4.10-2 an rvalue of type "pointer to cv T", where T is an object type can be
|
||||||
//converted to an rvalue of type "pointer to cv void"
|
//converted to an rvalue of type "pointer to cv void"
|
||||||
if( tPrev instanceof IPointerType && t instanceof IBasicType && ((IBasicType)t).getType() == IBasicType.t_void ){
|
if( tPrev instanceof IPointerType && t instanceof IBasicType && ((IBasicType)t).getType() == IBasicType.t_void ){
|
||||||
|
|
Loading…
Add table
Reference in a new issue