mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-29 19:45:01 +02:00
patch from Devin Steffler for bug 97020
This commit is contained in:
parent
a0e5adac22
commit
e5e342776d
3 changed files with 237 additions and 720 deletions
File diff suppressed because it is too large
Load diff
|
@ -13,7 +13,6 @@ package org.eclipse.cdt.internal.core.dom.parser.c;
|
|||
import org.eclipse.cdt.core.dom.ast.DOMException;
|
||||
import org.eclipse.cdt.core.dom.ast.IType;
|
||||
import org.eclipse.cdt.core.dom.ast.ITypedef;
|
||||
import org.eclipse.cdt.core.dom.ast.c.ICASTPointer;
|
||||
import org.eclipse.cdt.core.dom.ast.c.ICPointerType;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.ITypeContainer;
|
||||
|
||||
|
@ -21,14 +20,18 @@ import org.eclipse.cdt.internal.core.dom.parser.ITypeContainer;
|
|||
* @author dsteffle
|
||||
*/
|
||||
public class CPointerType implements ICPointerType, ITypeContainer {
|
||||
|
||||
static public final int IS_CONST = 1;
|
||||
static public final int IS_RESTRICT = 1 << 1;
|
||||
static public final int IS_VOLATILE = 1 << 2;
|
||||
|
||||
IType nextType = null;
|
||||
ICASTPointer pointer = null;
|
||||
private int qualifiers = 0;
|
||||
|
||||
public CPointerType() {}
|
||||
|
||||
public CPointerType(IType next) {
|
||||
public CPointerType(IType next, int qualifiers) {
|
||||
this.nextType = next;
|
||||
this.qualifiers = qualifiers;
|
||||
}
|
||||
|
||||
public boolean isSameType( IType obj ){
|
||||
|
@ -56,7 +59,7 @@ public class CPointerType implements ICPointerType, ITypeContainer {
|
|||
* @see org.eclipse.cdt.core.dom.ast.c.ICPointerType#isRestrict()
|
||||
*/
|
||||
public boolean isRestrict() {
|
||||
return pointer.isRestrict();
|
||||
return (qualifiers & IS_RESTRICT) != 0;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
|
@ -74,20 +77,16 @@ public class CPointerType implements ICPointerType, ITypeContainer {
|
|||
* @see org.eclipse.cdt.core.dom.ast.IPointerType#isConst()
|
||||
*/
|
||||
public boolean isConst() {
|
||||
return pointer.isConst();
|
||||
return (qualifiers & IS_CONST) != 0;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.dom.ast.IPointerType#isVolatile()
|
||||
*/
|
||||
public boolean isVolatile() {
|
||||
return pointer.isVolatile();
|
||||
return (qualifiers & IS_VOLATILE) != 0;
|
||||
}
|
||||
|
||||
public void setPointer(ICASTPointer pointer) {
|
||||
this.pointer = pointer;
|
||||
}
|
||||
|
||||
|
||||
public Object clone(){
|
||||
IType t = null;
|
||||
try {
|
||||
|
@ -97,4 +96,8 @@ public class CPointerType implements ICPointerType, ITypeContainer {
|
|||
}
|
||||
return t;
|
||||
}
|
||||
|
||||
public void setQualifiers(int qualifiers) {
|
||||
this.qualifiers = qualifiers;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -645,7 +645,7 @@ public class CVisitor {
|
|||
if( op == IASTUnaryExpression.op_star && (type instanceof IPointerType || type instanceof IArrayType) ){
|
||||
return ((ITypeContainer)type).getType();
|
||||
} else if( op == IASTUnaryExpression.op_amper ){
|
||||
return new CPointerType( type );
|
||||
return new CPointerType( type, 0 );
|
||||
}
|
||||
return type;
|
||||
} else if( expression instanceof IASTLiteralExpression ){
|
||||
|
@ -659,7 +659,7 @@ public class CVisitor {
|
|||
case IASTLiteralExpression.lk_string_literal:
|
||||
IType type = new CBasicType( IBasicType.t_char, 0, expression );
|
||||
type = new CQualifierType( type, true, false, false );
|
||||
return new CPointerType( type );
|
||||
return new CPointerType( type, 0 );
|
||||
}
|
||||
} else if( expression instanceof IASTBinaryExpression ){
|
||||
IASTBinaryExpression binary = (IASTBinaryExpression) expression;
|
||||
|
@ -712,7 +712,7 @@ public class CVisitor {
|
|||
return e.getProblem();
|
||||
}
|
||||
} else if( op == IASTUnaryExpression.op_amper ){
|
||||
return new CPointerType( type );
|
||||
return new CPointerType( type, 0 );
|
||||
} else if ( type instanceof CBasicType ){
|
||||
((CBasicType)type).setValue( expression );
|
||||
}
|
||||
|
@ -1581,7 +1581,7 @@ public class CVisitor {
|
|||
type = new CQualifiedPointerType( at.getType(), at.getModifier() );
|
||||
} else if( type instanceof IFunctionType ) {
|
||||
//-8 A declaration of a parameter as "function returning type" shall be adjusted to "pointer to function returning type"
|
||||
type = new CPointerType( type );
|
||||
type = new CPointerType( type, 0 );
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1755,19 +1755,31 @@ public class CVisitor {
|
|||
|
||||
if (ptrs.length == 1) {
|
||||
pointerType.setType(lastType);
|
||||
pointerType.setPointer((ICASTPointer)ptrs[0]);
|
||||
pointerType.setQualifiers(
|
||||
(((ICASTPointer)ptrs[0]).isConst() ? CPointerType.IS_CONST : 0) |
|
||||
(((ICASTPointer)ptrs[0]).isRestrict() ? CPointerType.IS_RESTRICT : 0) |
|
||||
(((ICASTPointer)ptrs[0]).isVolatile() ? CPointerType.IS_VOLATILE : 0));
|
||||
} else {
|
||||
CPointerType tempType = new CPointerType();
|
||||
pointerType.setType(tempType);
|
||||
pointerType.setPointer((ICASTPointer)ptrs[ptrs.length - 1]);
|
||||
pointerType.setQualifiers(
|
||||
(((ICASTPointer)ptrs[ptrs.length - 1]).isConst() ? CPointerType.IS_CONST : 0) |
|
||||
(((ICASTPointer)ptrs[ptrs.length - 1]).isRestrict() ? CPointerType.IS_RESTRICT : 0) |
|
||||
(((ICASTPointer)ptrs[ptrs.length - 1]).isVolatile() ? CPointerType.IS_VOLATILE : 0));
|
||||
int i = ptrs.length - 2;
|
||||
for (; i > 0; i--) {
|
||||
tempType.setType(new CPointerType());
|
||||
tempType.setPointer((ICASTPointer)ptrs[i]);
|
||||
tempType.setQualifiers(
|
||||
(((ICASTPointer)ptrs[i]).isConst() ? CPointerType.IS_CONST : 0) |
|
||||
(((ICASTPointer)ptrs[i]).isRestrict() ? CPointerType.IS_RESTRICT : 0) |
|
||||
(((ICASTPointer)ptrs[i]).isVolatile() ? CPointerType.IS_VOLATILE : 0));
|
||||
tempType = (CPointerType)tempType.getType();
|
||||
}
|
||||
tempType.setType(lastType);
|
||||
tempType.setPointer((ICASTPointer)ptrs[i]);
|
||||
tempType.setQualifiers(
|
||||
(((ICASTPointer)ptrs[i]).isConst() ? CPointerType.IS_CONST : 0) |
|
||||
(((ICASTPointer)ptrs[i]).isRestrict() ? CPointerType.IS_RESTRICT : 0) |
|
||||
(((ICASTPointer)ptrs[i]).isVolatile() ? CPointerType.IS_VOLATILE : 0));
|
||||
}
|
||||
|
||||
return pointerType;
|
||||
|
|
Loading…
Add table
Reference in a new issue