1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-07-24 17:35:35 +02:00

181735: fix a regression, and some (newly exposed) syntax errors in the unit tests

This commit is contained in:
Andrew Ferguson 2007-04-14 11:15:55 +00:00
parent 512a83717e
commit 2304aeb618
3 changed files with 23 additions and 7 deletions

View file

@ -18,6 +18,7 @@ import org.eclipse.cdt.core.dom.ast.DOMException;
import org.eclipse.cdt.core.dom.ast.IQualifierType;
import org.eclipse.cdt.core.dom.ast.IType;
import org.eclipse.cdt.core.dom.ast.ITypedef;
import org.eclipse.cdt.core.dom.ast.c.ICQualifierType;
import org.eclipse.cdt.internal.core.Util;
import org.eclipse.cdt.internal.core.dom.parser.ITypeContainer;
import org.eclipse.cdt.internal.core.index.IIndexType;
@ -29,7 +30,7 @@ import org.eclipse.core.runtime.CoreException;
* @author Doug Schaefer
*
*/
public class PDOMQualifierType extends PDOMNode implements IQualifierType,
public class PDOMQualifierType extends PDOMNode implements IQualifierType, ICQualifierType,
ITypeContainer, IIndexType {
private static final int FLAGS = PDOMNode.RECORD_SIZE;
@ -39,6 +40,7 @@ public class PDOMQualifierType extends PDOMNode implements IQualifierType,
private static final int CONST = 0x1;
private static final int VOLATILE = 0x2;
private static final int RESTRICT = 0x4;
public PDOMQualifierType(PDOM pdom, int record) {
super(pdom, record);
@ -65,6 +67,8 @@ public class PDOMQualifierType extends PDOMNode implements IQualifierType,
flags |= CONST;
if (type.isVolatile())
flags |= VOLATILE;
if (type instanceof ICQualifierType && ((ICQualifierType)type).isRestrict())
flags |= RESTRICT;
db.putByte(record + FLAGS, flags);
} catch (DOMException e) {
throw new CoreException(Util.createStatus(e));
@ -111,6 +115,15 @@ public class PDOMQualifierType extends PDOMNode implements IQualifierType,
return false;
}
}
public boolean isRestrict() {
try {
return (getFlags() & RESTRICT) != 0;
} catch (CoreException e) {
CCorePlugin.log(e);
return false;
}
}
public boolean isSameType(IType type) {
if( type instanceof ITypedef )
@ -120,7 +133,10 @@ public class PDOMQualifierType extends PDOMNode implements IQualifierType,
IQualifierType pt = (IQualifierType) type;
try {
if( isConst() == pt.isConst() && isVolatile() == pt.isVolatile() ) {
boolean flagsMatch= isConst() == pt.isConst() && isVolatile() == pt.isVolatile();
if(flagsMatch && (type instanceof ICQualifierType))
flagsMatch &= isRestrict() == ((ICQualifierType)type).isRestrict();
if(flagsMatch) {
IType myType= getType();
return myType != null && myType.isSameType( pt.getType() );
}

View file

@ -162,16 +162,16 @@ public abstract class CSelectionTestsAnyIndexer extends BaseSelectionTestsIndexe
// };
// enum E {up, down}; // defines
// int f(int); // declares
// extern X anotherX; // declares
// extern struct X anotherX; // declares
// #include "testCPPSpecDeclsDefs.h"
// int a; // defines
// X anX; // defines
// struct X anX; // defines
// extern const int c; // declares
// int f(int x) {return x+a;} // defines
// struct S; // declares
// typedef int Int; // declares
// S s;
// struct S s;
// Int lhs= s.a+s.b+up+down+anX+0;
public void testCPPSpecDeclsDefs() throws Exception {
StringBuffer[] buffers= getContents(2);

View file

@ -36,7 +36,7 @@ public class CTypeHierarchyTest extends TypeHierarchyBaseTest {
// enum E1 {e1, e2};
// typedef enum E2 {e3, e4} TE2;
// enum E3 {e5, e6};
// typedef E3 TE3;
// typedef enum E3 TE3;
public void testEnumC() throws Exception {
String content= getContentsForTest(1)[0].toString();
IFile file= createFile(getProject(), "enum.c", content);
@ -73,7 +73,7 @@ public class CTypeHierarchyTest extends TypeHierarchyBaseTest {
// enum E1 {e1, e2};
// typedef enum E2 {e3, e4} TE2;
// enum E3 {e5, e6};
// typedef E3 TE3;
// typedef enum E3 TE3;
public void testEnumCFromMember() throws Exception {
String content= getContentsForTest(1)[0].toString();
IFile file= createFile(getProject(), "enummem.c", content);