1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-04-23 22:52:11 +02:00

Remove CQualifiedPointerType, bug 269670.

This commit is contained in:
Markus Schorn 2009-03-24 17:39:00 +00:00
parent aeb02db39d
commit b90a03c48b
2 changed files with 12 additions and 100 deletions

View file

@ -1,96 +0,0 @@
/*******************************************************************************
* Copyright (c) 2005, 2008 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* IBM Rational Software - Initial API and implementation
* Markus Schorn (Wind River Systems)
*******************************************************************************/
package org.eclipse.cdt.internal.core.dom.parser.c;
import org.eclipse.cdt.core.dom.ast.IASTArrayModifier;
import org.eclipse.cdt.core.dom.ast.IType;
import org.eclipse.cdt.core.dom.ast.ITypedef;
import org.eclipse.cdt.core.dom.ast.c.ICASTArrayModifier;
import org.eclipse.cdt.core.dom.ast.c.ICPointerType;
import org.eclipse.cdt.internal.core.dom.parser.ITypeContainer;
import org.eclipse.cdt.internal.core.index.IIndexType;
/**
* @author dsteffle
*/
public class CQualifiedPointerType implements ICPointerType, ITypeContainer {
IType nextType = null;
IASTArrayModifier mod = null;
public CQualifiedPointerType(IType next, IASTArrayModifier mod) {
this.nextType = next;
if (mod instanceof ICASTArrayModifier) this.mod = mod;
}
/* (non-Javadoc)
* @see org.eclipse.cdt.core.dom.ast.c.ICPointerType#isRestrict()
*/
public boolean isRestrict() {
if (mod == null || !(mod instanceof ICASTArrayModifier)) return false;
return ((ICASTArrayModifier)mod).isRestrict();
}
/* (non-Javadoc)
* @see org.eclipse.cdt.core.dom.ast.IPointerType#getType()
*/
public IType getType() {
return nextType;
}
public void setType(IType type) {
nextType = type;
}
/* (non-Javadoc)
* @see org.eclipse.cdt.core.dom.ast.IPointerType#isConst()
*/
public boolean isConst() {
if (mod == null || !(mod instanceof ICASTArrayModifier)) return false;
return ((ICASTArrayModifier)mod).isConst();
}
/* (non-Javadoc)
* @see org.eclipse.cdt.core.dom.ast.IPointerType#isVolatile()
*/
public boolean isVolatile() {
if (mod == null || !(mod instanceof ICASTArrayModifier)) return false;
return ((ICASTArrayModifier)mod).isVolatile();
}
@Override
public Object clone(){
IType t = null;
try {
t = (IType) super.clone();
} catch ( CloneNotSupportedException e ) {
//not going to happen
}
return t;
}
/* (non-Javadoc)
* @see org.eclipse.cdt.core.dom.ast.IType#isSameType(org.eclipse.cdt.core.dom.ast.IType)
*/
public boolean isSameType( IType type ) {
if( type == this )
return true;
if( type instanceof ITypedef || type instanceof IIndexType)
return type.isSameType( this );
if( type instanceof CQualifiedPointerType ){
CQualifiedPointerType qual = (CQualifiedPointerType) type;
if( qual.isConst() == isConst() && qual.isRestrict() == isRestrict() && qual.isVolatile() == isVolatile() )
return getType().isSameType( qual.getType() );
}
return false;
}
}

View file

@ -51,7 +51,6 @@ import org.eclipse.cdt.core.dom.ast.IASTStandardFunctionDeclarator;
import org.eclipse.cdt.core.dom.ast.IASTStatement;
import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit;
import org.eclipse.cdt.core.dom.ast.IASTTypeId;
import org.eclipse.cdt.core.dom.ast.IArrayType;
import org.eclipse.cdt.core.dom.ast.IBasicType;
import org.eclipse.cdt.core.dom.ast.IBinding;
import org.eclipse.cdt.core.dom.ast.ICompositeType;
@ -78,6 +77,7 @@ import org.eclipse.cdt.core.dom.ast.c.ICASTFieldDesignator;
import org.eclipse.cdt.core.dom.ast.c.ICASTPointer;
import org.eclipse.cdt.core.dom.ast.c.ICASTSimpleDeclSpecifier;
import org.eclipse.cdt.core.dom.ast.c.ICASTTypedefNameSpecifier;
import org.eclipse.cdt.core.dom.ast.c.ICArrayType;
import org.eclipse.cdt.core.dom.ast.c.ICCompositeTypeScope;
import org.eclipse.cdt.core.dom.ast.c.ICFunctionScope;
import org.eclipse.cdt.core.dom.ast.gnu.c.ICASTKnRFunctionDeclarator;
@ -1277,9 +1277,17 @@ public class CVisitor extends ASTQueries {
if (isParameter) {
//C99: 6.7.5.3-7 a declaration of a parameter as "array of type" shall be adjusted to "qualified pointer to type", where the
//type qualifiers (if any) are those specified within the[and] of the array type derivation
if (type instanceof IArrayType) {
CArrayType at = (CArrayType) type;
type = new CQualifiedPointerType(at.getType(), at.getModifier());
if (type instanceof ICArrayType) {
ICArrayType at = (ICArrayType) type;
try {
int q= 0;
if (at.isConst()) q |= CPointerType.IS_CONST;
if (at.isVolatile()) q |= CPointerType.IS_VOLATILE;
if (at.isRestrict()) q |= CPointerType.IS_RESTRICT;
type = new CPointerType(at.getType(), q);
} catch (DOMException e) {
// stick to the array
}
} 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, 0);