From b90a03c48b74bd4dcc768e2592894ec3f3de223d Mon Sep 17 00:00:00 2001 From: Markus Schorn Date: Tue, 24 Mar 2009 17:39:00 +0000 Subject: [PATCH] Remove CQualifiedPointerType, bug 269670. --- .../dom/parser/c/CQualifiedPointerType.java | 96 ------------------- .../internal/core/dom/parser/c/CVisitor.java | 16 +++- 2 files changed, 12 insertions(+), 100 deletions(-) delete mode 100644 core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CQualifiedPointerType.java diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CQualifiedPointerType.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CQualifiedPointerType.java deleted file mode 100644 index 6512276cd6a..00000000000 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CQualifiedPointerType.java +++ /dev/null @@ -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; - } -} diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CVisitor.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CVisitor.java index 06d88921e64..62ff9e25614 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CVisitor.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CVisitor.java @@ -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);