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

Bug 294730: Declared type of an expression.

This commit is contained in:
Markus Schorn 2010-01-15 18:28:45 +00:00
parent 64c58d1776
commit 5a1293b690
38 changed files with 736 additions and 871 deletions

View file

@ -113,7 +113,6 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPReferenceType;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPUsingDeclaration;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPVariable;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTCompositeTypeSpecifier.ICPPASTBaseSpecifier;
import org.eclipse.cdt.core.dom.ast.gnu.cpp.IGPPASTSimpleDeclSpecifier;
import org.eclipse.cdt.core.dom.ast.gnu.cpp.IGPPPointerToMemberType;
import org.eclipse.cdt.core.dom.ast.gnu.cpp.IGPPPointerType;
import org.eclipse.cdt.core.parser.ParserLanguage;
@ -4670,10 +4669,10 @@ public class AST2CPPTests extends AST2BaseTest {
IASTTranslationUnit tu = parse( getAboveComment(), ParserLanguage.CPP, true, true );
IASTDeclaration[] decls = tu.getDeclarations();
assertTrue(((IGPPASTSimpleDeclSpecifier)((IASTSimpleDeclaration)decls[0]).getDeclSpecifier()).isComplex());
assertEquals(((IGPPASTSimpleDeclSpecifier)((IASTSimpleDeclaration)decls[0]).getDeclSpecifier()).getType(), IASTSimpleDeclSpecifier.t_float);
assertTrue(((IGPPASTSimpleDeclSpecifier)((IASTSimpleDeclaration)decls[1]).getDeclSpecifier()).isComplex());
assertEquals(((IGPPASTSimpleDeclSpecifier)((IASTSimpleDeclaration)decls[1]).getDeclSpecifier()).getType(), IASTSimpleDeclSpecifier.t_double);
assertTrue(((IASTSimpleDeclSpecifier)((IASTSimpleDeclaration)decls[0]).getDeclSpecifier()).isComplex());
assertEquals(((IASTSimpleDeclSpecifier)((IASTSimpleDeclaration)decls[0]).getDeclSpecifier()).getType(), IASTSimpleDeclSpecifier.t_float);
assertTrue(((IASTSimpleDeclSpecifier)((IASTSimpleDeclaration)decls[1]).getDeclSpecifier()).isComplex());
assertEquals(((IASTSimpleDeclSpecifier)((IASTSimpleDeclaration)decls[1]).getDeclSpecifier()).getType(), IASTSimpleDeclSpecifier.t_double);
}
// class _A {
@ -8010,5 +8009,41 @@ public class AST2CPPTests extends AST2BaseTest {
b= bh.assertNonProblem("f(a, 1)", 1);
assertSame(b, glob);
}
// const int&& foo();
// int i;
// struct A { double x; };
// const A* a = new A();
// decltype(foo()) t1(); // type is const int&&
// decltype(i) t2(); // type is int
// decltype(a->x) t3(); // type is double
// decltype((a->x)) t4(); // type is const double&
// __typeof foo() t5(); // type is const int
// __typeof(i) t6(); // type is int
// __typeof(a->x) t7(); // type is const double
// __typeof((a->x)) t8(); // type is const double
public void testDeclType_294730() throws Exception {
String code= getAboveComment();
parseAndCheckBindings(code, ParserLanguage.CPP);
BindingAssertionHelper bh= new BindingAssertionHelper(code, true);
IFunction f= bh.assertNonProblem("t1", 2);
assertEquals("const int &&", ASTTypeUtil.getType(f.getType().getReturnType()));
f= bh.assertNonProblem("t2", 2);
assertEquals("int", ASTTypeUtil.getType(f.getType().getReturnType()));
f= bh.assertNonProblem("t3", 2);
assertEquals("double", ASTTypeUtil.getType(f.getType().getReturnType()));
f= bh.assertNonProblem("t4", 2);
assertEquals("const double &", ASTTypeUtil.getType(f.getType().getReturnType()));
f= bh.assertNonProblem("t5", 2);
assertEquals("const int", ASTTypeUtil.getType(f.getType().getReturnType()));
f= bh.assertNonProblem("t6", 2);
assertEquals("int", ASTTypeUtil.getType(f.getType().getReturnType()));
f= bh.assertNonProblem("t7", 2);
assertEquals("const double", ASTTypeUtil.getType(f.getType().getReturnType()));
f= bh.assertNonProblem("t8", 2);
assertEquals("const double", ASTTypeUtil.getType(f.getType().getReturnType()));
}
}

View file

