1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-04-29 19:45:01 +02:00

Fixes cost comparison, bug 226877.

This commit is contained in:
Markus Schorn 2008-04-29 17:23:34 +00:00
parent 14e8eb91d4
commit 344265a6a1

View file

@ -92,9 +92,11 @@ class Cost {
if( result == 0 ){ if( result == 0 ){
if( cost.qualification != qualification ){ if( cost.qualification != qualification ){
return cost.qualification - qualification; return cost.qualification - qualification;
} else if( (cost.qualification == qualification) && qualification == 0 ){ }
if( qualification == 0 ){
return 0; return 0;
} else { }
// something is wrong below: // something is wrong below:
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=226877 // https://bugs.eclipse.org/bugs/show_bug.cgi?id=226877
@ -105,55 +107,54 @@ class Cost {
op1 = null; op1 = null;
op2 = null; op2 = null;
while (true) { while (true) {
if( t1 instanceof ITypedef ) if (t1 instanceof ITypedef) {
try { try {
t1 = ((ITypedef) t1).getType(); t1 = ((ITypedef) t1).getType();
} catch (DOMException e) { } catch (DOMException e) {
t1 = e.getProblem(); t1 = e.getProblem();
} }
else { } else {
if (t1 instanceof IPointerType) if (t1 instanceof IPointerType)
op1 = (IPointerType) t1; op1 = (IPointerType) t1;
break; break;
} }
} }
while (true) { while (true) {
if( t2 instanceof ITypedef ) if (t2 instanceof ITypedef) {
try { try {
t2 = ((ITypedef) t2).getType(); t2 = ((ITypedef) t2).getType();
} catch (DOMException e) { } catch (DOMException e) {
t2 = e.getProblem(); t2 = e.getProblem();
} }
else { } else {
if (t2 instanceof IPointerType) if (t2 instanceof IPointerType)
op1 = (IPointerType) t2; op2 = (IPointerType) t2;
break; break;
} }
} }
if (op1 == null || op2 == null) if (op1 == null || op2 == null)
break; break;
int cmp = ( op1.isConst() ? 1 : 0 ) + ( op1.isVolatile() ? 1 : 0 ) - int cmp = (op1.isConst() ? 1 : 0) + (op1.isVolatile() ? 1 : 0)
( op2.isConst() ? 1 : 0 ) + ( op2.isVolatile() ? 1 : 0 ); - (op2.isConst() ? 1 : 0) + (op2.isVolatile() ? 1 : 0);
if( subOrSuper == 0 ) if (cmp != 0) {
if (subOrSuper == 0) {
subOrSuper = cmp; subOrSuper = cmp;
else if( subOrSuper > 0 ^ cmp > 0) {
result = -1;
break;
} }
else if ((subOrSuper > 0) != (cmp > 0)) {
} return 0;
if( result == -1 ){
result = 0;
} else {
if( op1 == op2 ){
result = subOrSuper;
} else {
result = op1 != null ? 1 : -1;
} }
} }
t1= op1.getType();
t2= op2.getType();
} }
if (op1 != null) {
return 1;
} else if (op2 != null) {
return -1;
}
return 0;
} }
return result; return result;