@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2006, 2009 Wind River Systems, Inc. and others.
* Copyright (c) 2006, 2010 Wind River Systems, Inc. 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
@ -51,7 +51,6 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTParameterDeclaration;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTPointerToMember;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTQualifiedName;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTReferenceOperator;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTSimpleDeclSpecifier;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTSimpleTypeTemplateParameter;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTTemplateId;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTTemplateParameter;
@ -60,7 +59,6 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTTypeId;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTTypenameExpression;
import org.eclipse.cdt.core.dom.ast.gnu.c.ICASTKnRFunctionDeclarator;
import org.eclipse.cdt.core.dom.ast.gnu.cpp.IGPPASTPointer;
import org.eclipse.cdt.core.dom.ast.gnu.cpp.IGPPASTSimpleDeclSpecifier;
import org.eclipse.cdt.core.parser.Keywords;
import org.eclipse.cdt.internal.core.dom.parser.ASTQueries;
@ -579,27 +577,14 @@ public class ASTStringUtil {
if (simpleDeclSpec.isLong()) {
buffer.append(Keywords.LONG).append(' ');
}
if (simpleDeclSpec instanceof ICASTSimpleDeclSpecifier) {
final ICASTSimpleDeclSpecifier cSimpleDeclSpec= (ICASTSimpleDeclSpecifier)simpleDeclSpec;
if (cSimpleDeclSpec.isLongLong()) {
buffer.append(Keywords.LONG_LONG).append(' ');
}
if (cSimpleDeclSpec.isComplex()) {
buffer.append(Keywords._COMPLEX).append(' ');
}
if (cSimpleDeclSpec.isImaginary()) {
buffer.append(Keywords._IMAGINARY).append(' ');
}
switch (simpleDeclSpec.getType()) {
case ICASTSimpleDeclSpecifier.t_Bool:
buffer.append(Keywords._BOOL).append(' ');
break;
}
} else if (simpleDeclSpec instanceof IGPPASTSimpleDeclSpecifier) {
final IGPPASTSimpleDeclSpecifier gppSimpleDeclSpec= (IGPPASTSimpleDeclSpecifier)simpleDeclSpec;
if (gppSimpleDeclSpec.isLongLong()) {
buffer.append(Keywords.LONG_LONG).append(' ');
}
if (simpleDeclSpec.isLongLong()) {
buffer.append(Keywords.LONG_LONG).append(' ');
}
if (simpleDeclSpec.isComplex()) {
buffer.append(Keywords._COMPLEX).append(' ');
}
if (simpleDeclSpec.isImaginary()) {
buffer.append(Keywords._IMAGINARY).append(' ');
}
switch (simpleDeclSpec.getType()) {
case IASTSimpleDeclSpecifier.t_void:
@ -617,10 +602,14 @@ public class ASTStringUtil {
case IASTSimpleDeclSpecifier.t_double:
buffer.append(Keywords.DOUBLE).append(' ');
break;
case ICPPASTSimpleDeclSpecifier.t_bool:
buffer.append(Keywords.BOOL).append(' ');
case IASTSimpleDeclSpecifier.t_bool:
if (simpleDeclSpec instanceof ICASTSimpleDeclSpecifier) {
buffer.append(Keywords.cBOOL).append(' ');
} else {
buffer.append(Keywords.BOOL).append(' ');
}
break;
case ICPPASTSimpleDeclSpecifier.t_wchar_t:
case IASTSimpleDeclSpecifier.t_wchar_t:
buffer.append(Keywords.WCHAR_T).append(' ');
break;
default:

View file

@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2005, 2009 IBM Corporation and others.
* Copyright (c) 2005, 2010 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
@ -13,7 +13,6 @@ package org.eclipse.cdt.core.dom.ast;
import org.eclipse.cdt.core.dom.ast.c.ICASTArrayDesignator;
import org.eclipse.cdt.core.dom.ast.c.ICASTArrayModifier;
import org.eclipse.cdt.core.dom.ast.c.ICASTDeclSpecifier;
import org.eclipse.cdt.core.dom.ast.c.ICASTDesignatedInitializer;
import org.eclipse.cdt.core.dom.ast.c.ICASTDesignator;
import org.eclipse.cdt.core.dom.ast.c.ICASTFieldDesignator;
@ -27,20 +26,15 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTDeleteExpression;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTNewExpression;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTPackExpansionExpression;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTReferenceOperator;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTSimpleDeclSpecifier;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTSimpleTypeConstructorExpression;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTTypeIdExpression;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTTypenameExpression;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTUnaryExpression;
import org.eclipse.cdt.core.dom.ast.gnu.IGNUASTCompoundStatementExpression;
import org.eclipse.cdt.core.dom.ast.gnu.IGNUASTTypeIdExpression;
import org.eclipse.cdt.core.dom.ast.gnu.IGNUASTUnaryExpression;
import org.eclipse.cdt.core.dom.ast.gnu.c.ICASTKnRFunctionDeclarator;
import org.eclipse.cdt.core.dom.ast.gnu.c.IGCCASTArrayRangeDesignator;
import org.eclipse.cdt.core.dom.ast.gnu.cpp.IGPPASTDeclSpecifier;
import org.eclipse.cdt.core.dom.ast.gnu.cpp.IGPPASTPointer;
import org.eclipse.cdt.core.dom.ast.gnu.cpp.IGPPASTSimpleDeclSpecifier;
import org.eclipse.cdt.core.parser.GCCKeywords;
import org.eclipse.cdt.core.parser.Keywords;
import org.eclipse.cdt.internal.core.dom.parser.ASTProblem;
@ -440,7 +434,7 @@ public class ASTSignatureUtil {
StringBuffer result = new StringBuffer();
if (declSpec.getStorageClass() == ICPPASTDeclSpecifier.sc_mutable) {
if (declSpec.getStorageClass() == IASTDeclSpecifier.sc_mutable) {
result.append(Keywords.MUTABLE);
needSpace = true;
}
@ -501,6 +495,14 @@ public class ASTSignatureUtil {
result.append(Keywords.INLINE);
needSpace = true;
}
if (declSpec.isRestrict()) {
if (needSpace) {
result.append(SPACE);
needSpace = false;
}
result.append(Keywords.RESTRICT);
needSpace = true;
}
if (declSpec.isVolatile()) {
if (needSpace) {
result.append(SPACE);
@ -510,24 +512,7 @@ public class ASTSignatureUtil {
needSpace = true;
}
if (declSpec instanceof ICASTDeclSpecifier) {
if (((ICASTDeclSpecifier) declSpec).isRestrict()) {
if (needSpace) {
result.append(SPACE);
needSpace = false;
}
result.append(Keywords.RESTRICT);
needSpace = true;
}
} else if (declSpec instanceof ICPPASTDeclSpecifier) {
if (declSpec.getStorageClass() == ICPPASTDeclSpecifier.sc_mutable) {
if (needSpace) {
result.append(SPACE);
needSpace = false;
}
result.append(Keywords.MUTABLE);
needSpace = true;
}
if (declSpec instanceof ICPPASTDeclSpecifier) {
if (((ICPPASTDeclSpecifier) declSpec).isExplicit()) {
if (needSpace) {
result.append(SPACE);
@ -552,16 +537,7 @@ public class ASTSignatureUtil {
result.append(Keywords.VIRTUAL);
needSpace = true;
}
} else if (declSpec instanceof IGPPASTDeclSpecifier) {
if (((IGPPASTDeclSpecifier) declSpec).isRestrict()) {
if (needSpace) {
result.append(SPACE);
needSpace = false;
}
result.append(Keywords.RESTRICT);
needSpace = true;
}
}
}
// handle complex cases
if (declSpec instanceof IASTCompositeTypeSpecifier) {
@ -631,100 +607,32 @@ public class ASTSignatureUtil {
result.append(((IASTNamedTypeSpecifier) declSpec).getName().toString());
needSpace = true;
} else if (declSpec instanceof IASTSimpleDeclSpecifier) {
// handle complex cases
if (declSpec instanceof IGPPASTSimpleDeclSpecifier) {
if (((IGPPASTSimpleDeclSpecifier) declSpec).isLongLong())
result.append(Keywords.LONG_LONG);
if (((IGPPASTSimpleDeclSpecifier) declSpec).isComplex()) {
if (needSpace) {
result.append(SPACE);
needSpace = false;
}
result.append(Keywords.c_COMPLEX);
needSpace = true;
}
if (((IGPPASTSimpleDeclSpecifier) declSpec).isImaginary()) {
if (needSpace) {
result.append(SPACE);
needSpace = false;
}
result.append(Keywords.c_IMAGINARY);
needSpace = true;
}
switch (((IGPPASTSimpleDeclSpecifier) declSpec).getType()) {
case IGPPASTSimpleDeclSpecifier.t_typeof:
if (needSpace) {
result.append(SPACE);
needSpace = false;
}
result.append(GCCKeywords.TYPEOF);
needSpace = true;
break;
final IASTSimpleDeclSpecifier sds = (IASTSimpleDeclSpecifier) declSpec;
if (sds.isLongLong()) {
if (needSpace) {
result.append(SPACE);
needSpace = false;
}
result.append(Keywords.LONG_LONG);
needSpace = true;
}
if (declSpec instanceof ICPPASTSimpleDeclSpecifier) {
switch (((ICPPASTSimpleDeclSpecifier) declSpec).getType()) {
case ICPPASTSimpleDeclSpecifier.t_bool:
if (needSpace) {
result.append(SPACE);
needSpace = false;
}
result.append(Keywords.BOOL);
needSpace = true;
break;
case ICPPASTSimpleDeclSpecifier.t_wchar_t:
if (needSpace) {
result.append(SPACE);
needSpace = false;
}
result.append(Keywords.WCHAR_T);
needSpace = true;
break;
if (sds.isComplex()) {
if (needSpace) {
result.append(SPACE);
needSpace = false;
}
result.append(Keywords.c_COMPLEX);
needSpace = true;
}
if (declSpec instanceof ICASTSimpleDeclSpecifier) {
if (((ICASTSimpleDeclSpecifier) declSpec).isLongLong()) {
if (needSpace) {
result.append(SPACE);
needSpace = false;
}
result.append(Keywords.LONG_LONG);
needSpace = true;
}
if (((ICASTSimpleDeclSpecifier) declSpec).isComplex()) {
if (needSpace) {
result.append(SPACE);
needSpace = false;
}
result.append(Keywords.c_COMPLEX);
needSpace = true;
}
if (((ICASTSimpleDeclSpecifier) declSpec).isImaginary()) {
if (needSpace) {
result.append(SPACE);
needSpace = false;
}
result.append(Keywords.c_IMAGINARY);
needSpace = true;
}
switch (((ICASTSimpleDeclSpecifier) declSpec).getType()) {
case ICASTSimpleDeclSpecifier.t_Bool:
if (needSpace) {
result.append(SPACE);
needSpace = false;
}
result.append(Keywords.c_BOOL);
needSpace = true;
break;
if (sds.isImaginary()) {
if (needSpace) {
result.append(SPACE);
needSpace = false;
}
result.append(Keywords.c_IMAGINARY);
needSpace = true;
}
// handle simple cases
if (((IASTSimpleDeclSpecifier) declSpec).isLong()) {
if (sds.isLong()) {
if (needSpace) {
result.append(SPACE);
needSpace = false;
@ -732,7 +640,7 @@ public class ASTSignatureUtil {
result.append(Keywords.LONG);
needSpace = true;
}
if (((IASTSimpleDeclSpecifier) declSpec).isShort()) {
if (sds.isShort()) {
if (needSpace) {
result.append(SPACE);
needSpace = false;
@ -740,7 +648,7 @@ public class ASTSignatureUtil {
result.append(Keywords.SHORT);
needSpace = true;
}
if (((IASTSimpleDeclSpecifier) declSpec).isSigned()) {
if (sds.isSigned()) {
if (needSpace) {
result.append(SPACE);
needSpace = false;
@ -748,7 +656,7 @@ public class ASTSignatureUtil {
result.append(Keywords.SIGNED);
needSpace = true;
}
if (((IASTSimpleDeclSpecifier) declSpec).isUnsigned()) {
if (sds.isUnsigned()) {
if (needSpace) {
result.append(SPACE);
needSpace = false;
@ -757,7 +665,35 @@ public class ASTSignatureUtil {
needSpace = true;
}
switch (((IASTSimpleDeclSpecifier) declSpec).getType()) {
switch (sds.getType()) {
case IASTSimpleDeclSpecifier.t_typeof:
if (needSpace) {
result.append(SPACE);
needSpace = false;
}
result.append(Keywords.TYPEOF);
needSpace = true;
break;
case IASTSimpleDeclSpecifier.t_decltype:
if (needSpace) {
result.append(SPACE);
needSpace = false;
}
result.append(Keywords.cDECLTYPE);
needSpace = true;
break;
case IASTSimpleDeclSpecifier.t_bool:
if (needSpace) {
result.append(SPACE);
needSpace = false;
}
if (declSpec instanceof ICASTSimpleDeclSpecifier) {
result.append(Keywords.c_BOOL);
} else {
result.append(Keywords.BOOL);
}
needSpace = true;
break;
case IASTSimpleDeclSpecifier.t_char:
if (needSpace) {
result.append(SPACE);
@ -766,6 +702,14 @@ public class ASTSignatureUtil {
result.append(Keywords.CHAR);
needSpace = true;
break;
case IASTSimpleDeclSpecifier.t_wchar_t:
if (needSpace) {
result.append(SPACE);
needSpace = false;
}
result.append(Keywords.WCHAR_T);
needSpace = true;
break;
case IASTSimpleDeclSpecifier.t_double:
if (needSpace) {
result.append(SPACE);
@ -1181,21 +1125,14 @@ public class ASTSignatureUtil {
opString = Keywords.TYPEID;
break;
}
} else if (ue instanceof IGNUASTUnaryExpression) {
switch (op) {
case IGNUASTUnaryExpression.op_alignOf:
opString = Keywords.ALIGNOF;
break;
case IGNUASTUnaryExpression.op_typeof:
opString = Keywords.TYPEOF;
break;
}
}
}
if (!opString.equals(EMPTY_STRING))
return opString;
switch (op) {
case IASTUnaryExpression.op_alignOf:
opString = Keywords.ALIGNOF;
break;
case IASTUnaryExpression.op_amper:
opString = String.valueOf(Keywords.cpAMPER);
break;

View file

@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2004, 2009 IBM Corporation and others.
* Copyright (c) 2004, 2010 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
@ -20,108 +20,71 @@ package org.eclipse.cdt.core.dom.ast;
public interface IASTDeclSpecifier extends IASTNode {
/**
* <code>sc_unspecified</code> undefined storage class
* No storage class specified.
*/
public static final int sc_unspecified = 0;
/**
* <code>sc_typedef</code> typedef
*/
public static final int sc_typedef = 1;
/**
* <code>sc_extern</code>extern
*/
public static final int sc_extern = 2;
/**
* <code>sc_static</code>static
*/
public static final int sc_static = 3;
/**
* <code>sc_auto</code>auto
*/
public static final int sc_auto = 4;
/**
* <code>sc_register</code>register
*/
public static final int sc_register = 5;
/**
* <code>sc_last</code> for sub-interfaces to continue on
* @since 5.2
*/
public static final int sc_last = sc_register;
public static final int sc_mutable = 6;
/**
* Set the storage class.
*
* @param storageClass
* int
*/
public void setStorageClass(int storageClass);
/**
* Get the storage class.
*
* @return int
* Returns the storage class, which is one of the constants sc_...
*/
public int getStorageClass();
// Type qualifier
/**
* Is const modifier used?
*
* @return boolean
*/
public boolean isConst();
/**
* Set const modifier used.
*
* @param value
* boolean
*/
public void setConst(boolean value);
/**
* Is volatile modifier used?
*
* @return boolean
*/
public boolean isVolatile();
/**
* Set volatile modifier used.
*
* @param value
* boolean
* @since 5.2
*/
public void setVolatile(boolean value);
public boolean isRestrict();
// Function specifier
/**
* Is inline modifier used?
*
* @return boolean
*/
public boolean isInline();
/**
* Set inline modifier used.
*
* @param value
* boolean
*/
public void setInline(boolean value);
/**
* @since 5.1
*/
public IASTDeclSpecifier copy();
/**
* Not allowed on frozen ast.
*/
public void setStorageClass(int storageClass);
/**
* Not allowed on frozen ast.
*/
public void setConst(boolean value);
/**
* Not allowed on frozen ast.
*/
public void setVolatile(boolean value);
/**
* Not allowed on frozen ast.
* @since 5.2
*/
public void setRestrict(boolean value);
/**
* Not allowed on frozen ast.
*/
public void setInline(boolean value);
/**
* @deprecated All constants must be defined in this interface.
*/
@Deprecated
public static final int sc_last = sc_register;
}

View file

@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2004, 2009 IBM Corporation and others.
* Copyright (c) 2004, 2010 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
@ -20,129 +20,195 @@ import org.eclipse.cdt.core.dom.ast.IBasicType.Kind;
* @noimplement This interface is not intended to be implemented by clients.
*/
public interface IASTSimpleDeclSpecifier extends IASTDeclSpecifier {
/**
* @since 5.2
*/
public static final ASTNodeProperty DECLTYPE_EXPRESSION = new ASTNodeProperty(
"IASTSimpleDeclSpecifier.EXPRESSION [IASTExpression]"); //$NON-NLS-1$
/**
* Used for omitted declaration specifiers. E.g. for declaration of constructors,
* or in plain c, where this defaults to an integer.
*/
public static final int t_unspecified = 0;
/**
* <code>void x();</code>
*/
public static final int t_void = 1;
/**
* <code>char c;</code>
*/
public static final int t_char = 2;
/**
* <code>int i;</code>
*/
public static final int t_int = 3;
/**
* <code>float f;</code>
*/
public static final int t_float = 4;
/**
* <code>double d;</code>
*/
public static final int t_double = 5;
/**
* Represents a boolean type (bool in c++, _Bool in c)
* @since 5.2
*/
public static final int t_bool = 6;
/**
* <code>t_wchar_t c;</code>
* @since 5.2
*/
public static final int t_wchar_t = 7;
/**
* <code>typeof 'c' c;</code>
* @since 5.2
*/
public static final int t_typeof = 8;
/**
* <code>decltype('c') c;</code>
* @since 5.2
*/
public static final int t_decltype = 9;
/**
* @since 5.1
*/
public IASTSimpleDeclSpecifier copy();
/**
* This returns the built-in type for the declaration. The type is then
* refined by qualifiers for signed/unsigned and short/long. The type could
* also be unspecified which usually means int.
*
*/
public int getType();
/**
* <code>t_unspecified</code> implies an unspecified type. .e.g x = 5; //
* declaration w/t_unspecified type logically defaults to integer.
* <code>signed char c;</code>
*/
public static final int t_unspecified = 0;
public boolean isSigned();
/**
* <code>t_void</code> implies void type e.g. void x();
* <code>unsigned int u;</code>
*/
public static final int t_void = 1;
public boolean isUnsigned();
/**
* <code>t_char</code> implies char type e.g. char y;
* <code>short int s;</code>
*/
public static final int t_char = 2;
public boolean isShort();
/**
* <code>t_int</code> implies int type e.g. int x;
* <code>long int l;</code>
*/
public static final int t_int = 3;
public boolean isLong();
/**
* <code>t_float</code> implies floating point type. e.g. float yy;
* <code>long long int l;</code>
* @since 5.2
*/
public static final int t_float = 4;
public boolean isLongLong();
/**
* <code>t_double</code> implies double floating point type. e.g. double
* d;
* <code>_Complex t</code>;
* @since 5.2
*/
public static final int t_double = 5;
public boolean isComplex();
/**
* <code>_Imaginary t</code>;
* @since 5.2
*/
public boolean isImaginary();
/**
* <code>t_last</code> specified for subinterface definition.
* Returns the expression for simple declaration specifiers of type
* {@link IASTSimpleDeclSpecifier#t_decltype} or {@link IASTSimpleDeclSpecifier#t_typeof}.
* Other simple declaration specifiers will return <code>null</code>.
* @since 5.2
*/
public static final int t_last = t_double; // used only in subclasses
public IASTExpression getDeclTypeExpression();
/**
* Set this decl specifier type to <code>type</code>.
*
* @param type
* (int)
* Not allowed on frozen ast.
* @see #getType()
*/
public void setType(int type);
/**
* Not allowed on frozen ast.
* Sets this declaration specifier to the type based on {@link IBasicType.Kind}.
* @since 5.2
*/
public void setType(Kind kind);
/**
* Is the type modified by the signed keyword?
*
* @return boolean
*/
public boolean isSigned();
/**
* Is the type modified by the unsigned keyword?
*
* @return boolean
*/
public boolean isUnsigned();
/**
* Is the type modified by the short keyword?
*
* @return boolean
*/
public boolean isShort();
/**
* Is the type modified by the long keyword?
*
* @return boolean
*/
public boolean isLong();
/**
* Change as to if the type is modified by the keyword signed.
*
* @param value
* boolean
* Not allowed on frozen ast.
* @see #isSigned()
*/
public void setSigned(boolean value);
/**
* Change as to if the type is modified by the keyword unsigned.
*
* @param value
* boolean
* Not allowed on frozen ast.
* @see #isUnsigned()
*/
public void setUnsigned(boolean value);
/**
* Change as to if the type is modified by the keyword long.
*
* @param value
* boolean
* Not allowed on frozen ast.
* @see #isShort()
*/
public void setShort(boolean value);
/**
* Not allowed on frozen ast.
* @see #isLong()
*/
public void setLong(boolean value);
/**
* Change as to if the type is modified by the keyword short.
*
* @param value
* boolean
* Not allowed on frozen ast.
* @see #isLongLong()
* @since 5.2
*/
public void setShort(boolean value);
public void setLongLong(boolean value);
/**
* @since 5.1
* Not allowed on frozen ast.
* @see #isComplex()
* @since 5.2
*/
public IASTSimpleDeclSpecifier copy();
public void setComplex(boolean value);
/**
* Not allowed on frozen ast.
* @see #isImaginary()
* @since 5.2
*/
public void setImaginary(boolean value);
/**
* Not allowed on frozen ast.
* @see #getDeclTypeExpression()
* @since 5.2
*/
public void setDeclTypeExpression(IASTExpression expression);
/**
* @deprecated all constants must be defined in this interface
*/
@Deprecated
public static final int t_last = t_double; // used only in subclasses
}

View file

@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2004, 2009 IBM Corporation and others.
* Copyright (c) 2004, 2010 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
@ -101,9 +101,9 @@ public interface IASTUnaryExpression extends IASTExpression {
public static final int op_typeid = 13;
/**
* for gnu parsers, only. <code>op_typeof</code> is used for typeof( unaryExpression ) type
* expressions.
* @deprecated Shall not be used, 'typeof something' is not an expression, it's a declaration specifier.
*/
@Deprecated
public static final int op_typeof = 14;
/**

View file

@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2004, 2009 IBM Corporation and others.
* Copyright (c) 2004, 2010 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
@ -7,6 +7,7 @@
*
* Contributors:
* Doug Schaefer (IBM) - Initial API and implementation
* Markus Schorn (Wind River Systems)
*******************************************************************************/
package org.eclipse.cdt.core.dom.ast.c;
@ -20,20 +21,6 @@ import org.eclipse.cdt.core.dom.ast.IASTDeclSpecifier;
*/
public interface ICASTDeclSpecifier extends IASTDeclSpecifier {
/**
* Is restrict keyword used?
*
* @return boolean
*/
public boolean isRestrict();
/**
* Set restrict to value.
*
* @param value
*/
public void setRestrict(boolean value);
/**
* @since 5.1
*/

View file

@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2004, 2009 IBM Corporation and others.
* Copyright (c) 2004, 2010 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
@ -7,6 +7,7 @@
*
* Contributors:
* Doug Schaefer (IBM) - Initial API and implementation
* Markus Schorn (Wind River Systems)
*******************************************************************************/
package org.eclipse.cdt.core.dom.ast.c;
@ -18,63 +19,22 @@ import org.eclipse.cdt.core.dom.ast.IASTSimpleDeclSpecifier;
* @noextend This interface is not intended to be extended by clients.
* @noimplement This interface is not intended to be implemented by clients.
*/
public interface ICASTSimpleDeclSpecifier extends IASTSimpleDeclSpecifier,
ICASTDeclSpecifier {
public interface ICASTSimpleDeclSpecifier extends IASTSimpleDeclSpecifier, ICASTDeclSpecifier {
// Extra types in C
/**
* <code>t_Bool</code> boolean. e.g. _Bool x;
*/
public static final int t_Bool = IASTSimpleDeclSpecifier.t_last + 1;
/**
* <code>t_last</code> is defined for sub-interfaces.
*/
public static final int t_last = t_Bool;
/**
* Is complex number? e.g. _Complex t;
* @return true if it is a complex number, false otherwise
*/
public boolean isComplex();
/**
* Set the number to be complex.
* @param value true if it is a complex number, false otherwise
*/
public void setComplex(boolean value);
/**
* Is imaginary number? e.g. _Imaginr
* @return true if it is an imaginary number, false otherwise
*/
public boolean isImaginary();
/**
* Set the number to be imaginary.
* @param value true if it is an imaginary number, false otherwise
*/
public void setImaginary(boolean value);
// allow for long long's
/**
* Is long long?
*
* @return boolean
*/
public boolean isLongLong();
/**
* Set long long to be 'value'.
*
* @param value
* boolean
*/
public void setLongLong(boolean value);
/**
* @since 5.1
*/
public ICASTSimpleDeclSpecifier copy();
/**
* @deprecated Replaced by {@link IASTSimpleDeclSpecifier#t_bool}.
*/
@Deprecated
public static final int t_Bool = t_bool;
/**
* @deprecated All constants must be defined in {@link IASTSimpleDeclSpecifier}.
*/
@Deprecated
public static final int t_last = t_Bool;
}

View file

@ -1,12 +1,13 @@
/*******************************************************************************
* Copyright (c) 2006, 2009 IBM Corporation and others.
* Copyright (c) 2006, 2010 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 Corporation - initial API and implementation
* Mike Kucera (IBM Corporation) - initial API and implementation
* Markus Schorn (Wind River Systems)
*******************************************************************************/
package org.eclipse.cdt.core.dom.ast.c;
@ -18,12 +19,10 @@ import org.eclipse.cdt.core.dom.ast.IASTTypeId;
import org.eclipse.cdt.core.dom.ast.INodeFactory;
import org.eclipse.cdt.core.dom.ast.gnu.c.ICASTKnRFunctionDeclarator;
import org.eclipse.cdt.core.dom.ast.gnu.c.IGCCASTArrayRangeDesignator;
import org.eclipse.cdt.core.dom.ast.gnu.c.IGCCASTSimpleDeclSpecifier;
/**
* Factory for AST nodes for the C programming language.
*
* @author Mike Kucera
* @since 5.1
*
* @noextend This interface is not intended to be extended by clients.
@ -57,5 +56,9 @@ public interface ICNodeFactory extends INodeFactory {
public IGCCASTArrayRangeDesignator newArrayRangeDesignatorGCC(IASTExpression floor, IASTExpression ceiling);
public IGCCASTSimpleDeclSpecifier newSimpleDeclSpecifierGCC(IASTExpression typeofExpression);
/**
* @deprecated Replaced by {@link #newSimpleDeclSpecifier()}
*/
@Deprecated
public org.eclipse.cdt.core.dom.ast.gnu.c.IGCCASTSimpleDeclSpecifier newSimpleDeclSpecifierGCC(IASTExpression typeofExpression);
}

View file

@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2004, 2009 IBM Corporation and others.
* Copyright (c) 2004, 2010 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
@ -7,6 +7,7 @@
*
* Contributors:
* Doug Schaefer (IBM) - Initial API and implementation
* Markus Schorn (Wind River Systems)
*******************************************************************************/
package org.eclipse.cdt.core.dom.ast.cpp;
@ -20,17 +21,6 @@ import org.eclipse.cdt.core.dom.ast.IASTDeclSpecifier;
*/
public interface ICPPASTDeclSpecifier extends IASTDeclSpecifier {
// Extra storage class in C++
/**
* <code>sc_mutable</code> represents a mutable storage representation.
*/
public static final int sc_mutable = IASTDeclSpecifier.sc_last + 1;
/**
* <code>sc_last</code> is overwritten to allow extensibility.
*/
public static final int sc_last = sc_mutable;
// A declaration in C++ can be a friend declaration
/**
* Is this a friend declaration?
@ -81,5 +71,10 @@ public interface ICPPASTDeclSpecifier extends IASTDeclSpecifier {
* @since 5.1
*/
public ICPPASTDeclSpecifier copy();
/**
* @deprecated All constants must be defined in {@link IASTDeclSpecifier}
*/
@Deprecated
public static final int sc_last = sc_mutable;
}

View file

@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2004, 2009 IBM Corporation and others.
* Copyright (c) 2004, 2010 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
@ -7,6 +7,7 @@
*
* Contributors:
* Doug Schaefer (IBM) - Initial API and implementation
* Markus Schorn (Wind River Systems)
*******************************************************************************/
package org.eclipse.cdt.core.dom.ast.cpp;
@ -18,27 +19,15 @@ import org.eclipse.cdt.core.dom.ast.IASTSimpleDeclSpecifier;
* @noextend This interface is not intended to be extended by clients.
* @noimplement This interface is not intended to be implemented by clients.
*/
public interface ICPPASTSimpleDeclSpecifier extends IASTSimpleDeclSpecifier,
ICPPASTDeclSpecifier {
// Extra types
/**
* <code>t_bool</code> bool
*/
public static final int t_bool = IASTSimpleDeclSpecifier.t_last + 1;
/**
* <code>t_wchar_t</code> wchar_t
*/
public static final int t_wchar_t = IASTSimpleDeclSpecifier.t_last + 2;
/**
* <code>t_last</code> is specified for subinterfaces.
*/
public static final int t_last = t_wchar_t;
public interface ICPPASTSimpleDeclSpecifier extends IASTSimpleDeclSpecifier, ICPPASTDeclSpecifier {
/**
* @since 5.1
*/
public ICPPASTSimpleDeclSpecifier copy();
/**
* @deprecated all constants must be defined in {@link IASTSimpleDeclSpecifier}.
*/
@Deprecated
public static final int t_last = t_wchar_t;
}

View file

@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2006, 2009 IBM Corporation and others.
* Copyright (c) 2006, 2010 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
@ -26,7 +26,6 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTCompositeTypeSpecifier.ICPPASTBas
import org.eclipse.cdt.core.dom.ast.gnu.cpp.IGPPASTExplicitTemplateInstantiation;
import org.eclipse.cdt.core.dom.ast.gnu.cpp.IGPPASTPointer;
import org.eclipse.cdt.core.dom.ast.gnu.cpp.IGPPASTPointerToMember;
import org.eclipse.cdt.core.dom.ast.gnu.cpp.IGPPASTSimpleDeclSpecifier;
import org.eclipse.cdt.core.parser.IScanner;
/**
@ -127,8 +126,6 @@ public interface ICPPNodeFactory extends INodeFactory {
public ICPPASTDeleteExpression newDeleteExpression(IASTExpression operand);
public IGPPASTSimpleDeclSpecifier newSimpleDeclSpecifierGPP();
public ICPPASTSimpleTypeConstructorExpression newSimpleTypeConstructorExpression(int type, IASTExpression expression);
public ICPPASTTypenameExpression newTypenameExpression(IASTName qualifiedName, IASTExpression expr, boolean isTemplate);
@ -225,4 +222,9 @@ public interface ICPPNodeFactory extends INodeFactory {
*/
@Deprecated
public ICPPASTTranslationUnit newTranslationUnit();
/**
* @deprecated Replaced by {@link #newSimpleDeclSpecifier()}
*/
@Deprecated
public org.eclipse.cdt.core.dom.ast.gnu.cpp.IGPPASTSimpleDeclSpecifier newSimpleDeclSpecifierGPP();
}

View file

@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2005, 2009 IBM Corporation and others.
* Copyright (c) 2005, 2010 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
@ -13,32 +13,11 @@ package org.eclipse.cdt.core.dom.ast.gnu;
import org.eclipse.cdt.core.dom.ast.IASTUnaryExpression;
/**
* There are GNU language extensions that apply to both GCC and G++. Unary
* expressions for _alignOf() and typeof() along the lines of sizeof().
*
* @noextend This interface is not intended to be extended by clients.
* @noimplement This interface is not intended to be implemented by clients.
* @deprecated Replaced by {@link IASTUnaryExpression}.
*/
@Deprecated
public interface IGNUASTUnaryExpression extends IASTUnaryExpression {
/**
* <code>op_typeof</code> is used for typeof( unaryExpression ) type
* expressions.
*/
public static final int op_typeof = IASTUnaryExpression.op_typeof;
/**
* <code>op_alignOf</code> is used for __alignOf( unaryExpression ) type
* expressions.
*/
public static final int op_alignOf = IASTUnaryExpression.op_alignOf;
/**
* @deprecated all constants to be defined in {@link IASTUnaryExpression}.
*/
@Deprecated
public static final int op_last = IASTUnaryExpression.op_last;
/**
* @since 5.1
*/

View file

@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2005, 2009 IBM Corporation and others.
* Copyright (c) 2005, 2010 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
@ -12,44 +12,46 @@ package org.eclipse.cdt.core.dom.ast.gnu.c;
import org.eclipse.cdt.core.dom.ast.ASTNodeProperty;
import org.eclipse.cdt.core.dom.ast.IASTExpression;
import org.eclipse.cdt.core.dom.ast.IASTSimpleDeclSpecifier;
import org.eclipse.cdt.core.dom.ast.c.ICASTSimpleDeclSpecifier;
/**
* @noextend This interface is not intended to be extended by clients.
* @noimplement This interface is not intended to be implemented by clients.
* @deprecated Everything can be expressed as {@link ICASTSimpleDeclSpecifier}.
*/
@Deprecated
public interface IGCCASTSimpleDeclSpecifier extends ICASTSimpleDeclSpecifier {
/**
* <code>t_typeof</code> represents a typeof() expression type.
* @deprecated Replaced by {@link IASTSimpleDeclSpecifier#t_typeof}.
*/
@Deprecated
public static final int t_typeof = ICASTSimpleDeclSpecifier.t_last + 1;
/**
* <code>t_last</code> is specified for subinterfaces.
* @deprecated All constants must be defined in {@link IASTSimpleDeclSpecifier}.
*/
@Deprecated
public static final int t_last = t_typeof;
/**
* <code>TYPEOF_EXPRESSION</code> represents the relationship between the
* decl spec & the expression for typeof().
* @deprecated Replaced by {@link IASTSimpleDeclSpecifier#DECLTYPE_EXPRESSION}.
*/
@Deprecated
public static final ASTNodeProperty TYPEOF_EXPRESSION = new ASTNodeProperty(
"IGCCASTSimpleDeclSpecifier.TYPEOF_EXPRESSION - typeof() Expression"); //$NON-NLS-1$
/**
* Set the typeof() expression.
*
* @param typeofExpression
* <code>IASTExpression</code>
* @deprecated Replaced by {@link IASTSimpleDeclSpecifier#setDeclTypeExpression(IASTExpression)}.
*/
@Deprecated
public void setTypeofExpression(IASTExpression typeofExpression);
/**
* Get the typeof expression.
*
* @return <code>IASTExpression</code>
* @deprecated Replaced by {@link IASTSimpleDeclSpecifier#getDeclTypeExpression()}.
*/
@Deprecated
public IASTExpression getTypeofExpression();
/**

View file

@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2004, 2009 IBM Corporation and others.
* Copyright (c) 2004, 2010 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
@ -17,24 +17,11 @@ import org.eclipse.cdt.core.dom.ast.IASTDeclSpecifier;
*
* @noextend This interface is not intended to be extended by clients.
* @noimplement This interface is not intended to be implemented by clients.
* @deprecated Replaced by {@link IASTDeclSpecifier}.
*/
@Deprecated
public interface IGPPASTDeclSpecifier extends IASTDeclSpecifier {
/**
* Was restrict keyword encountered?
*
* @return boolean
*/
public boolean isRestrict();
/**
* Set restrict-modifier-encountered to value.
*
* @param value
* boolean
*/
public void setRestrict(boolean value);
/**
* @since 5.1
*/

View file

@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2004, 2009 IBM Corporation and others.
* Copyright (c) 2004, 2010 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
@ -12,6 +12,7 @@ package org.eclipse.cdt.core.dom.ast.gnu.cpp;
import org.eclipse.cdt.core.dom.ast.ASTNodeProperty;
import org.eclipse.cdt.core.dom.ast.IASTExpression;
import org.eclipse.cdt.core.dom.ast.IASTSimpleDeclSpecifier;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTSimpleDeclSpecifier;
/**
@ -19,78 +20,20 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTSimpleDeclSpecifier;
*
* @noextend This interface is not intended to be extended by clients.
* @noimplement This interface is not intended to be implemented by clients.
* @deprecated Replaced by {@link ICPPASTSimpleDeclSpecifier}.
*/
@Deprecated
public interface IGPPASTSimpleDeclSpecifier extends IGPPASTDeclSpecifier, ICPPASTSimpleDeclSpecifier {
/**
* <code>t_typeof</code> represents a typeof() expression type.
*/
public static final int t_typeof = ICPPASTSimpleDeclSpecifier.t_last + 1;
/**
* <code>t_last</code> is for subinterfaces to extend these types.
*/
public static final int t_last = t_typeof;
/**
* Is complex number? e.g. _Complex t;
* @return true if it is a complex number, false otherwise
*/
public boolean isComplex();
/**
* Set the number to be complex.
* @param value true if it is a complex number, false otherwise
*/
public void setComplex(boolean value);
/**
* Is imaginary number? e.g. _Imaginr
* @return true if it is an imaginary number, false otherwise
*/
public boolean isImaginary();
/**
* Set the number to be imaginary.
* @param value true if it is an imaginary number, false otherwise
*/
public void setImaginary(boolean value);
/**
* <code>TYPEOF_EXPRESSION</code> represents the relationship between the
* decl spec & the expression for typeof().
*/
public static final ASTNodeProperty TYPEOF_EXPRESSION = new ASTNodeProperty(
"IGPPASTSimpleDeclSpecifier.TYPEOF_EXPRESSION - typeof() Expression"); //$NON-NLS-1$
/**
* Did we encounter "long long" as a modifier?
*
* @return boolean
*/
public boolean isLongLong();
/**
* Encountered "long long" - set true or false.
*
* @param value
* boolean
*/
public void setLongLong(boolean value);
/**
* Set the typeof() expression.
*
* @param typeofExpression
* <code>IASTExpression</code>
* @deprecated Replaced by {@link ICPPASTSimpleDeclSpecifier#setDeclTypeExpression(IASTExpression)}.
*/
@Deprecated
public void setTypeofExpression(IASTExpression typeofExpression);
/**
* Get the typeof expression.
*
* @return <code>IASTExpression</code>
* @deprecated Replaced by {@link ICPPASTSimpleDeclSpecifier#getDeclTypeExpression()}.
*/
@Deprecated
public IASTExpression getTypeofExpression();
/**
@ -98,4 +41,17 @@ public interface IGPPASTSimpleDeclSpecifier extends IGPPASTDeclSpecifier, ICPPAS
*/
public IGPPASTSimpleDeclSpecifier copy();
/**
* @deprecated All constants must be defined in {@link IASTSimpleDeclSpecifier}.
*/
@Deprecated
public static final int t_last = t_typeof;
/**
* @deprecated Replaced by {@link ICPPASTSimpleDeclSpecifier#DECLTYPE_EXPRESSION}.
*/
@Deprecated
public static final ASTNodeProperty TYPEOF_EXPRESSION = new ASTNodeProperty(
"IGPPASTSimpleDeclSpecifier.TYPEOF_EXPRESSION - typeof() Expression"); //$NON-NLS-1$
}

View file

@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2002, 2009 IBM Corporation and others.
* Copyright (c) 2002, 2010 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
@ -11,7 +11,6 @@
*******************************************************************************/
package org.eclipse.cdt.core.parser;
/**
* @noextend This interface is not intended to be extended by clients.
* @noimplement This interface is not intended to be implemented by clients.
@ -93,7 +92,7 @@ public interface IToken {
* @see IScanner#setSplitShiftROperator(boolean)
* @since 5.2
*/
int tGT_in_SHIFTR= 53;
int tGT_in_SHIFTR= 5200;
/** @deprecated use {@link #tAND} */ @Deprecated int t_and = 54;
/** @deprecated use {@link #tAMPERASSIGN} */ @Deprecated int t_and_eq = 55;
@ -113,6 +112,7 @@ public interface IToken {
int t_const_cast = 69;
int t_continue = 70;
/** @since 5.2 */ int t_decltype= 5201;
int t_default = 71;
int t_delete = 72;
int t_do = 73;
@ -149,7 +149,7 @@ public interface IToken {
int t_short = 104;
int t_sizeof = 105;
int t_static = 106;
/** @since 5.2 */ int t_static_assert = 5010;
/** @since 5.2 */ int t_static_assert = 5202;
int t_static_cast = 107;
int t_signed = 108;
int t_struct = 109;

View file

@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2002, 2009 IBM Corporation and others.
* Copyright (c) 2002, 2010 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
@ -43,6 +43,8 @@ public class Keywords {
public static final String CONST = "const"; //$NON-NLS-1$
public static final String CONST_CAST = "const_cast"; //$NON-NLS-1$
public static final String CONTINUE = "continue"; //$NON-NLS-1$
/** @since 5.2 */
public static final String DECLTYPE = "decltype"; //$NON-NLS-1$
public static final String DEFAULT = "default"; //$NON-NLS-1$
public static final String DELETE = "delete"; //$NON-NLS-1$
public static final String DO = "do"; //$NON-NLS-1$
@ -127,6 +129,8 @@ public class Keywords {
public static final char[] cCONST_CAST = "const_cast".toCharArray(); //$NON-NLS-1$
public static final char[] cCONTINUE = "continue".toCharArray(); //$NON-NLS-1$
public static final char[] cDEFAULT = "default".toCharArray(); //$NON-NLS-1$
/** @since 5.2 */
public static final char[] cDECLTYPE = DECLTYPE.toCharArray();
public static final char[] cDELETE = "delete".toCharArray(); //$NON-NLS-1$
public static final char[] cDO = "do".toCharArray(); //$NON-NLS-1$
public static final char[] cDOUBLE = "double".toCharArray(); //$NON-NLS-1$
@ -165,7 +169,7 @@ public class Keywords {
public static final char[] cSIZEOF = "sizeof".toCharArray(); //$NON-NLS-1$
public static final char[] cSTATIC = "static".toCharArray(); //$NON-NLS-1$
/** @since 5.2 */
public static final char[] cSTATIC_ASSERT = "static_assert".toCharArray(); //$NON-NLS-1$
public static final char[] cSTATIC_ASSERT = STATIC_ASSERT.toCharArray();
public static final char[] cSTATIC_CAST = "static_cast".toCharArray(); //$NON-NLS-1$
public static final char[] cSTRUCT = "struct".toCharArray(); //$NON-NLS-1$
public static final char[] cSWITCH = "switch".toCharArray(); //$NON-NLS-1$
@ -329,6 +333,7 @@ public class Keywords {
cppkeywords.put(Keywords.cCATCH, IToken.t_catch);
cppkeywords.put(Keywords.cCLASS, IToken.t_class);
cppkeywords.put(Keywords.cCONST_CAST, IToken.t_const_cast);
cppkeywords.put(Keywords.cDECLTYPE, IToken.t_decltype);
cppkeywords.put(Keywords.cDELETE, IToken.t_delete);
cppkeywords.put(Keywords.cDYNAMIC_CAST, IToken.t_dynamic_cast);
cppkeywords.put(Keywords.cEXPLICIT, IToken.t_explicit);

View file

@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2005, 2009 IBM Corporation and others.
* Copyright (c) 2005, 2010 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
@ -2104,7 +2104,7 @@ public abstract class AbstractGNUSourceCodeParser implements ISourceCodeParser {
}
protected IASTStatement parseDefaultStatement() throws EndOfFileException, BacktrackException {
int startOffset = consume().getOffset(); // t_default
int startOffset = consume(IToken.t_default).getOffset();
int lastOffset = consume(IToken.tCOLON).getEndOffset();
IASTDefaultStatement df = nodeFactory.newDefaultStatement();
@ -2243,7 +2243,7 @@ public abstract class AbstractGNUSourceCodeParser implements ISourceCodeParser {
return result1;
}
IASTExpression result2= buildUnaryExpression(unaryExprKind, expr, offset, endOffset2);
IASTExpression result2= unaryExprKind == -1 ? expr : buildUnaryExpression(unaryExprKind, expr, offset, endOffset2);
if (ca != null)
result2= ca.updateExpression(result2);
@ -2444,6 +2444,7 @@ public abstract class AbstractGNUSourceCodeParser implements ISourceCodeParser {
case IToken.t__Imaginary:
case IToken.t_signed:
case IToken.t_unsigned:
case IToken.t_decltype:
// class-specifier:
case IToken.t_class:

View file

@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2007, 2009 Wind River Systems, Inc. and others.
* Copyright (c) 2007, 2010 Wind River Systems, Inc. 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
@ -43,7 +43,6 @@ import org.eclipse.cdt.core.dom.ast.IFunctionType;
import org.eclipse.cdt.core.dom.ast.IType;
import org.eclipse.cdt.core.dom.ast.IVariable;
import org.eclipse.cdt.core.dom.ast.gnu.IGNUASTCompoundStatementExpression;
import org.eclipse.cdt.core.dom.ast.gnu.IGNUASTUnaryExpression;
import org.eclipse.cdt.internal.core.pdom.dom.PDOMName;
/**
@ -260,8 +259,7 @@ public abstract class VariableReadWriteFlags {
case IASTUnaryExpression.op_sizeof:
case IASTUnaryExpression.op_sizeofParameterPack:
case IGNUASTUnaryExpression.op_alignOf:
case IGNUASTUnaryExpression.op_typeof:
case IASTUnaryExpression.op_alignOf:
return 0;
}
return READ;

View file

@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2005, 2009 IBM Corporation and others.
* Copyright (c) 2005, 2010 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
@ -13,10 +13,14 @@
package org.eclipse.cdt.internal.core.dom.parser.c;
import org.eclipse.cdt.core.dom.ast.ASTVisitor;
import org.eclipse.cdt.core.dom.ast.IASTExpression;
import org.eclipse.cdt.core.dom.ast.IASTNode;
import org.eclipse.cdt.core.dom.ast.IBasicType.Kind;
import org.eclipse.cdt.core.dom.ast.c.ICASTSimpleDeclSpecifier;
import org.eclipse.cdt.internal.core.dom.parser.IASTAmbiguityParent;
public class CASTSimpleDeclSpecifier extends CASTBaseDeclSpecifier implements ICASTSimpleDeclSpecifier {
public class CASTSimpleDeclSpecifier extends CASTBaseDeclSpecifier implements ICASTSimpleDeclSpecifier,
IASTAmbiguityParent {
private int simpleType;
private boolean isSigned;
@ -26,6 +30,7 @@ public class CASTSimpleDeclSpecifier extends CASTBaseDeclSpecifier implements IC
private boolean longlong;
private boolean complex=false;
private boolean imaginary=false;
private IASTExpression fDeclTypeExpression;
public CASTSimpleDeclSpecifier copy() {
CASTSimpleDeclSpecifier copy = new CASTSimpleDeclSpecifier();
@ -43,9 +48,10 @@ public class CASTSimpleDeclSpecifier extends CASTBaseDeclSpecifier implements IC
copy.longlong = longlong;
copy.complex = complex;
copy.imaginary = imaginary;
if (fDeclTypeExpression != null)
copy.setDeclTypeExpression(fDeclTypeExpression.copy());
}
public int getType() {
return simpleType;
}
@ -78,7 +84,7 @@ public class CASTSimpleDeclSpecifier extends CASTBaseDeclSpecifier implements IC
private int getType(Kind kind) {
switch(kind) {
case eBoolean:
return t_Bool;
return t_bool;
case eChar:
case eWChar:
return t_char;
@ -134,6 +140,10 @@ public class CASTSimpleDeclSpecifier extends CASTBaseDeclSpecifier implements IC
default : break;
}
}
if (fDeclTypeExpression != null && !fDeclTypeExpression.accept(action))
return false;
if( action.shouldVisitDeclSpecifiers ){
switch( action.leave( this ) ){
case ASTVisitor.PROCESS_ABORT : return false;
@ -161,4 +171,25 @@ public class CASTSimpleDeclSpecifier extends CASTBaseDeclSpecifier implements IC
assertNotFrozen();
this.imaginary = value;
}
public IASTExpression getDeclTypeExpression() {
return fDeclTypeExpression;
}
public void setDeclTypeExpression(IASTExpression expression) {
assertNotFrozen();
fDeclTypeExpression= expression;
if (expression != null) {
expression.setPropertyInParent(DECLTYPE_EXPRESSION);
expression.setParent(this);
}
}
public void replace(IASTNode child, IASTNode other) {
if (child == fDeclTypeExpression) {
other.setPropertyInParent(child.getPropertyInParent());
other.setParent(child.getParent());
fDeclTypeExpression= (IASTExpression) other;
}
}
}

View file

@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2006, 2009 IBM Corporation and others.
* Copyright (c) 2006, 2010 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
@ -77,7 +77,6 @@ import org.eclipse.cdt.core.dom.ast.c.ICNodeFactory;
import org.eclipse.cdt.core.dom.ast.gnu.IGNUASTCompoundStatementExpression;
import org.eclipse.cdt.core.dom.ast.gnu.c.ICASTKnRFunctionDeclarator;
import org.eclipse.cdt.core.dom.ast.gnu.c.IGCCASTArrayRangeDesignator;
import org.eclipse.cdt.core.dom.ast.gnu.c.IGCCASTSimpleDeclSpecifier;
import org.eclipse.cdt.core.parser.IScanner;
import org.eclipse.cdt.internal.core.dom.parser.NodeFactory;
@ -349,7 +348,8 @@ public class CNodeFactory extends NodeFactory implements ICNodeFactory {
return new CASTArrayRangeDesignator(floor, ceiling);
}
public IGCCASTSimpleDeclSpecifier newSimpleDeclSpecifierGCC(IASTExpression typeofExpression) {
@Deprecated
public org.eclipse.cdt.core.dom.ast.gnu.c.IGCCASTSimpleDeclSpecifier newSimpleDeclSpecifierGCC(IASTExpression typeofExpression) {
return new GCCASTSimpleDeclSpecifier(typeofExpression);
}
}

View file

@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2004, 2009 IBM Corporation and others.
* Copyright (c) 2004, 2010 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
@ -34,12 +34,12 @@ import org.eclipse.cdt.core.dom.ast.IASTName;
import org.eclipse.cdt.core.dom.ast.IASTNamedTypeSpecifier;
import org.eclipse.cdt.core.dom.ast.IASTNode;
import org.eclipse.cdt.core.dom.ast.IASTParameterDeclaration;
import org.eclipse.cdt.core.dom.ast.IASTSimpleDeclSpecifier;
import org.eclipse.cdt.core.dom.ast.IASTSimpleDeclaration;
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.IASTTypeIdExpression;
import org.eclipse.cdt.core.dom.ast.IASTUnaryExpression;
import org.eclipse.cdt.core.dom.ast.IBinding;
import org.eclipse.cdt.core.dom.ast.ICompositeType;
import org.eclipse.cdt.core.dom.ast.IEnumeration;
@ -50,7 +50,6 @@ import org.eclipse.cdt.core.dom.ast.c.ICASTCompositeTypeSpecifier;
import org.eclipse.cdt.core.dom.ast.c.ICASTElaboratedTypeSpecifier;
import org.eclipse.cdt.core.dom.ast.c.ICASTEnumerationSpecifier;
import org.eclipse.cdt.core.dom.ast.c.ICScope;
import org.eclipse.cdt.core.dom.ast.gnu.IGNUASTUnaryExpression;
import org.eclipse.cdt.core.dom.ast.gnu.c.ICASTKnRFunctionDeclarator;
import org.eclipse.cdt.core.index.IIndex;
import org.eclipse.cdt.core.index.IIndexFileSet;
@ -306,8 +305,8 @@ public class CScope implements ICScope, IASTInternalScope {
}
IASTNode parent= name.getParent();
while (parent != null) {
if (parent instanceof IASTUnaryExpression) {
if (((IASTUnaryExpression) parent).getOperator() == IGNUASTUnaryExpression.op_typeof)
if (parent instanceof IASTSimpleDeclSpecifier) {
if (((IASTSimpleDeclSpecifier) parent).getDeclTypeExpression() != null)
return false;
}
else if (parent instanceof IASTTypeIdExpression) {

View file

@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2005, 2009 IBM Corporation and others.
* Copyright (c) 2005, 2010 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
@ -83,7 +83,6 @@ 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;
import org.eclipse.cdt.core.dom.ast.gnu.c.IGCCASTSimpleDeclSpecifier;
import org.eclipse.cdt.core.index.IIndexBinding;
import org.eclipse.cdt.core.index.IIndexFileSet;
import org.eclipse.cdt.core.parser.util.ArrayUtil;
@ -1332,13 +1331,12 @@ public class CVisitor extends ASTQueries {
* @return the base IType
*/
public static IType createBaseType(IASTDeclSpecifier declSpec) {
if (declSpec instanceof IGCCASTSimpleDeclSpecifier) {
IASTExpression exp = ((IGCCASTSimpleDeclSpecifier)declSpec).getTypeofExpression();
if (declSpec instanceof ICASTSimpleDeclSpecifier) {
final ICASTSimpleDeclSpecifier sds = (ICASTSimpleDeclSpecifier)declSpec;
IASTExpression exp = sds.getDeclTypeExpression();
if (exp != null)
return exp.getExpressionType();
return new CBasicType((ICASTSimpleDeclSpecifier) declSpec);
} else if (declSpec instanceof ICASTSimpleDeclSpecifier) {
return new CBasicType((ICASTSimpleDeclSpecifier)declSpec);
return new CBasicType(sds);
}
IBinding binding = null;
IASTName name = null;

View file

@ -1,33 +1,28 @@
/*******************************************************************************
* Copyright (c) 2005, 2008 IBM Corporation and others.
* Copyright (c) 2005, 2010 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 Corporation - initial API and implementation
* Andrew Niefer (IBM Corporation) - initial API and implementation
* Emanuel Graf IFS - Bugfix for #198257
*******************************************************************************/
package org.eclipse.cdt.internal.core.dom.parser.c;
import org.eclipse.cdt.core.dom.ast.ASTVisitor;
import org.eclipse.cdt.core.dom.ast.IASTExpression;
import org.eclipse.cdt.core.dom.ast.IASTNode;
import org.eclipse.cdt.core.dom.ast.gnu.c.IGCCASTSimpleDeclSpecifier;
import org.eclipse.cdt.internal.core.dom.parser.IASTAmbiguityParent;
/**
* @author aniefer
*
* @deprecated Replaced by {@link CASTSimpleDeclSpecifier}.
*/
public class GCCASTSimpleDeclSpecifier extends CASTSimpleDeclSpecifier implements IGCCASTSimpleDeclSpecifier, IASTAmbiguityParent {
private IASTExpression typeOfExpression;
@Deprecated
public class GCCASTSimpleDeclSpecifier extends CASTSimpleDeclSpecifier implements IGCCASTSimpleDeclSpecifier {
public GCCASTSimpleDeclSpecifier() {
}
public GCCASTSimpleDeclSpecifier(IASTExpression typeofExpression) {
setTypeofExpression(typeofExpression);
}
@ -36,50 +31,14 @@ public class GCCASTSimpleDeclSpecifier extends CASTSimpleDeclSpecifier implement
public GCCASTSimpleDeclSpecifier copy() {
GCCASTSimpleDeclSpecifier copy = new GCCASTSimpleDeclSpecifier();
copySimpleDeclSpec(copy);
copy.setTypeofExpression(typeOfExpression == null ? null : typeOfExpression.copy());
return copy;
}
public void setTypeofExpression(IASTExpression typeofExpression) {
this.typeOfExpression = typeofExpression;
if (typeofExpression != null) {
typeofExpression.setParent(this);
typeofExpression.setPropertyInParent(TYPEOF_EXPRESSION);
}
public void setTypeofExpression(IASTExpression expr) {
setDeclTypeExpression(expr);
}
public IASTExpression getTypeofExpression() {
return typeOfExpression;
}
@Override
public boolean accept( ASTVisitor action ){
if( action.shouldVisitDeclSpecifiers ){
switch( action.visit( this ) ){
case ASTVisitor.PROCESS_ABORT : return false;
case ASTVisitor.PROCESS_SKIP : return true;
default : break;
}
}
if( typeOfExpression != null )
if( !typeOfExpression.accept( action ) ) return false;
if( action.shouldVisitDeclSpecifiers ){
switch( action.leave( this ) ){
case ASTVisitor.PROCESS_ABORT : return false;
case ASTVisitor.PROCESS_SKIP : return true;
default : break;
}
}
return true;
}
public void replace(IASTNode child, IASTNode other) {
if (child == typeOfExpression) {
other.setPropertyInParent(child.getPropertyInParent());
other.setParent(child.getParent());
typeOfExpression= (IASTExpression) other;
}
return getDeclTypeExpression();
}
}

View file

@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2005, 2009 IBM Corporation and others.
* Copyright (c) 2005, 2010 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
@ -71,7 +71,6 @@ 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.ICNodeFactory;
import org.eclipse.cdt.core.dom.ast.gnu.IGNUASTTypeIdExpression;
import org.eclipse.cdt.core.dom.ast.gnu.IGNUASTUnaryExpression;
import org.eclipse.cdt.core.dom.ast.gnu.c.ICASTKnRFunctionDeclarator;
import org.eclipse.cdt.core.dom.ast.gnu.c.IGCCASTArrayRangeDesignator;
import org.eclipse.cdt.core.dom.parser.IExtensionToken;
@ -589,9 +588,6 @@ public class GNUCSourceParser extends AbstractGNUSourceCodeParser {
case IToken.t_sizeof:
return parseTypeidInParenthesisOrUnaryExpression(false, consume().getOffset(),
IASTTypeIdExpression.op_sizeof, IASTUnaryExpression.op_sizeof, ctx);
case IGCCToken.t_typeof:
return parseTypeidInParenthesisOrUnaryExpression(false, consume().getOffset(),
IASTTypeIdExpression.op_typeof, IASTUnaryExpression.op_typeof, ctx);
case IGCCToken.t___alignof__:
return parseTypeidInParenthesisOrUnaryExpression(false, consume().getOffset(),
IASTTypeIdExpression.op_alignof, IASTUnaryExpression.op_alignOf, ctx);
@ -1004,7 +1000,7 @@ public class GNUCSourceParser extends AbstractGNUSourceCodeParser {
case IToken.t__Bool:
if (encounteredTypename)
break declSpecifiers;
simpleType = ICASTSimpleDeclSpecifier.t_Bool;
simpleType = IASTSimpleDeclSpecifier.t_bool;
encounteredRawType= true;
endOffset= consume().getEndOffset();
break;
@ -1081,8 +1077,10 @@ public class GNUCSourceParser extends AbstractGNUSourceCodeParser {
if (encounteredRawType || encounteredTypename)
throwBacktrack(LA(1));
typeofExpression = parseTypeidInParenthesisOrUnaryExpression(false, consume().getOffset(),
IGNUASTTypeIdExpression.op_typeof, IGNUASTUnaryExpression.op_typeof, CastExprCtx.eNotBExpr);
simpleType= IASTSimpleDeclSpecifier.t_typeof;
consume(IGCCToken.t_typeof);
typeofExpression = parseTypeidInParenthesisOrUnaryExpression(false, LA(1).getOffset(),
IGNUASTTypeIdExpression.op_typeof, -1, CastExprCtx.eNotBExpr);
encounteredTypename= true;
endOffset= calculateEndOffset(typeofExpression);
@ -1155,11 +1153,7 @@ public class GNUCSourceParser extends AbstractGNUSourceCodeParser {
private ICASTSimpleDeclSpecifier buildSimpleDeclSpec(int storageClass, int simpleType,
int options, int isLong, IASTExpression typeofExpression, int offset, int endOffset) {
ICASTSimpleDeclSpecifier declSpec;
if (typeofExpression != null)
declSpec = nodeFactory.newSimpleDeclSpecifierGCC(typeofExpression);
else
declSpec = nodeFactory.newSimpleDeclSpecifier();
ICASTSimpleDeclSpecifier declSpec= nodeFactory.newSimpleDeclSpecifier();
configureDeclSpec(declSpec, storageClass, options);
declSpec.setType(simpleType);
@ -1171,6 +1165,10 @@ public class GNUCSourceParser extends AbstractGNUSourceCodeParser {
declSpec.setShort((options & SHORT) != 0);
declSpec.setComplex((options & COMPLEX) != 0);
declSpec.setImaginary((options & IMAGINARY) != 0);
if (typeofExpression != null) {
declSpec.setDeclTypeExpression(typeofExpression);
typeofExpression.setParent(declSpec);
}
((ASTNode) declSpec).setOffsetAndLength(offset, endOffset - offset);
return declSpec;

View file

@ -1,12 +1,13 @@
/*******************************************************************************
* Copyright (c) 2004, 2008 IBM Corporation and others.
* Copyright (c) 2004, 2010 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 - Initial API and implementation
* John Camelon (IBM) - Initial API and implementation
* Markus Schorn (Wind River Systems)
*******************************************************************************/
package org.eclipse.cdt.internal.core.dom.parser.cpp;
@ -15,14 +16,15 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTDeclSpecifier;
import org.eclipse.cdt.internal.core.dom.parser.ASTNode;
/**
* @author jcamelon
* Base for all c++ declaration specifiers
*/
public abstract class CPPASTBaseDeclSpecifier extends ASTNode implements ICPPASTDeclSpecifier {
private boolean friend;
private boolean inline;
private boolean volatil;
private boolean isConst;
private boolean isVolatile;
private boolean isRestrict;
private int sc;
private boolean virtual;
private boolean explicit;
@ -50,12 +52,21 @@ public abstract class CPPASTBaseDeclSpecifier extends ASTNode implements ICPPAST
}
public boolean isVolatile() {
return volatil;
return isVolatile;
}
public void setVolatile(boolean value) {
assertNotFrozen();
volatil = value;
isVolatile = value;
}
public boolean isRestrict() {
return isRestrict;
}
public void setRestrict(boolean value) {
assertNotFrozen();
isRestrict = value;
}
public boolean isInline() {
@ -93,8 +104,9 @@ public abstract class CPPASTBaseDeclSpecifier extends ASTNode implements ICPPAST
protected void copyBaseDeclSpec(CPPASTBaseDeclSpecifier other) {
other.friend = friend;
other.inline = inline;
other.volatil = volatil;
other.isConst = isConst;
other.isVolatile = isVolatile;
other.isRestrict= isRestrict;
other.virtual = virtual;
other.explicit = explicit;
other.sc = sc;

View file

@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2004, 2009 IBM Corporation and others.
* Copyright (c) 2004, 2010 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
@ -13,7 +13,7 @@
*******************************************************************************/
package org.eclipse.cdt.internal.core.dom.parser.cpp;
import static org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.SemanticUtil.TDEF;
import static org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.SemanticUtil.*;
import java.util.ArrayList;
import java.util.List;
@ -28,10 +28,12 @@ import org.eclipse.cdt.core.dom.ast.IASTNode;
import org.eclipse.cdt.core.dom.ast.IBinding;
import org.eclipse.cdt.core.dom.ast.IEnumerator;
import org.eclipse.cdt.core.dom.ast.IFunction;
import org.eclipse.cdt.core.dom.ast.IPointerType;
import org.eclipse.cdt.core.dom.ast.IProblemBinding;
import org.eclipse.cdt.core.dom.ast.IType;
import org.eclipse.cdt.core.dom.ast.IVariable;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTFieldReference;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPField;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPFunction;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPMember;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPMethod;
@ -39,6 +41,7 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPReferenceType;
import org.eclipse.cdt.internal.core.dom.parser.ASTNode;
import org.eclipse.cdt.internal.core.dom.parser.IASTAmbiguityParent;
import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPSemantics;
import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CVQualifier;
import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.SemanticUtil;
public class CPPASTFieldReference extends ASTNode implements ICPPASTFieldReference, IASTAmbiguityParent,
@ -190,7 +193,28 @@ public class CPPASTFieldReference extends ASTNode implements ICPPASTFieldReferen
IBinding binding = name.resolvePreBinding();
try {
if (binding instanceof IVariable) {
return SemanticUtil.mapToAST(((IVariable) binding).getType(), this);
IType e2= ((IVariable) binding).getType();
if (binding instanceof ICPPField && !((ICPPField) binding).isStatic()) {
IType e1= getFieldOwner().getExpressionType();
if (isPointerDereference()) {
e1= SemanticUtil.getNestedType(e1, TDEF | REF | CVTYPE);
if (e1 instanceof IPointerType) {
e1= ((IPointerType) e1).getType();
}
}
CVQualifier cvq1 = SemanticUtil.getCVQualifier(e1);
if (((ICPPField) binding).isMutable()) {
// Remove const, add union of volatile.
CVQualifier cvq2 = SemanticUtil.getCVQualifier(e2);
if (cvq2.isConst()) {
e2= SemanticUtil.getNestedType(e2, ALLCVQ | TDEF | REF);
}
e2= SemanticUtil.addQualifiers(e2, false, cvq1.isVolatile() || cvq2.isVolatile());
} else {
e2= SemanticUtil.addQualifiers(e2, cvq1.isConst(), cvq1.isVolatile());
}
}
return SemanticUtil.mapToAST(e2, this);
} else if (binding instanceof IEnumerator) {
return ((IEnumerator) binding).getType();
} else if (binding instanceof IFunction) {

View file

@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2004, 2009 IBM Corporation and others.
* Copyright (c) 2004, 2010 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
@ -12,16 +12,23 @@
package org.eclipse.cdt.internal.core.dom.parser.cpp;
import org.eclipse.cdt.core.dom.ast.ASTVisitor;
import org.eclipse.cdt.core.dom.ast.IASTExpression;
import org.eclipse.cdt.core.dom.ast.IASTNode;
import org.eclipse.cdt.core.dom.ast.IBasicType.Kind;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTSimpleDeclSpecifier;
import org.eclipse.cdt.internal.core.dom.parser.IASTAmbiguityParent;
public class CPPASTSimpleDeclSpecifier extends CPPASTBaseDeclSpecifier implements ICPPASTSimpleDeclSpecifier {
public class CPPASTSimpleDeclSpecifier extends CPPASTBaseDeclSpecifier implements ICPPASTSimpleDeclSpecifier,
IASTAmbiguityParent {
private int type;
private boolean isSigned;
private boolean isUnsigned;
private boolean isShort;
private boolean isLong;
private boolean isLonglong;
private boolean isComplex=false;
private boolean isImaginary=false;
private IASTExpression fDeclTypeExpression;
public CPPASTSimpleDeclSpecifier copy() {
CPPASTSimpleDeclSpecifier copy = new CPPASTSimpleDeclSpecifier();
@ -36,6 +43,12 @@ public class CPPASTSimpleDeclSpecifier extends CPPASTBaseDeclSpecifier implement
other.isUnsigned = isUnsigned;
other.isShort = isShort;
other.isLong = isLong;
other.isLonglong= isLonglong;
other.isComplex= isComplex;
other.isImaginary= isImaginary;
if (fDeclTypeExpression != null) {
other.setDeclTypeExpression(fDeclTypeExpression.copy());
}
}
/**
@ -92,7 +105,23 @@ public class CPPASTSimpleDeclSpecifier extends CPPASTBaseDeclSpecifier implement
return isLong;
}
public void setSigned(boolean value) {
public boolean isLongLong() {
return isLonglong;
}
public boolean isComplex() {
return isComplex;
}
public boolean isImaginary() {
return isImaginary;
}
public IASTExpression getDeclTypeExpression() {
return fDeclTypeExpression;
}
public void setSigned(boolean value) {
assertNotFrozen();
isSigned = value;
}
@ -112,7 +141,31 @@ public class CPPASTSimpleDeclSpecifier extends CPPASTBaseDeclSpecifier implement
isShort = value;
}
@Override
public void setLongLong(boolean value) {
assertNotFrozen();
isLonglong = value;
}
public void setComplex(boolean value) {
assertNotFrozen();
isComplex = value;
}
public void setImaginary(boolean value) {
assertNotFrozen();
isImaginary = value;
}
public void setDeclTypeExpression(IASTExpression expression) {
assertNotFrozen();
fDeclTypeExpression = expression;
if (expression != null) {
expression.setPropertyInParent(DECLTYPE_EXPRESSION);
expression.setParent(this);
}
}
@Override
public boolean accept(ASTVisitor action) {
if (action.shouldVisitDeclSpecifiers) {
switch (action.visit(this)) {
@ -121,6 +174,10 @@ public class CPPASTSimpleDeclSpecifier extends CPPASTBaseDeclSpecifier implement
default: break;
}
}
if (fDeclTypeExpression != null && !fDeclTypeExpression.accept(action))
return false;
if (action.shouldVisitDeclSpecifiers) {
switch (action.leave(this)) {
case ASTVisitor.PROCESS_ABORT: return false;
@ -130,4 +187,12 @@ public class CPPASTSimpleDeclSpecifier extends CPPASTBaseDeclSpecifier implement
}
return true;
}
public void replace(IASTNode child, IASTNode other) {
if (child == fDeclTypeExpression) {
other.setPropertyInParent(child.getPropertyInParent());
other.setParent(child.getParent());
fDeclTypeExpression= (IASTExpression) other;
}
}
}

View file

@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2004, 2009 IBM Corporation and others.
* Copyright (c) 2004, 2010 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
@ -19,7 +19,6 @@ import org.eclipse.cdt.core.dom.ast.IType;
import org.eclipse.cdt.core.dom.ast.ITypedef;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTSimpleDeclSpecifier;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPBasicType;
import org.eclipse.cdt.core.dom.ast.gnu.cpp.IGPPASTSimpleDeclSpecifier;
import org.eclipse.cdt.internal.core.dom.parser.ISerializableType;
import org.eclipse.cdt.internal.core.dom.parser.ITypeMarshalBuffer;
import org.eclipse.core.runtime.CoreException;
@ -58,19 +57,14 @@ public class CPPBasicType implements ICPPBasicType, ISerializableType {
}
private static int getModifiers(ICPPASTSimpleDeclSpecifier sds) {
int qualifiers=
return
( sds.isLong() ? IBasicType.IS_LONG : 0 ) |
( sds.isShort() ? IBasicType.IS_SHORT : 0 ) |
( sds.isSigned() ? IBasicType.IS_SIGNED: 0 ) |
( sds.isUnsigned()? IBasicType.IS_UNSIGNED : 0 );
if (sds instanceof IGPPASTSimpleDeclSpecifier) {
IGPPASTSimpleDeclSpecifier gsds= (IGPPASTSimpleDeclSpecifier) sds;
qualifiers |=
( gsds.isLongLong()? IBasicType.IS_LONG_LONG : 0 ) |
( gsds.isComplex() ? IBasicType.IS_COMPLEX : 0 ) |
( gsds.isImaginary()?IBasicType.IS_IMAGINARY : 0 );
}
return qualifiers;
( sds.isUnsigned()? IBasicType.IS_UNSIGNED : 0 ) |
( sds.isLongLong()? IBasicType.IS_LONG_LONG : 0 ) |
( sds.isComplex() ? IBasicType.IS_COMPLEX : 0 ) |
( sds.isImaginary()?IBasicType.IS_IMAGINARY : 0 );
}
private static Kind getKind(ICPPASTSimpleDeclSpecifier sds) {
@ -79,11 +73,11 @@ public class CPPBasicType implements ICPPBasicType, ISerializableType {
static Kind getKind(final int simpleDeclSpecType) {
switch(simpleDeclSpecType) {
case ICPPASTSimpleDeclSpecifier.t_bool:
case IASTSimpleDeclSpecifier.t_bool:
return Kind.eBoolean;
case IASTSimpleDeclSpecifier.t_char:
return Kind.eChar;
case ICPPASTSimpleDeclSpecifier.t_wchar_t:
case IASTSimpleDeclSpecifier.t_wchar_t:
return Kind.eWChar;
case IASTSimpleDeclSpecifier.t_double:
return Kind.eDouble;

View file

@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2006, 2009 IBM Corporation and others.
* Copyright (c) 2006, 2010 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
@ -107,7 +107,6 @@ import org.eclipse.cdt.core.dom.ast.gnu.IGNUASTCompoundStatementExpression;
import org.eclipse.cdt.core.dom.ast.gnu.cpp.IGPPASTExplicitTemplateInstantiation;
import org.eclipse.cdt.core.dom.ast.gnu.cpp.IGPPASTPointer;
import org.eclipse.cdt.core.dom.ast.gnu.cpp.IGPPASTPointerToMember;
import org.eclipse.cdt.core.dom.ast.gnu.cpp.IGPPASTSimpleDeclSpecifier;
import org.eclipse.cdt.core.parser.IScanner;
import org.eclipse.cdt.internal.core.dom.parser.NodeFactory;
@ -356,10 +355,6 @@ public class CPPNodeFactory extends NodeFactory implements ICPPNodeFactory {
return new CPPASTSimpleDeclSpecifier();
}
public IGPPASTSimpleDeclSpecifier newSimpleDeclSpecifierGPP() {
return new GPPASTSimpleDeclSpecifier();
}
public ICPPASTFunctionDeclarator newFunctionDeclarator(IASTName name) {
return new CPPASTFunctionDeclarator(name);
}
@ -529,4 +524,9 @@ public class CPPNodeFactory extends NodeFactory implements ICPPNodeFactory {
public ICPPASTPackExpansionExpression newPackExpansionExpression(IASTExpression pattern) {
return new CPPASTPackExpansionExpression(pattern);
}
@Deprecated
public org.eclipse.cdt.core.dom.ast.gnu.cpp.IGPPASTSimpleDeclSpecifier newSimpleDeclSpecifierGPP() {
return new GPPASTSimpleDeclSpecifier();
}
}

View file

@ -111,11 +111,9 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTVisibilityLabel;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPNodeFactory;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTCompositeTypeSpecifier.ICPPASTBaseSpecifier;
import org.eclipse.cdt.core.dom.ast.gnu.IGNUASTTypeIdExpression;
import org.eclipse.cdt.core.dom.ast.gnu.IGNUASTUnaryExpression;
import org.eclipse.cdt.core.dom.ast.gnu.cpp.IGPPASTExplicitTemplateInstantiation;
import org.eclipse.cdt.core.dom.ast.gnu.cpp.IGPPASTPointer;
import org.eclipse.cdt.core.dom.ast.gnu.cpp.IGPPASTPointerToMember;
import org.eclipse.cdt.core.dom.ast.gnu.cpp.IGPPASTSimpleDeclSpecifier;
import org.eclipse.cdt.core.dom.parser.IExtensionToken;
import org.eclipse.cdt.core.dom.parser.cpp.ICPPParserExtensionConfiguration;
import org.eclipse.cdt.core.index.IIndex;
@ -152,7 +150,6 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser {
private final boolean allowCPPRestrict;
private final boolean supportExtendedTemplateSyntax;
private final boolean supportLongLong;
private final IIndex index;
protected ICPPASTTranslationUnit translationUnit;
@ -181,7 +178,6 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser {
config.getBuiltinBindingsProvider());
allowCPPRestrict = config.allowRestrictPointerOperators();
supportExtendedTemplateSyntax = config.supportExtendedTemplateSyntax();
supportLongLong = config.supportLongLongs();
supportParameterInfoBlock= config.supportParameterInfoBlock();
supportExtendedSizeofOperator= config.supportExtendedSizeofOperator();
supportFunctionStyleAsm= config.supportFunctionStyleAssembler();
@ -414,7 +410,6 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser {
case IToken.t_new:
case IToken.t_delete:
case IToken.t_sizeof:
case IGCCToken.t_typeof:
case IGCCToken.t___alignof__:
// postfix expression
case IToken.t_typename:
@ -1087,9 +1082,6 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser {
}
return parseTypeidInParenthesisOrUnaryExpression(false, consume().getOffset(),
IASTTypeIdExpression.op_sizeof, IASTUnaryExpression.op_sizeof, ctx);
case IGCCToken.t_typeof:
return parseTypeidInParenthesisOrUnaryExpression(false, consume().getOffset(),
IASTTypeIdExpression.op_typeof, IASTUnaryExpression.op_typeof, ctx);
case IGCCToken.t___alignof__:
return parseTypeidInParenthesisOrUnaryExpression(false, consume().getOffset(),
IASTTypeIdExpression.op_alignof, IASTUnaryExpression.op_alignOf, ctx);
@ -2442,13 +2434,28 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser {
if (encounteredRawType || encounteredTypename)
throwBacktrack(LA(1));
typeofExpression= parseTypeidInParenthesisOrUnaryExpression(false, consume().getOffset(),
IGNUASTTypeIdExpression.op_typeof, IGNUASTUnaryExpression.op_typeof, CastExprCtx.eNotBExpr);
simpleType= IASTSimpleDeclSpecifier.t_typeof;
consume(IGCCToken.t_typeof);
typeofExpression= parseTypeidInParenthesisOrUnaryExpression(false, LA(1).getOffset(),
IGNUASTTypeIdExpression.op_typeof, -1, CastExprCtx.eNotBExpr);
encounteredTypename= true;
endOffset= calculateEndOffset(typeofExpression);
break;
case IToken.t_decltype:
if (encounteredRawType || encounteredTypename)
throwBacktrack(LA(1));
simpleType= IASTSimpleDeclSpecifier.t_decltype;
consume(IToken.t_decltype);
consume(IToken.tLPAREN);
typeofExpression= unaryExpression(CastExprCtx.eNotBExpr);
endOffset= consumeOrEOC(IToken.tRPAREN).getEndOffset();
encounteredTypename= true;
break;
default:
if (lt1 >= IExtensionToken.t__otherDeclSpecModifierFirst && lt1 <= IExtensionToken.t__otherDeclSpecModifierLast) {
handleOtherDeclSpecModifier();
@ -2510,31 +2517,19 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser {
private ICPPASTSimpleDeclSpecifier buildSimpleDeclSpec(int storageClass, int simpleType,
int options, int isLong, IASTExpression typeofExpression, int offset, int endOffset) {
if (isLong > 1 && !supportLongLong)
isLong= 1;
ICPPASTSimpleDeclSpecifier declSpec= null;
if (isLong > 1 || (options & (RESTRICT|COMPLEX|IMAGINARY)) != 0 || typeofExpression != null) {
final IGPPASTSimpleDeclSpecifier gppDeclSpec= nodeFactory.newSimpleDeclSpecifierGPP();
gppDeclSpec.setLongLong(isLong > 1);
gppDeclSpec.setRestrict((options & RESTRICT) != 0);
gppDeclSpec.setComplex((options & COMPLEX) != 0);
gppDeclSpec.setImaginary((options & IMAGINARY) != 0);
gppDeclSpec.setTypeofExpression(typeofExpression);
declSpec= gppDeclSpec;
} else {
declSpec = nodeFactory.newSimpleDeclSpecifier();
}
ICPPASTSimpleDeclSpecifier declSpec= nodeFactory.newSimpleDeclSpecifier();
configureDeclSpec(declSpec, storageClass, options);
declSpec.setType(simpleType);
declSpec.setLong(isLong == 1);
declSpec.setLongLong(isLong > 1);
declSpec.setShort((options & SHORT) != 0);
declSpec.setUnsigned((options & UNSIGNED) != 0);
declSpec.setSigned((options & SIGNED) != 0);
declSpec.setComplex((options & COMPLEX) != 0);
declSpec.setImaginary((options & IMAGINARY) != 0);
declSpec.setDeclTypeExpression(typeofExpression);
((ASTNode) declSpec).setOffsetAndLength(offset, endOffset-offset);
return declSpec;
@ -2548,6 +2543,7 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser {
declSpec.setFriend((options & FRIEND) != 0);
declSpec.setVirtual((options & VIRTUAL) != 0);
declSpec.setExplicit((options & EXPLICIT) != 0);
declSpec.setRestrict((options & RESTRICT) != 0);
}
/**
@ -2717,18 +2713,10 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser {
if (declspec instanceof ICPPASTSimpleDeclSpecifier) {
ICPPASTSimpleDeclSpecifier sspec= (ICPPASTSimpleDeclSpecifier) declspec;
switch(sspec.getType()) {
case IASTSimpleDeclSpecifier.t_unspecified:
if (sspec.isLong() || sspec.isShort() || sspec.isSigned() || sspec.isUnsigned())
return true;
if (sspec instanceof IGPPASTSimpleDeclSpecifier) {
final IGPPASTSimpleDeclSpecifier gspec = (IGPPASTSimpleDeclSpecifier) sspec;
if (gspec.isLongLong())
return true;
}
if (CPPVisitor.doesNotSpecifyType(declspec)) {
return false;
case IASTSimpleDeclSpecifier.t_void:
}
if (sspec.getType() == IASTSimpleDeclSpecifier.t_void) {
return false;
}
}

View file

@ -1,126 +1,47 @@
/*******************************************************************************
* Copyright (c) 2004, 2008 IBM Corporation and others.
* Copyright (c) 2004, 2010 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 - Initial API and implementation
* John Camelon (IBM) - Initial API and implementation
* Markus Schorn (Wind River Systems)
*******************************************************************************/
package org.eclipse.cdt.internal.core.dom.parser.cpp;
import org.eclipse.cdt.core.dom.ast.ASTVisitor;
import org.eclipse.cdt.core.dom.ast.IASTExpression;
import org.eclipse.cdt.core.dom.ast.IASTNode;
import org.eclipse.cdt.core.dom.ast.gnu.cpp.IGPPASTSimpleDeclSpecifier;
import org.eclipse.cdt.internal.core.dom.parser.IASTAmbiguityParent;
/**
* @author jcamelon
* @deprecated Replaced by {@link CPPASTSimpleDeclSpecifier}
*/
public class GPPASTSimpleDeclSpecifier extends CPPASTSimpleDeclSpecifier
implements IGPPASTSimpleDeclSpecifier, IASTAmbiguityParent {
@Deprecated
public class GPPASTSimpleDeclSpecifier extends CPPASTSimpleDeclSpecifier implements
IGPPASTSimpleDeclSpecifier {
private boolean longLong;
private boolean restrict;
private boolean complex=false;
private boolean imaginary=false;
private IASTExpression typeOfExpression;
public GPPASTSimpleDeclSpecifier() {
}
public GPPASTSimpleDeclSpecifier(IASTExpression typeofExpression) {
setTypeofExpression(typeofExpression);
super();
setDeclTypeExpression(typeofExpression);
}
@Override
public GPPASTSimpleDeclSpecifier copy() {
GPPASTSimpleDeclSpecifier copy = new GPPASTSimpleDeclSpecifier();
copySimpleDeclSpec(copy);
copy.setTypeofExpression(typeOfExpression == null ? null : typeOfExpression.copy());
copy.longLong = longLong;
copy.restrict = restrict;
copy.complex = complex;
copy.imaginary = imaginary;
return copy;
}
public boolean isLongLong() {
return longLong;
}
public void setLongLong(boolean value) {
longLong = value;
}
public boolean isRestrict() {
return restrict;
}
public void setRestrict(boolean value) {
restrict = value;
}
public void setTypeofExpression(IASTExpression typeofExpression) {
typeOfExpression = typeofExpression;
if (typeofExpression != null) {
typeofExpression.setParent(this);
typeofExpression.setPropertyInParent(TYPEOF_EXPRESSION);
}
setDeclTypeExpression(typeofExpression);
}
public IASTExpression getTypeofExpression() {
return typeOfExpression;
return getDeclTypeExpression();
}
@Override
public boolean accept( ASTVisitor action ){
if( action.shouldVisitDeclSpecifiers ){
switch( action.visit( this ) ){
case ASTVisitor.PROCESS_ABORT : return false;
case ASTVisitor.PROCESS_SKIP : return true;
default : break;
}
}
if( typeOfExpression != null )
if( !typeOfExpression.accept( action ) ) return false;
if( action.shouldVisitDeclSpecifiers ){
switch( action.leave( this ) ){
case ASTVisitor.PROCESS_ABORT : return false;
case ASTVisitor.PROCESS_SKIP : return true;
default : break;
}
}
return true;
}
public boolean isComplex() {
return complex;
}
public void setComplex(boolean value) {
this.complex = value;
}
public boolean isImaginary() {
return imaginary;
}
public void setImaginary(boolean value) {
this.imaginary = value;
}
public void replace(IASTNode child, IASTNode other) {
if (child == typeOfExpression) {
other.setPropertyInParent(child.getPropertyInParent());
other.setParent(child.getParent());
typeOfExpression= (IASTExpression) other;
}
}
}

View file

@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2004, 2009 IBM Corporation and others.
* Copyright (c) 2004, 2010 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
@ -64,6 +64,7 @@ import org.eclipse.cdt.core.dom.ast.IBinding;
import org.eclipse.cdt.core.dom.ast.ICompositeType;
import org.eclipse.cdt.core.dom.ast.IEnumeration;
import org.eclipse.cdt.core.dom.ast.IEnumerator;
import org.eclipse.cdt.core.dom.ast.IFunction;
import org.eclipse.cdt.core.dom.ast.IFunctionType;
import org.eclipse.cdt.core.dom.ast.ILabel;
import org.eclipse.cdt.core.dom.ast.IParameter;
@ -129,7 +130,6 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPUsingDeclaration;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTCompositeTypeSpecifier.ICPPASTBaseSpecifier;
import org.eclipse.cdt.core.dom.ast.gnu.cpp.IGPPASTPointer;
import org.eclipse.cdt.core.dom.ast.gnu.cpp.IGPPASTPointerToMember;
import org.eclipse.cdt.core.dom.ast.gnu.cpp.IGPPASTSimpleDeclSpecifier;
import org.eclipse.cdt.core.index.IIndexBinding;
import org.eclipse.cdt.core.parser.util.ArrayUtil;
import org.eclipse.cdt.core.parser.util.CharArrayUtils;
@ -1742,13 +1742,8 @@ public class CPPVisitor extends ASTQueries {
name = ((IASTEnumerationSpecifier)declSpec).getName();
} else if (declSpec instanceof ICPPASTSimpleDeclSpecifier) {
ICPPASTSimpleDeclSpecifier spec = (ICPPASTSimpleDeclSpecifier) declSpec;
if (spec instanceof IGPPASTSimpleDeclSpecifier) {
IGPPASTSimpleDeclSpecifier gspec = (IGPPASTSimpleDeclSpecifier) spec;
final IASTExpression typeofExpression = gspec.getTypeofExpression();
if (typeofExpression != null) {
type = typeofExpression.getExpressionType();
}
}
// Check for decltype(expr)
type = getDeclType(spec);
if (type == null) {
type = new CPPBasicType(spec);
}
@ -1782,6 +1777,55 @@ public class CPPVisitor extends ASTQueries {
return type;
}
/**
* Compute the type for decltype(expr) or typeof(expr)
*/
private static IType getDeclType(ICPPASTSimpleDeclSpecifier spec) {
IASTExpression expr = spec.getDeclTypeExpression();
if (expr == null)
return null;
if (spec.getType() == IASTSimpleDeclSpecifier.t_decltype) {
IASTName namedEntity= null;
if (expr instanceof IASTIdExpression) {
namedEntity= ((IASTIdExpression) expr).getName();
} else if (expr instanceof IASTFieldReference) {
namedEntity= ((IASTFieldReference) expr).getFieldName();
}
if (namedEntity != null) {
IBinding b= namedEntity.resolvePreBinding();
if (b instanceof IType) {
return (IType) b;
}
try {
if (b instanceof IVariable) {
return ((IVariable) b).getType();
}
if (b instanceof IFunction) {
return ((IFunction) b).getType();
}
} catch (DOMException e) {
return e.getProblem();
}
}
}
IType type = expr.getExpressionType();
if (spec.getType() == IASTSimpleDeclSpecifier.t_decltype) {
while (expr instanceof IASTUnaryExpression
&& ((IASTUnaryExpression) expr).getOperator() == IASTUnaryExpression.op_bracketedPrimary) {
expr = ((IASTUnaryExpression) expr).getOperand();
}
if (!(expr instanceof IASTFunctionCallExpression)) {
type= SemanticUtil.getNestedType(type, TDEF | REF);
if (expr.isLValue())
type= new CPPReferenceType(type, false);
}
} else {
type= SemanticUtil.getNestedType(type, TDEF | REF);
}
return type;
}
public static IType getThisType(IScope scope) {
try {
IASTNode node = null;
@ -2182,12 +2226,7 @@ public class CPPVisitor extends ASTQueries {
if (declspec instanceof ICPPASTSimpleDeclSpecifier) {
ICPPASTSimpleDeclSpecifier ds= (ICPPASTSimpleDeclSpecifier) declspec;
if (ds.getType() == IASTSimpleDeclSpecifier.t_unspecified) {
if (ds instanceof IGPPASTSimpleDeclSpecifier) {
final IGPPASTSimpleDeclSpecifier gds = (IGPPASTSimpleDeclSpecifier) ds;
if (gds.isLongLong() || gds.getTypeofExpression() != null)
return false;
}
if (ds.isShort() || ds.isLong() || ds.isSigned() || ds.isUnsigned())
if (ds.isShort() || ds.isLong() || ds.isLongLong() || ds.isSigned() || ds.isUnsigned())
return false;
return true;

View file

@ -171,7 +171,7 @@ public class SemanticUtil {
/**
* Returns 0 for no qualifier, 1 for const, 2 for volatile and 3 for const volatile.
*/
static CVQualifier getCVQualifier(IType t) {
public static CVQualifier getCVQualifier(IType t) {
if (t instanceof IQualifierType) {
IQualifierType qt= (IQualifierType) t;
if (qt.isConst()) {

View file

@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2008, 2009 Institute for Software, HSR Hochschule fuer Technik
* Copyright (c) 2008, 2010 Institute for Software, HSR Hochschule fuer Technik
* Rapperswil, University of applied sciences and others
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
@ -37,7 +37,6 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTTypeIdExpression;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTTypenameExpression;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTUnaryExpression;
import org.eclipse.cdt.core.dom.ast.gnu.IGNUASTTypeIdExpression;
import org.eclipse.cdt.core.dom.ast.gnu.IGNUASTUnaryExpression;
import org.eclipse.cdt.core.dom.ast.gnu.cpp.IGPPASTBinaryExpression;
import org.eclipse.cdt.internal.core.dom.rewrite.commenthandler.NodeCommentMap;
@ -252,8 +251,8 @@ public class ExpressionWriter extends NodeWriter{
case IASTUnaryExpression.op_bracketedPrimary:
case ICPPASTUnaryExpression.op_throw:
case ICPPASTUnaryExpression.op_typeid:
case IGNUASTUnaryExpression.op_alignOf:
case IGNUASTUnaryExpression.op_typeof:
case IASTUnaryExpression.op_alignOf:
case IASTUnaryExpression.op_typeof:
return true;
default:
@ -268,8 +267,8 @@ public class ExpressionWriter extends NodeWriter{
case IASTUnaryExpression.op_postFixIncr:
case IASTUnaryExpression.op_bracketedPrimary:
case ICPPASTUnaryExpression.op_typeid:
case IGNUASTUnaryExpression.op_alignOf:
case IGNUASTUnaryExpression.op_typeof:
case IASTUnaryExpression.op_alignOf:
case IASTUnaryExpression.op_typeof:
return true;
default:
@ -306,9 +305,9 @@ public class ExpressionWriter extends NodeWriter{
return THROW;
case ICPPASTUnaryExpression.op_typeid:
return TYPEID_OP;
case IGNUASTUnaryExpression.op_alignOf:
case IASTUnaryExpression.op_alignOf:
return ALIGNOF_OP;
case IGNUASTUnaryExpression.op_typeof:
case IASTUnaryExpression.op_typeof:
return TYPEOF_OP;
default:
System.err.println("Unkwown unaryExpressionType: " + unaryExpressionType); //$NON-NLS-1$
@ -326,8 +325,8 @@ public class ExpressionWriter extends NodeWriter{
case ICPPASTUnaryExpression.op_typeid:
return CLOSING_BRACKET_OP;
case IASTUnaryExpression.op_bracketedPrimary:
case IGNUASTUnaryExpression.op_alignOf:
case IGNUASTUnaryExpression.op_typeof:
case IASTUnaryExpression.op_alignOf:
case IASTUnaryExpression.op_typeof:
return CLOSING_BRACKET_OP;
default:
System.err.println("Unkwown unaryExpressionType " + unaryExpressionType); //$NON-NLS-1$

View file

@ -1,12 +1,13 @@
/*******************************************************************************
* Copyright (c) 2002, 2008 IBM Corporation and others.
* Copyright (c) 2002, 2010 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
* John Camelon (IBM Rational Software) - Initial API and implementation
* Markus Schorn (Wind River Systems)
*******************************************************************************/
package org.eclipse.cdt.internal.core.parser.token;
@ -21,9 +22,6 @@ import org.eclipse.cdt.core.parser.KeywordSetKey;
import org.eclipse.cdt.core.parser.Keywords;
import org.eclipse.cdt.core.parser.ParserLanguage;
/**
* @author jcamelon
*/
public class KeywordSets {
public static Set<String> getKeywords( KeywordSetKey kind, ParserLanguage language )
@ -417,6 +415,7 @@ public class KeywordSets {
ALL_CPP.add( Keywords.CONST);
ALL_CPP.add( Keywords.CONST_CAST);
ALL_CPP.add( Keywords.CONTINUE);
ALL_CPP.add( Keywords.DECLTYPE);
ALL_CPP.add( Keywords.DEFAULT);
ALL_CPP.add( Keywords.DELETE);
ALL_CPP.add( Keywords.DO);
@ -504,6 +503,7 @@ public class KeywordSets {
KEYWORDS_CPP.add( Keywords.CONST );
KEYWORDS_CPP.add( Keywords.CONST_CAST );
KEYWORDS_CPP.add( Keywords.CONTINUE );
KEYWORDS_CPP.add( Keywords.DECLTYPE);
KEYWORDS_CPP.add( Keywords.DEFAULT );
KEYWORDS_CPP.add( Keywords.DELETE );
KEYWORDS_CPP.add( Keywords.DO );

View file

@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2008 Institute for Software, HSR Hochschule fuer Technik
* Copyright (c) 2008, 2010 Institute for Software, HSR Hochschule fuer Technik
* Rapperswil, University of applied sciences and others
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
@ -7,12 +7,10 @@
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Institute for Software - initial API and implementation
* Institute for Software - initial API and implementation
*******************************************************************************/
package org.eclipse.cdt.internal.ui.refactoring.extractfunction;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
@ -47,7 +45,6 @@ import org.eclipse.cdt.core.dom.ast.IBinding;
import org.eclipse.cdt.core.dom.ast.IType;
import org.eclipse.cdt.core.dom.ast.c.ICASTDeclSpecifier;
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.cpp.ICPPASTCatchHandler;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTConversionName;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTDeclSpecifier;
@ -64,10 +61,8 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTTypenameExpression;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTUsingDeclaration;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTVisibilityLabel;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPVariable;
import org.eclipse.cdt.core.dom.ast.gnu.cpp.IGPPASTDeclSpecifier;
import org.eclipse.cdt.core.dom.ast.gnu.cpp.IGPPASTExplicitTemplateInstantiation;
import org.eclipse.cdt.core.dom.ast.gnu.cpp.IGPPASTPointer;
import org.eclipse.cdt.core.dom.ast.gnu.cpp.IGPPASTSimpleDeclSpecifier;
import org.eclipse.cdt.core.index.IIndex;
import org.eclipse.cdt.core.index.IIndexName;
@ -137,33 +132,7 @@ public class TrailNodeEqualityChecker implements EqualityChecker<IASTNode> {
}
private boolean isDeclSpecifierEquals(IASTNode trailNode, IASTNode node) {
if (trailNode instanceof IGPPASTSimpleDeclSpecifier) {
IGPPASTSimpleDeclSpecifier trailSimpleDecl = (IGPPASTSimpleDeclSpecifier) trailNode;
IGPPASTSimpleDeclSpecifier simpleDecl = (IGPPASTSimpleDeclSpecifier) node;
return isSimpleDeclSpecifierEquals(trailSimpleDecl, simpleDecl)
&& trailSimpleDecl.isComplex() == simpleDecl.isComplex()
&& trailSimpleDecl.isImaginary() == simpleDecl.isImaginary()
&& trailSimpleDecl.isLongLong() == simpleDecl.isLongLong()
&& trailSimpleDecl.isComplex() == simpleDecl.isComplex()
&& trailSimpleDecl.isExplicit() == simpleDecl.isExplicit()
&& trailSimpleDecl.isFriend() == simpleDecl.isFriend();
} else if (trailNode instanceof IGPPASTDeclSpecifier) {
IGPPASTDeclSpecifier trailDecl = (IGPPASTDeclSpecifier) trailNode;
IGPPASTDeclSpecifier decl = (IGPPASTDeclSpecifier) node;
return isDeclSpecifierEquals(trailDecl, decl)
&& trailDecl.isRestrict() == decl.isRestrict();
} else if (trailNode instanceof ICASTSimpleDeclSpecifier) {
ICASTSimpleDeclSpecifier trailDecl = (ICASTSimpleDeclSpecifier) trailNode;
ICASTSimpleDeclSpecifier decl = (ICASTSimpleDeclSpecifier) node;
return isSimpleDeclSpecifierEquals(trailDecl, decl)
&& trailDecl.isRestrict() == decl.isRestrict()
&& trailDecl.isComplex() == decl.isComplex()
&& trailDecl.isImaginary() == decl.isImaginary()
&& trailDecl.isLongLong() == decl.isLongLong();
} else if (trailNode instanceof IASTSimpleDeclSpecifier) {
if (trailNode instanceof IASTSimpleDeclSpecifier) {
IASTSimpleDeclSpecifier trailDecl = (IASTSimpleDeclSpecifier) trailNode;
IASTSimpleDeclSpecifier decl = (IASTSimpleDeclSpecifier) node;
@ -386,9 +355,21 @@ public class TrailNodeEqualityChecker implements EqualityChecker<IASTNode> {
}
private boolean isDeclSpecifierEquals(IASTDeclSpecifier trailDeclSpeci, IASTDeclSpecifier declSpeci){
if (trailDeclSpeci instanceof ICPPASTDeclSpecifier) {
ICPPASTDeclSpecifier trailCppDecl= (ICPPASTDeclSpecifier) trailDeclSpeci;
ICPPASTDeclSpecifier cppDecl= (ICPPASTDeclSpecifier) declSpeci;
if (trailCppDecl.isExplicit() == cppDecl.isExplicit()
&& trailCppDecl.isFriend() == cppDecl.isFriend()
&& trailCppDecl.isVirtual() == cppDecl.isVirtual()) {
// ok
} else {
return false;
}
}
return trailDeclSpeci.isConst() == declSpeci.isConst()
&& trailDeclSpeci.isInline() == declSpeci.isInline()
&& trailDeclSpeci.isVolatile() == declSpeci.isVolatile()
&& trailDeclSpeci.isRestrict() == declSpeci.isRestrict()
&& trailDeclSpeci.getStorageClass() == declSpeci.getStorageClass();
}
@ -398,7 +379,10 @@ public class TrailNodeEqualityChecker implements EqualityChecker<IASTNode> {
&& trailDeclSpeci.isShort() == declSpeci.isShort()
&& trailDeclSpeci.isSigned() == declSpeci.isSigned()
&& trailDeclSpeci.isUnsigned() == declSpeci.isUnsigned()
&& trailDeclSpeci.getType() == declSpeci.getType();
&& trailDeclSpeci.getType() == declSpeci.getType()
&& trailDeclSpeci.isComplex() == declSpeci.isComplex()
&& trailDeclSpeci.isImaginary() == declSpeci.isImaginary()
&& trailDeclSpeci.isLongLong() == declSpeci.isLongLong();
}
private boolean isNameEquals(TrailName trailName, IASTName name) {