1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-06-07 17:56:01 +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.ICPPUsingDeclaration;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPVariable; 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.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.IGPPPointerToMemberType;
import org.eclipse.cdt.core.dom.ast.gnu.cpp.IGPPPointerType; import org.eclipse.cdt.core.dom.ast.gnu.cpp.IGPPPointerType;
import org.eclipse.cdt.core.parser.ParserLanguage; import org.eclipse.cdt.core.parser.ParserLanguage;
@ -4670,10 +4669,10 @@ public class AST2CPPTests extends AST2BaseTest {
IASTTranslationUnit tu = parse( getAboveComment(), ParserLanguage.CPP, true, true ); IASTTranslationUnit tu = parse( getAboveComment(), ParserLanguage.CPP, true, true );
IASTDeclaration[] decls = tu.getDeclarations(); IASTDeclaration[] decls = tu.getDeclarations();
assertTrue(((IGPPASTSimpleDeclSpecifier)((IASTSimpleDeclaration)decls[0]).getDeclSpecifier()).isComplex()); assertTrue(((IASTSimpleDeclSpecifier)((IASTSimpleDeclaration)decls[0]).getDeclSpecifier()).isComplex());
assertEquals(((IGPPASTSimpleDeclSpecifier)((IASTSimpleDeclaration)decls[0]).getDeclSpecifier()).getType(), IASTSimpleDeclSpecifier.t_float); assertEquals(((IASTSimpleDeclSpecifier)((IASTSimpleDeclaration)decls[0]).getDeclSpecifier()).getType(), IASTSimpleDeclSpecifier.t_float);
assertTrue(((IGPPASTSimpleDeclSpecifier)((IASTSimpleDeclaration)decls[1]).getDeclSpecifier()).isComplex()); assertTrue(((IASTSimpleDeclSpecifier)((IASTSimpleDeclaration)decls[1]).getDeclSpecifier()).isComplex());
assertEquals(((IGPPASTSimpleDeclSpecifier)((IASTSimpleDeclaration)decls[1]).getDeclSpecifier()).getType(), IASTSimpleDeclSpecifier.t_double); assertEquals(((IASTSimpleDeclSpecifier)((IASTSimpleDeclaration)decls[1]).getDeclSpecifier()).getType(), IASTSimpleDeclSpecifier.t_double);
} }
// class _A { // class _A {
@ -8010,5 +8009,41 @@ public class AST2CPPTests extends AST2BaseTest {
b= bh.assertNonProblem("f(a, 1)", 1); b= bh.assertNonProblem("f(a, 1)", 1);
assertSame(b, glob); 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 * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0 * are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at * 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.ICPPASTPointerToMember;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTQualifiedName; 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.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.ICPPASTSimpleTypeTemplateParameter;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTTemplateId; import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTTemplateId;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTTemplateParameter; 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.cpp.ICPPASTTypenameExpression;
import org.eclipse.cdt.core.dom.ast.gnu.c.ICASTKnRFunctionDeclarator; 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.IGPPASTPointer;
import org.eclipse.cdt.core.dom.ast.gnu.cpp.IGPPASTSimpleDeclSpecifier;
import org.eclipse.cdt.core.parser.Keywords; import org.eclipse.cdt.core.parser.Keywords;
import org.eclipse.cdt.internal.core.dom.parser.ASTQueries; import org.eclipse.cdt.internal.core.dom.parser.ASTQueries;
@ -579,27 +577,14 @@ public class ASTStringUtil {
if (simpleDeclSpec.isLong()) { if (simpleDeclSpec.isLong()) {
buffer.append(Keywords.LONG).append(' '); buffer.append(Keywords.LONG).append(' ');
} }
if (simpleDeclSpec instanceof ICASTSimpleDeclSpecifier) { if (simpleDeclSpec.isLongLong()) {
final ICASTSimpleDeclSpecifier cSimpleDeclSpec= (ICASTSimpleDeclSpecifier)simpleDeclSpec; buffer.append(Keywords.LONG_LONG).append(' ');
if (cSimpleDeclSpec.isLongLong()) { }
buffer.append(Keywords.LONG_LONG).append(' '); if (simpleDeclSpec.isComplex()) {
} buffer.append(Keywords._COMPLEX).append(' ');
if (cSimpleDeclSpec.isComplex()) { }
buffer.append(Keywords._COMPLEX).append(' '); if (simpleDeclSpec.isImaginary()) {
} buffer.append(Keywords._IMAGINARY).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(' ');
}
} }
switch (simpleDeclSpec.getType()) { switch (simpleDeclSpec.getType()) {
case IASTSimpleDeclSpecifier.t_void: case IASTSimpleDeclSpecifier.t_void:
@ -617,10 +602,14 @@ public class ASTStringUtil {
case IASTSimpleDeclSpecifier.t_double: case IASTSimpleDeclSpecifier.t_double:
buffer.append(Keywords.DOUBLE).append(' '); buffer.append(Keywords.DOUBLE).append(' ');
break; break;
case ICPPASTSimpleDeclSpecifier.t_bool: case IASTSimpleDeclSpecifier.t_bool:
buffer.append(Keywords.BOOL).append(' '); if (simpleDeclSpec instanceof ICASTSimpleDeclSpecifier) {
buffer.append(Keywords.cBOOL).append(' ');
} else {
buffer.append(Keywords.BOOL).append(' ');
}
break; break;
case ICPPASTSimpleDeclSpecifier.t_wchar_t: case IASTSimpleDeclSpecifier.t_wchar_t:
buffer.append(Keywords.WCHAR_T).append(' '); buffer.append(Keywords.WCHAR_T).append(' ');
break; break;
default: 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 * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0 * are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at * 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.ICASTArrayDesignator;
import org.eclipse.cdt.core.dom.ast.c.ICASTArrayModifier; 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.ICASTDesignatedInitializer;
import org.eclipse.cdt.core.dom.ast.c.ICASTDesignator; import org.eclipse.cdt.core.dom.ast.c.ICASTDesignator;
import org.eclipse.cdt.core.dom.ast.c.ICASTFieldDesignator; 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.ICPPASTNewExpression;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTPackExpansionExpression; 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.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.ICPPASTSimpleTypeConstructorExpression;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTTypeIdExpression; 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.ICPPASTTypenameExpression;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTUnaryExpression; 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.IGNUASTCompoundStatementExpression;
import org.eclipse.cdt.core.dom.ast.gnu.IGNUASTTypeIdExpression; 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.ICASTKnRFunctionDeclarator;
import org.eclipse.cdt.core.dom.ast.gnu.c.IGCCASTArrayRangeDesignator; 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.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.core.parser.Keywords;
import org.eclipse.cdt.internal.core.dom.parser.ASTProblem; import org.eclipse.cdt.internal.core.dom.parser.ASTProblem;
@ -440,7 +434,7 @@ public class ASTSignatureUtil {
StringBuffer result = new StringBuffer(); StringBuffer result = new StringBuffer();
if (declSpec.getStorageClass() == ICPPASTDeclSpecifier.sc_mutable) { if (declSpec.getStorageClass() == IASTDeclSpecifier.sc_mutable) {
result.append(Keywords.MUTABLE); result.append(Keywords.MUTABLE);
needSpace = true; needSpace = true;
} }
@ -501,6 +495,14 @@ public class ASTSignatureUtil {
result.append(Keywords.INLINE); result.append(Keywords.INLINE);
needSpace = true; needSpace = true;
} }
if (declSpec.isRestrict()) {
if (needSpace) {
result.append(SPACE);
needSpace = false;
}
result.append(Keywords.RESTRICT);
needSpace = true;
}
if (declSpec.isVolatile()) { if (declSpec.isVolatile()) {
if (needSpace) { if (needSpace) {
result.append(SPACE); result.append(SPACE);
@ -510,24 +512,7 @@ public class ASTSignatureUtil {
needSpace = true; needSpace = true;
} }
if (declSpec instanceof ICASTDeclSpecifier) { if (declSpec instanceof ICPPASTDeclSpecifier) {
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 (((ICPPASTDeclSpecifier) declSpec).isExplicit()) { if (((ICPPASTDeclSpecifier) declSpec).isExplicit()) {
if (needSpace) { if (needSpace) {
result.append(SPACE); result.append(SPACE);
@ -552,15 +537,6 @@ public class ASTSignatureUtil {
result.append(Keywords.VIRTUAL); result.append(Keywords.VIRTUAL);
needSpace = true; 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 // handle complex cases
@ -631,100 +607,32 @@ public class ASTSignatureUtil {
result.append(((IASTNamedTypeSpecifier) declSpec).getName().toString()); result.append(((IASTNamedTypeSpecifier) declSpec).getName().toString());
needSpace = true; needSpace = true;
} else if (declSpec instanceof IASTSimpleDeclSpecifier) { } else if (declSpec instanceof IASTSimpleDeclSpecifier) {
// handle complex cases final IASTSimpleDeclSpecifier sds = (IASTSimpleDeclSpecifier) declSpec;
if (declSpec instanceof IGPPASTSimpleDeclSpecifier) { if (sds.isLongLong()) {
if (((IGPPASTSimpleDeclSpecifier) declSpec).isLongLong()) if (needSpace) {
result.append(Keywords.LONG_LONG); result.append(SPACE);
if (((IGPPASTSimpleDeclSpecifier) declSpec).isComplex()) { needSpace = false;
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;
} }
result.append(Keywords.LONG_LONG);
needSpace = true;
} }
if (sds.isComplex()) {
if (declSpec instanceof ICPPASTSimpleDeclSpecifier) { if (needSpace) {
switch (((ICPPASTSimpleDeclSpecifier) declSpec).getType()) { result.append(SPACE);
case ICPPASTSimpleDeclSpecifier.t_bool: needSpace = false;
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;
} }
result.append(Keywords.c_COMPLEX);
needSpace = true;
} }
if (sds.isImaginary()) {
if (declSpec instanceof ICASTSimpleDeclSpecifier) { if (needSpace) {
if (((ICASTSimpleDeclSpecifier) declSpec).isLongLong()) { result.append(SPACE);
if (needSpace) { needSpace = false;
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;
} }
result.append(Keywords.c_IMAGINARY);
needSpace = true;
} }
if (sds.isLong()) {
// handle simple cases
if (((IASTSimpleDeclSpecifier) declSpec).isLong()) {
if (needSpace) { if (needSpace) {
result.append(SPACE); result.append(SPACE);
needSpace = false; needSpace = false;
@ -732,7 +640,7 @@ public class ASTSignatureUtil {
result.append(Keywords.LONG); result.append(Keywords.LONG);
needSpace = true; needSpace = true;
} }
if (((IASTSimpleDeclSpecifier) declSpec).isShort()) { if (sds.isShort()) {
if (needSpace) { if (needSpace) {
result.append(SPACE); result.append(SPACE);
needSpace = false; needSpace = false;
@ -740,7 +648,7 @@ public class ASTSignatureUtil {
result.append(Keywords.SHORT); result.append(Keywords.SHORT);
needSpace = true; needSpace = true;
} }
if (((IASTSimpleDeclSpecifier) declSpec).isSigned()) { if (sds.isSigned()) {
if (needSpace) { if (needSpace) {
result.append(SPACE); result.append(SPACE);
needSpace = false; needSpace = false;
@ -748,7 +656,7 @@ public class ASTSignatureUtil {
result.append(Keywords.SIGNED); result.append(Keywords.SIGNED);
needSpace = true; needSpace = true;
} }
if (((IASTSimpleDeclSpecifier) declSpec).isUnsigned()) { if (sds.isUnsigned()) {
if (needSpace) { if (needSpace) {
result.append(SPACE); result.append(SPACE);
needSpace = false; needSpace = false;
@ -757,7 +665,35 @@ public class ASTSignatureUtil {
needSpace = true; 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: case IASTSimpleDeclSpecifier.t_char:
if (needSpace) { if (needSpace) {
result.append(SPACE); result.append(SPACE);
@ -766,6 +702,14 @@ public class ASTSignatureUtil {
result.append(Keywords.CHAR); result.append(Keywords.CHAR);
needSpace = true; needSpace = true;
break; 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: case IASTSimpleDeclSpecifier.t_double:
if (needSpace) { if (needSpace) {
result.append(SPACE); result.append(SPACE);
@ -1181,21 +1125,14 @@ public class ASTSignatureUtil {
opString = Keywords.TYPEID; opString = Keywords.TYPEID;
break; 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)) if (!opString.equals(EMPTY_STRING))
return opString; return opString;
switch (op) { switch (op) {
case IASTUnaryExpression.op_alignOf:
opString = Keywords.ALIGNOF;
break;
case IASTUnaryExpression.op_amper: case IASTUnaryExpression.op_amper:
opString = String.valueOf(Keywords.cpAMPER); opString = String.valueOf(Keywords.cpAMPER);
break; 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 * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0 * are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at * which accompanies this distribution, and is available at
@ -20,108 +20,71 @@ package org.eclipse.cdt.core.dom.ast;
public interface IASTDeclSpecifier extends IASTNode { public interface IASTDeclSpecifier extends IASTNode {
/** /**
* <code>sc_unspecified</code> undefined storage class * No storage class specified.
*/ */
public static final int sc_unspecified = 0; public static final int sc_unspecified = 0;
/**
* <code>sc_typedef</code> typedef
*/
public static final int sc_typedef = 1; public static final int sc_typedef = 1;
/**
* <code>sc_extern</code>extern
*/
public static final int sc_extern = 2; public static final int sc_extern = 2;
/**
* <code>sc_static</code>static
*/
public static final int sc_static = 3; public static final int sc_static = 3;
/**
* <code>sc_auto</code>auto
*/
public static final int sc_auto = 4; public static final int sc_auto = 4;
/**
* <code>sc_register</code>register
*/
public static final int sc_register = 5; 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. * Returns the storage class, which is one of the constants sc_...
*
* @param storageClass
* int
*/
public void setStorageClass(int storageClass);
/**
* Get the storage class.
*
* @return int
*/ */
public int getStorageClass(); public int getStorageClass();
// Type qualifier // Type qualifier
/**
* Is const modifier used?
*
* @return boolean
*/
public boolean isConst(); public boolean isConst();
/**
* Set const modifier used.
*
* @param value
* boolean
*/
public void setConst(boolean value);
/**
* Is volatile modifier used?
*
* @return boolean
*/
public boolean isVolatile(); public boolean isVolatile();
/** /**
* Set volatile modifier used. * @since 5.2
*
* @param value
* boolean
*/ */
public void setVolatile(boolean value); public boolean isRestrict();
// Function specifier // Function specifier
/**
* Is inline modifier used?
*
* @return boolean
*/
public boolean isInline(); public boolean isInline();
/**
* Set inline modifier used.
*
* @param value
* boolean
*/
public void setInline(boolean value);
/** /**
* @since 5.1 * @since 5.1
*/ */
public IASTDeclSpecifier copy(); 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 * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0 * are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at * 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. * @noimplement This interface is not intended to be implemented by clients.
*/ */
public interface IASTSimpleDeclSpecifier extends IASTDeclSpecifier { public interface IASTSimpleDeclSpecifier extends IASTDeclSpecifier {
/** /**
* This returns the built-in type for the declaration. The type is then * @since 5.2
* refined by qualifiers for signed/unsigned and short/long. The type could
* also be unspecified which usually means int.
*
*/ */
public int getType(); public static final ASTNodeProperty DECLTYPE_EXPRESSION = new ASTNodeProperty(
"IASTSimpleDeclSpecifier.EXPRESSION [IASTExpression]"); //$NON-NLS-1$
/** /**
* <code>t_unspecified</code> implies an unspecified type. .e.g x = 5; // * Used for omitted declaration specifiers. E.g. for declaration of constructors,
* declaration w/t_unspecified type logically defaults to integer. * or in plain c, where this defaults to an integer.
*/ */
public static final int t_unspecified = 0; public static final int t_unspecified = 0;
/** /**
* <code>t_void</code> implies void type e.g. void x(); * <code>void x();</code>
*/ */
public static final int t_void = 1; public static final int t_void = 1;
/** /**
* <code>t_char</code> implies char type e.g. char y; * <code>char c;</code>
*/ */
public static final int t_char = 2; public static final int t_char = 2;
/** /**
* <code>t_int</code> implies int type e.g. int x; * <code>int i;</code>
*/ */
public static final int t_int = 3; public static final int t_int = 3;
/** /**
* <code>t_float</code> implies floating point type. e.g. float yy; * <code>float f;</code>
*/ */
public static final int t_float = 4; public static final int t_float = 4;
/** /**
* <code>t_double</code> implies double floating point type. e.g. double * <code>double d;</code>
* d;
*/ */
public static final int t_double = 5; public static final int t_double = 5;
/** /**
* <code>t_last</code> specified for subinterface definition. * Represents a boolean type (bool in c++, _Bool in c)
*/
public static final int t_last = t_double; // used only in subclasses
/**
* Set this decl specifier type to <code>type</code>.
*
* @param type
* (int)
*/
public void setType(int type);
/**
* Sets this declaration specifier to the type based on {@link IBasicType.Kind}.
* @since 5.2 * @since 5.2
*/ */
public void setType(Kind kind); public static final int t_bool = 6;
/** /**
* Is the type modified by the signed keyword? * <code>t_wchar_t c;</code>
* * @since 5.2
* @return boolean
*/ */
public boolean isSigned(); public static final int t_wchar_t = 7;
/** /**
* Is the type modified by the unsigned keyword? * <code>typeof 'c' c;</code>
* * @since 5.2
* @return boolean
*/ */
public boolean isUnsigned(); public static final int t_typeof = 8;
/** /**
* Is the type modified by the short keyword? * <code>decltype('c') c;</code>
* * @since 5.2
* @return boolean
*/ */
public boolean isShort(); public static final int t_decltype = 9;
/**
* 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
*/
public void setSigned(boolean value);
/**
* Change as to if the type is modified by the keyword unsigned.
*
* @param value
* boolean
*/
public void setUnsigned(boolean value);
/**
* Change as to if the type is modified by the keyword long.
*
* @param value
* boolean
*/
public void setLong(boolean value);
/**
* Change as to if the type is modified by the keyword short.
*
* @param value
* boolean
*/
public void setShort(boolean value);
/** /**
* @since 5.1 * @since 5.1
*/ */
public IASTSimpleDeclSpecifier copy(); 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>signed char c;</code>
*/
public boolean isSigned();
/**
* <code>unsigned int u;</code>
*/
public boolean isUnsigned();
/**
* <code>short int s;</code>
*/
public boolean isShort();
/**
* <code>long int l;</code>
*/
public boolean isLong();
/**
* <code>long long int l;</code>
* @since 5.2
*/
public boolean isLongLong();
/**
* <code>_Complex t</code>;
* @since 5.2
*/
public boolean isComplex();
/**
* <code>_Imaginary t</code>;
* @since 5.2
*/
public boolean isImaginary();
/**
* 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 IASTExpression getDeclTypeExpression();
/**
* 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);
/**
* Not allowed on frozen ast.
* @see #isSigned()
*/
public void setSigned(boolean value);
/**
* Not allowed on frozen ast.
* @see #isUnsigned()
*/
public void setUnsigned(boolean value);
/**
* Not allowed on frozen ast.
* @see #isShort()
*/
public void setShort(boolean value);
/**
* Not allowed on frozen ast.
* @see #isLong()
*/
public void setLong(boolean value);
/**
* Not allowed on frozen ast.
* @see #isLongLong()
* @since 5.2
*/
public void setLongLong(boolean value);
/**
* Not allowed on frozen ast.
* @see #isComplex()
* @since 5.2
*/
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 * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0 * are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at * which accompanies this distribution, and is available at
@ -101,9 +101,9 @@ public interface IASTUnaryExpression extends IASTExpression {
public static final int op_typeid = 13; public static final int op_typeid = 13;
/** /**
* for gnu parsers, only. <code>op_typeof</code> is used for typeof( unaryExpression ) type * @deprecated Shall not be used, 'typeof something' is not an expression, it's a declaration specifier.
* expressions.
*/ */
@Deprecated
public static final int op_typeof = 14; 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 * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0 * are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at * which accompanies this distribution, and is available at
@ -7,6 +7,7 @@
* *
* Contributors: * Contributors:
* Doug Schaefer (IBM) - Initial API and implementation * Doug Schaefer (IBM) - Initial API and implementation
* Markus Schorn (Wind River Systems)
*******************************************************************************/ *******************************************************************************/
package org.eclipse.cdt.core.dom.ast.c; 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 { 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 * @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 * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0 * are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at * which accompanies this distribution, and is available at
@ -7,6 +7,7 @@
* *
* Contributors: * Contributors:
* Doug Schaefer (IBM) - Initial API and implementation * Doug Schaefer (IBM) - Initial API and implementation
* Markus Schorn (Wind River Systems)
*******************************************************************************/ *******************************************************************************/
package org.eclipse.cdt.core.dom.ast.c; 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. * @noextend This interface is not intended to be extended by clients.
* @noimplement This interface is not intended to be implemented by clients. * @noimplement This interface is not intended to be implemented by clients.
*/ */
public interface ICASTSimpleDeclSpecifier extends IASTSimpleDeclSpecifier, public interface ICASTSimpleDeclSpecifier extends IASTSimpleDeclSpecifier, ICASTDeclSpecifier {
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 * @since 5.1
*/ */
public ICASTSimpleDeclSpecifier copy(); 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 * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0 * are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at * which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html * http://www.eclipse.org/legal/epl-v10.html
* *
* Contributors: * 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; 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.INodeFactory;
import org.eclipse.cdt.core.dom.ast.gnu.c.ICASTKnRFunctionDeclarator; 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.IGCCASTArrayRangeDesignator;
import org.eclipse.cdt.core.dom.ast.gnu.c.IGCCASTSimpleDeclSpecifier;
/** /**
* Factory for AST nodes for the C programming language. * Factory for AST nodes for the C programming language.
* *
* @author Mike Kucera
* @since 5.1 * @since 5.1
* *
* @noextend This interface is not intended to be extended by clients. * @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 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 * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0 * are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at * which accompanies this distribution, and is available at
@ -7,6 +7,7 @@
* *
* Contributors: * Contributors:
* Doug Schaefer (IBM) - Initial API and implementation * Doug Schaefer (IBM) - Initial API and implementation
* Markus Schorn (Wind River Systems)
*******************************************************************************/ *******************************************************************************/
package org.eclipse.cdt.core.dom.ast.cpp; 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 { 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 // A declaration in C++ can be a friend declaration
/** /**
* Is this a friend declaration? * Is this a friend declaration?
@ -82,4 +72,9 @@ public interface ICPPASTDeclSpecifier extends IASTDeclSpecifier {
*/ */
public ICPPASTDeclSpecifier copy(); 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 * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0 * are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at * which accompanies this distribution, and is available at
@ -7,6 +7,7 @@
* *
* Contributors: * Contributors:
* Doug Schaefer (IBM) - Initial API and implementation * Doug Schaefer (IBM) - Initial API and implementation
* Markus Schorn (Wind River Systems)
*******************************************************************************/ *******************************************************************************/
package org.eclipse.cdt.core.dom.ast.cpp; 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. * @noextend This interface is not intended to be extended by clients.
* @noimplement This interface is not intended to be implemented by clients. * @noimplement This interface is not intended to be implemented by clients.
*/ */
public interface ICPPASTSimpleDeclSpecifier extends IASTSimpleDeclSpecifier, public interface ICPPASTSimpleDeclSpecifier extends IASTSimpleDeclSpecifier, ICPPASTDeclSpecifier {
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;
/** /**
* @since 5.1 * @since 5.1
*/ */
public ICPPASTSimpleDeclSpecifier copy(); 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 * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0 * are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at * 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.IGPPASTExplicitTemplateInstantiation;
import org.eclipse.cdt.core.dom.ast.gnu.cpp.IGPPASTPointer; 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.IGPPASTPointerToMember;
import org.eclipse.cdt.core.dom.ast.gnu.cpp.IGPPASTSimpleDeclSpecifier;
import org.eclipse.cdt.core.parser.IScanner; import org.eclipse.cdt.core.parser.IScanner;
/** /**
@ -127,8 +126,6 @@ public interface ICPPNodeFactory extends INodeFactory {
public ICPPASTDeleteExpression newDeleteExpression(IASTExpression operand); public ICPPASTDeleteExpression newDeleteExpression(IASTExpression operand);
public IGPPASTSimpleDeclSpecifier newSimpleDeclSpecifierGPP();
public ICPPASTSimpleTypeConstructorExpression newSimpleTypeConstructorExpression(int type, IASTExpression expression); public ICPPASTSimpleTypeConstructorExpression newSimpleTypeConstructorExpression(int type, IASTExpression expression);
public ICPPASTTypenameExpression newTypenameExpression(IASTName qualifiedName, IASTExpression expr, boolean isTemplate); public ICPPASTTypenameExpression newTypenameExpression(IASTName qualifiedName, IASTExpression expr, boolean isTemplate);
@ -225,4 +222,9 @@ public interface ICPPNodeFactory extends INodeFactory {
*/ */
@Deprecated @Deprecated
public ICPPASTTranslationUnit newTranslationUnit(); 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 * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0 * are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at * 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; import org.eclipse.cdt.core.dom.ast.IASTUnaryExpression;
/** /**
* There are GNU language extensions that apply to both GCC and G++. Unary * @deprecated Replaced by {@link IASTUnaryExpression}.
* 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
public interface IGNUASTUnaryExpression extends IASTUnaryExpression { 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 * @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 * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0 * are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at * 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.ASTNodeProperty;
import org.eclipse.cdt.core.dom.ast.IASTExpression; 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; import org.eclipse.cdt.core.dom.ast.c.ICASTSimpleDeclSpecifier;
/** /**
* @noextend This interface is not intended to be extended by clients. * @noextend This interface is not intended to be extended by clients.
* @noimplement This interface is not intended to be implemented 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 { 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; 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; public static final int t_last = t_typeof;
/** /**
* <code>TYPEOF_EXPRESSION</code> represents the relationship between the * @deprecated Replaced by {@link IASTSimpleDeclSpecifier#DECLTYPE_EXPRESSION}.
* decl spec & the expression for typeof().
*/ */
@Deprecated
public static final ASTNodeProperty TYPEOF_EXPRESSION = new ASTNodeProperty( public static final ASTNodeProperty TYPEOF_EXPRESSION = new ASTNodeProperty(
"IGCCASTSimpleDeclSpecifier.TYPEOF_EXPRESSION - typeof() Expression"); //$NON-NLS-1$ "IGCCASTSimpleDeclSpecifier.TYPEOF_EXPRESSION - typeof() Expression"); //$NON-NLS-1$
/** /**
* Set the typeof() expression. * @deprecated Replaced by {@link IASTSimpleDeclSpecifier#setDeclTypeExpression(IASTExpression)}.
*
* @param typeofExpression
* <code>IASTExpression</code>
*/ */
@Deprecated
public void setTypeofExpression(IASTExpression typeofExpression); public void setTypeofExpression(IASTExpression typeofExpression);
/** /**
* Get the typeof expression. * @deprecated Replaced by {@link IASTSimpleDeclSpecifier#getDeclTypeExpression()}.
*
* @return <code>IASTExpression</code>
*/ */
@Deprecated
public IASTExpression getTypeofExpression(); 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 * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0 * are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at * 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. * @noextend This interface is not intended to be extended by clients.
* @noimplement This interface is not intended to be implemented by clients. * @noimplement This interface is not intended to be implemented by clients.
* @deprecated Replaced by {@link IASTDeclSpecifier}.
*/ */
@Deprecated
public interface IGPPASTDeclSpecifier extends IASTDeclSpecifier { 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 * @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 * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0 * are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at * 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.ASTNodeProperty;
import org.eclipse.cdt.core.dom.ast.IASTExpression; 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; 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. * @noextend This interface is not intended to be extended by clients.
* @noimplement This interface is not intended to be implemented 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 { public interface IGPPASTSimpleDeclSpecifier extends IGPPASTDeclSpecifier, ICPPASTSimpleDeclSpecifier {
/** /**
* <code>t_typeof</code> represents a typeof() expression type. * @deprecated Replaced by {@link ICPPASTSimpleDeclSpecifier#setDeclTypeExpression(IASTExpression)}.
*/
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
public void setTypeofExpression(IASTExpression typeofExpression); public void setTypeofExpression(IASTExpression typeofExpression);
/** /**
* Get the typeof expression. * @deprecated Replaced by {@link ICPPASTSimpleDeclSpecifier#getDeclTypeExpression()}.
*
* @return <code>IASTExpression</code>
*/ */
@Deprecated
public IASTExpression getTypeofExpression(); public IASTExpression getTypeofExpression();
/** /**
@ -98,4 +41,17 @@ public interface IGPPASTSimpleDeclSpecifier extends IGPPASTDeclSpecifier, ICPPAS
*/ */
public IGPPASTSimpleDeclSpecifier copy(); 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 * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0 * are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at * which accompanies this distribution, and is available at
@ -11,7 +11,6 @@
*******************************************************************************/ *******************************************************************************/
package org.eclipse.cdt.core.parser; package org.eclipse.cdt.core.parser;
/** /**
* @noextend This interface is not intended to be extended by clients. * @noextend This interface is not intended to be extended by clients.
* @noimplement This interface is not intended to be implemented by clients. * @noimplement This interface is not intended to be implemented by clients.
@ -93,7 +92,7 @@ public interface IToken {
* @see IScanner#setSplitShiftROperator(boolean) * @see IScanner#setSplitShiftROperator(boolean)
* @since 5.2 * @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 #tAND} */ @Deprecated int t_and = 54;
/** @deprecated use {@link #tAMPERASSIGN} */ @Deprecated int t_and_eq = 55; /** @deprecated use {@link #tAMPERASSIGN} */ @Deprecated int t_and_eq = 55;
@ -113,6 +112,7 @@ public interface IToken {
int t_const_cast = 69; int t_const_cast = 69;
int t_continue = 70; int t_continue = 70;
/** @since 5.2 */ int t_decltype= 5201;
int t_default = 71; int t_default = 71;
int t_delete = 72; int t_delete = 72;
int t_do = 73; int t_do = 73;
@ -149,7 +149,7 @@ public interface IToken {
int t_short = 104; int t_short = 104;
int t_sizeof = 105; int t_sizeof = 105;
int t_static = 106; 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_static_cast = 107;
int t_signed = 108; int t_signed = 108;
int t_struct = 109; 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 * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0 * are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at * 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 = "const"; //$NON-NLS-1$
public static final String CONST_CAST = "const_cast"; //$NON-NLS-1$ public static final String CONST_CAST = "const_cast"; //$NON-NLS-1$
public static final String CONTINUE = "continue"; //$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 DEFAULT = "default"; //$NON-NLS-1$
public static final String DELETE = "delete"; //$NON-NLS-1$ public static final String DELETE = "delete"; //$NON-NLS-1$
public static final String DO = "do"; //$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[] cCONST_CAST = "const_cast".toCharArray(); //$NON-NLS-1$
public static final char[] cCONTINUE = "continue".toCharArray(); //$NON-NLS-1$ public static final char[] cCONTINUE = "continue".toCharArray(); //$NON-NLS-1$
public static final char[] cDEFAULT = "default".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[] cDELETE = "delete".toCharArray(); //$NON-NLS-1$
public static final char[] cDO = "do".toCharArray(); //$NON-NLS-1$ public static final char[] cDO = "do".toCharArray(); //$NON-NLS-1$
public static final char[] cDOUBLE = "double".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[] cSIZEOF = "sizeof".toCharArray(); //$NON-NLS-1$
public static final char[] cSTATIC = "static".toCharArray(); //$NON-NLS-1$ public static final char[] cSTATIC = "static".toCharArray(); //$NON-NLS-1$
/** @since 5.2 */ /** @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[] cSTATIC_CAST = "static_cast".toCharArray(); //$NON-NLS-1$
public static final char[] cSTRUCT = "struct".toCharArray(); //$NON-NLS-1$ public static final char[] cSTRUCT = "struct".toCharArray(); //$NON-NLS-1$
public static final char[] cSWITCH = "switch".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.cCATCH, IToken.t_catch);
cppkeywords.put(Keywords.cCLASS, IToken.t_class); cppkeywords.put(Keywords.cCLASS, IToken.t_class);
cppkeywords.put(Keywords.cCONST_CAST, IToken.t_const_cast); 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.cDELETE, IToken.t_delete);
cppkeywords.put(Keywords.cDYNAMIC_CAST, IToken.t_dynamic_cast); cppkeywords.put(Keywords.cDYNAMIC_CAST, IToken.t_dynamic_cast);
cppkeywords.put(Keywords.cEXPLICIT, IToken.t_explicit); 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 * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0 * are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at * which accompanies this distribution, and is available at
@ -2104,7 +2104,7 @@ public abstract class AbstractGNUSourceCodeParser implements ISourceCodeParser {
} }
protected IASTStatement parseDefaultStatement() throws EndOfFileException, BacktrackException { 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(); int lastOffset = consume(IToken.tCOLON).getEndOffset();
IASTDefaultStatement df = nodeFactory.newDefaultStatement(); IASTDefaultStatement df = nodeFactory.newDefaultStatement();
@ -2243,7 +2243,7 @@ public abstract class AbstractGNUSourceCodeParser implements ISourceCodeParser {
return result1; return result1;
} }
IASTExpression result2= buildUnaryExpression(unaryExprKind, expr, offset, endOffset2); IASTExpression result2= unaryExprKind == -1 ? expr : buildUnaryExpression(unaryExprKind, expr, offset, endOffset2);
if (ca != null) if (ca != null)
result2= ca.updateExpression(result2); result2= ca.updateExpression(result2);
@ -2444,6 +2444,7 @@ public abstract class AbstractGNUSourceCodeParser implements ISourceCodeParser {
case IToken.t__Imaginary: case IToken.t__Imaginary:
case IToken.t_signed: case IToken.t_signed:
case IToken.t_unsigned: case IToken.t_unsigned:
case IToken.t_decltype:
// class-specifier: // class-specifier:
case IToken.t_class: 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 * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0 * are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at * 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.IType;
import org.eclipse.cdt.core.dom.ast.IVariable; 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.IGNUASTCompoundStatementExpression;
import org.eclipse.cdt.core.dom.ast.gnu.IGNUASTUnaryExpression;
import org.eclipse.cdt.internal.core.pdom.dom.PDOMName; import org.eclipse.cdt.internal.core.pdom.dom.PDOMName;
/** /**
@ -260,8 +259,7 @@ public abstract class VariableReadWriteFlags {
case IASTUnaryExpression.op_sizeof: case IASTUnaryExpression.op_sizeof:
case IASTUnaryExpression.op_sizeofParameterPack: case IASTUnaryExpression.op_sizeofParameterPack:
case IGNUASTUnaryExpression.op_alignOf: case IASTUnaryExpression.op_alignOf:
case IGNUASTUnaryExpression.op_typeof:
return 0; return 0;
} }
return READ; 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 * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0 * are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at * which accompanies this distribution, and is available at
@ -13,10 +13,14 @@
package org.eclipse.cdt.internal.core.dom.parser.c; package org.eclipse.cdt.internal.core.dom.parser.c;
import org.eclipse.cdt.core.dom.ast.ASTVisitor; 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.IBasicType.Kind;
import org.eclipse.cdt.core.dom.ast.c.ICASTSimpleDeclSpecifier; 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 int simpleType;
private boolean isSigned; private boolean isSigned;
@ -26,6 +30,7 @@ public class CASTSimpleDeclSpecifier extends CASTBaseDeclSpecifier implements IC
private boolean longlong; private boolean longlong;
private boolean complex=false; private boolean complex=false;
private boolean imaginary=false; private boolean imaginary=false;
private IASTExpression fDeclTypeExpression;
public CASTSimpleDeclSpecifier copy() { public CASTSimpleDeclSpecifier copy() {
CASTSimpleDeclSpecifier copy = new CASTSimpleDeclSpecifier(); CASTSimpleDeclSpecifier copy = new CASTSimpleDeclSpecifier();
@ -43,9 +48,10 @@ public class CASTSimpleDeclSpecifier extends CASTBaseDeclSpecifier implements IC
copy.longlong = longlong; copy.longlong = longlong;
copy.complex = complex; copy.complex = complex;
copy.imaginary = imaginary; copy.imaginary = imaginary;
if (fDeclTypeExpression != null)
copy.setDeclTypeExpression(fDeclTypeExpression.copy());
} }
public int getType() { public int getType() {
return simpleType; return simpleType;
} }
@ -78,7 +84,7 @@ public class CASTSimpleDeclSpecifier extends CASTBaseDeclSpecifier implements IC
private int getType(Kind kind) { private int getType(Kind kind) {
switch(kind) { switch(kind) {
case eBoolean: case eBoolean:
return t_Bool; return t_bool;
case eChar: case eChar:
case eWChar: case eWChar:
return t_char; return t_char;
@ -134,6 +140,10 @@ public class CASTSimpleDeclSpecifier extends CASTBaseDeclSpecifier implements IC
default : break; default : break;
} }
} }
if (fDeclTypeExpression != null && !fDeclTypeExpression.accept(action))
return false;
if( action.shouldVisitDeclSpecifiers ){ if( action.shouldVisitDeclSpecifiers ){
switch( action.leave( this ) ){ switch( action.leave( this ) ){
case ASTVisitor.PROCESS_ABORT : return false; case ASTVisitor.PROCESS_ABORT : return false;
@ -161,4 +171,25 @@ public class CASTSimpleDeclSpecifier extends CASTBaseDeclSpecifier implements IC
assertNotFrozen(); assertNotFrozen();
this.imaginary = value; 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 * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0 * are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at * 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.IGNUASTCompoundStatementExpression;
import org.eclipse.cdt.core.dom.ast.gnu.c.ICASTKnRFunctionDeclarator; 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.IGCCASTArrayRangeDesignator;
import org.eclipse.cdt.core.dom.ast.gnu.c.IGCCASTSimpleDeclSpecifier;
import org.eclipse.cdt.core.parser.IScanner; import org.eclipse.cdt.core.parser.IScanner;
import org.eclipse.cdt.internal.core.dom.parser.NodeFactory; 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); 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); 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 * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0 * are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at * 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.IASTNamedTypeSpecifier;
import org.eclipse.cdt.core.dom.ast.IASTNode; import org.eclipse.cdt.core.dom.ast.IASTNode;
import org.eclipse.cdt.core.dom.ast.IASTParameterDeclaration; 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.IASTSimpleDeclaration;
import org.eclipse.cdt.core.dom.ast.IASTStandardFunctionDeclarator; import org.eclipse.cdt.core.dom.ast.IASTStandardFunctionDeclarator;
import org.eclipse.cdt.core.dom.ast.IASTStatement; import org.eclipse.cdt.core.dom.ast.IASTStatement;
import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit; import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit;
import org.eclipse.cdt.core.dom.ast.IASTTypeIdExpression; 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.IBinding;
import org.eclipse.cdt.core.dom.ast.ICompositeType; import org.eclipse.cdt.core.dom.ast.ICompositeType;
import org.eclipse.cdt.core.dom.ast.IEnumeration; 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.ICASTElaboratedTypeSpecifier;
import org.eclipse.cdt.core.dom.ast.c.ICASTEnumerationSpecifier; 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.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.dom.ast.gnu.c.ICASTKnRFunctionDeclarator;
import org.eclipse.cdt.core.index.IIndex; import org.eclipse.cdt.core.index.IIndex;
import org.eclipse.cdt.core.index.IIndexFileSet; import org.eclipse.cdt.core.index.IIndexFileSet;
@ -306,8 +305,8 @@ public class CScope implements ICScope, IASTInternalScope {
} }
IASTNode parent= name.getParent(); IASTNode parent= name.getParent();
while (parent != null) { while (parent != null) {
if (parent instanceof IASTUnaryExpression) { if (parent instanceof IASTSimpleDeclSpecifier) {
if (((IASTUnaryExpression) parent).getOperator() == IGNUASTUnaryExpression.op_typeof) if (((IASTSimpleDeclSpecifier) parent).getDeclTypeExpression() != null)
return false; return false;
} }
else if (parent instanceof IASTTypeIdExpression) { 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 * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0 * are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at * 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.ICCompositeTypeScope;
import org.eclipse.cdt.core.dom.ast.c.ICFunctionScope; 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.ICASTKnRFunctionDeclarator;
import org.eclipse.cdt.core.dom.ast.gnu.c.IGCCASTSimpleDeclSpecifier;
import org.eclipse.cdt.core.index.IIndexBinding; import org.eclipse.cdt.core.index.IIndexBinding;
import org.eclipse.cdt.core.index.IIndexFileSet; import org.eclipse.cdt.core.index.IIndexFileSet;
import org.eclipse.cdt.core.parser.util.ArrayUtil; import org.eclipse.cdt.core.parser.util.ArrayUtil;
@ -1332,13 +1331,12 @@ public class CVisitor extends ASTQueries {
* @return the base IType * @return the base IType
*/ */
public static IType createBaseType(IASTDeclSpecifier declSpec) { public static IType createBaseType(IASTDeclSpecifier declSpec) {
if (declSpec instanceof IGCCASTSimpleDeclSpecifier) { if (declSpec instanceof ICASTSimpleDeclSpecifier) {
IASTExpression exp = ((IGCCASTSimpleDeclSpecifier)declSpec).getTypeofExpression(); final ICASTSimpleDeclSpecifier sds = (ICASTSimpleDeclSpecifier)declSpec;
IASTExpression exp = sds.getDeclTypeExpression();
if (exp != null) if (exp != null)
return exp.getExpressionType(); return exp.getExpressionType();
return new CBasicType((ICASTSimpleDeclSpecifier) declSpec); return new CBasicType(sds);
} else if (declSpec instanceof ICASTSimpleDeclSpecifier) {
return new CBasicType((ICASTSimpleDeclSpecifier)declSpec);
} }
IBinding binding = null; IBinding binding = null;
IASTName name = null; IASTName name = null;

View file

@ -1,29 +1,24 @@
/******************************************************************************* /*******************************************************************************
* 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 * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0 * are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at * which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html * http://www.eclipse.org/legal/epl-v10.html
* *
* Contributors: * Contributors:
* IBM Corporation - initial API and implementation * Andrew Niefer (IBM Corporation) - initial API and implementation
* Emanuel Graf IFS - Bugfix for #198257 * Emanuel Graf IFS - Bugfix for #198257
*******************************************************************************/ *******************************************************************************/
package org.eclipse.cdt.internal.core.dom.parser.c; 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.IASTExpression;
import org.eclipse.cdt.core.dom.ast.IASTNode;
import org.eclipse.cdt.core.dom.ast.gnu.c.IGCCASTSimpleDeclSpecifier; 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 { @Deprecated
public class GCCASTSimpleDeclSpecifier extends CASTSimpleDeclSpecifier implements IGCCASTSimpleDeclSpecifier {
private IASTExpression typeOfExpression;
public GCCASTSimpleDeclSpecifier() { public GCCASTSimpleDeclSpecifier() {
} }
@ -36,50 +31,14 @@ public class GCCASTSimpleDeclSpecifier extends CASTSimpleDeclSpecifier implement
public GCCASTSimpleDeclSpecifier copy() { public GCCASTSimpleDeclSpecifier copy() {
GCCASTSimpleDeclSpecifier copy = new GCCASTSimpleDeclSpecifier(); GCCASTSimpleDeclSpecifier copy = new GCCASTSimpleDeclSpecifier();
copySimpleDeclSpec(copy); copySimpleDeclSpec(copy);
copy.setTypeofExpression(typeOfExpression == null ? null : typeOfExpression.copy());
return copy; return copy;
} }
public void setTypeofExpression(IASTExpression typeofExpression) { public void setTypeofExpression(IASTExpression expr) {
this.typeOfExpression = typeofExpression; setDeclTypeExpression(expr);
if (typeofExpression != null) {
typeofExpression.setParent(this);
typeofExpression.setPropertyInParent(TYPEOF_EXPRESSION);
}
} }
public IASTExpression getTypeofExpression() { 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 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) 2005, 2009 IBM Corporation and others. * Copyright (c) 2005, 2010 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0 * are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at * 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.ICASTTypedefNameSpecifier;
import org.eclipse.cdt.core.dom.ast.c.ICNodeFactory; 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.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.ICASTKnRFunctionDeclarator;
import org.eclipse.cdt.core.dom.ast.gnu.c.IGCCASTArrayRangeDesignator; import org.eclipse.cdt.core.dom.ast.gnu.c.IGCCASTArrayRangeDesignator;
import org.eclipse.cdt.core.dom.parser.IExtensionToken; import org.eclipse.cdt.core.dom.parser.IExtensionToken;
@ -589,9 +588,6 @@ public class GNUCSourceParser extends AbstractGNUSourceCodeParser {
case IToken.t_sizeof: case IToken.t_sizeof:
return parseTypeidInParenthesisOrUnaryExpression(false, consume().getOffset(), return parseTypeidInParenthesisOrUnaryExpression(false, consume().getOffset(),
IASTTypeIdExpression.op_sizeof, IASTUnaryExpression.op_sizeof, ctx); 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__: case IGCCToken.t___alignof__:
return parseTypeidInParenthesisOrUnaryExpression(false, consume().getOffset(), return parseTypeidInParenthesisOrUnaryExpression(false, consume().getOffset(),
IASTTypeIdExpression.op_alignof, IASTUnaryExpression.op_alignOf, ctx); IASTTypeIdExpression.op_alignof, IASTUnaryExpression.op_alignOf, ctx);
@ -1004,7 +1000,7 @@ public class GNUCSourceParser extends AbstractGNUSourceCodeParser {
case IToken.t__Bool: case IToken.t__Bool:
if (encounteredTypename) if (encounteredTypename)
break declSpecifiers; break declSpecifiers;
simpleType = ICASTSimpleDeclSpecifier.t_Bool; simpleType = IASTSimpleDeclSpecifier.t_bool;
encounteredRawType= true; encounteredRawType= true;
endOffset= consume().getEndOffset(); endOffset= consume().getEndOffset();
break; break;
@ -1081,8 +1077,10 @@ public class GNUCSourceParser extends AbstractGNUSourceCodeParser {
if (encounteredRawType || encounteredTypename) if (encounteredRawType || encounteredTypename)
throwBacktrack(LA(1)); throwBacktrack(LA(1));
typeofExpression = parseTypeidInParenthesisOrUnaryExpression(false, consume().getOffset(), simpleType= IASTSimpleDeclSpecifier.t_typeof;
IGNUASTTypeIdExpression.op_typeof, IGNUASTUnaryExpression.op_typeof, CastExprCtx.eNotBExpr); consume(IGCCToken.t_typeof);
typeofExpression = parseTypeidInParenthesisOrUnaryExpression(false, LA(1).getOffset(),
IGNUASTTypeIdExpression.op_typeof, -1, CastExprCtx.eNotBExpr);
encounteredTypename= true; encounteredTypename= true;
endOffset= calculateEndOffset(typeofExpression); endOffset= calculateEndOffset(typeofExpression);
@ -1155,11 +1153,7 @@ public class GNUCSourceParser extends AbstractGNUSourceCodeParser {
private ICASTSimpleDeclSpecifier buildSimpleDeclSpec(int storageClass, int simpleType, private ICASTSimpleDeclSpecifier buildSimpleDeclSpec(int storageClass, int simpleType,
int options, int isLong, IASTExpression typeofExpression, int offset, int endOffset) { int options, int isLong, IASTExpression typeofExpression, int offset, int endOffset) {
ICASTSimpleDeclSpecifier declSpec; ICASTSimpleDeclSpecifier declSpec= nodeFactory.newSimpleDeclSpecifier();
if (typeofExpression != null)
declSpec = nodeFactory.newSimpleDeclSpecifierGCC(typeofExpression);
else
declSpec = nodeFactory.newSimpleDeclSpecifier();
configureDeclSpec(declSpec, storageClass, options); configureDeclSpec(declSpec, storageClass, options);
declSpec.setType(simpleType); declSpec.setType(simpleType);
@ -1171,6 +1165,10 @@ public class GNUCSourceParser extends AbstractGNUSourceCodeParser {
declSpec.setShort((options & SHORT) != 0); declSpec.setShort((options & SHORT) != 0);
declSpec.setComplex((options & COMPLEX) != 0); declSpec.setComplex((options & COMPLEX) != 0);
declSpec.setImaginary((options & IMAGINARY) != 0); declSpec.setImaginary((options & IMAGINARY) != 0);
if (typeofExpression != null) {
declSpec.setDeclTypeExpression(typeofExpression);
typeofExpression.setParent(declSpec);
}
((ASTNode) declSpec).setOffsetAndLength(offset, endOffset - offset); ((ASTNode) declSpec).setOffsetAndLength(offset, endOffset - offset);
return declSpec; 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 * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0 * are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at * which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html * http://www.eclipse.org/legal/epl-v10.html
* *
* Contributors: * 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; 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; 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 { public abstract class CPPASTBaseDeclSpecifier extends ASTNode implements ICPPASTDeclSpecifier {
private boolean friend; private boolean friend;
private boolean inline; private boolean inline;
private boolean volatil;
private boolean isConst; private boolean isConst;
private boolean isVolatile;
private boolean isRestrict;
private int sc; private int sc;
private boolean virtual; private boolean virtual;
private boolean explicit; private boolean explicit;
@ -50,12 +52,21 @@ public abstract class CPPASTBaseDeclSpecifier extends ASTNode implements ICPPAST
} }
public boolean isVolatile() { public boolean isVolatile() {
return volatil; return isVolatile;
} }
public void setVolatile(boolean value) { public void setVolatile(boolean value) {
assertNotFrozen(); assertNotFrozen();
volatil = value; isVolatile = value;
}
public boolean isRestrict() {
return isRestrict;
}
public void setRestrict(boolean value) {
assertNotFrozen();
isRestrict = value;
} }
public boolean isInline() { public boolean isInline() {
@ -93,8 +104,9 @@ public abstract class CPPASTBaseDeclSpecifier extends ASTNode implements ICPPAST
protected void copyBaseDeclSpec(CPPASTBaseDeclSpecifier other) { protected void copyBaseDeclSpec(CPPASTBaseDeclSpecifier other) {
other.friend = friend; other.friend = friend;
other.inline = inline; other.inline = inline;
other.volatil = volatil;
other.isConst = isConst; other.isConst = isConst;
other.isVolatile = isVolatile;
other.isRestrict= isRestrict;
other.virtual = virtual; other.virtual = virtual;
other.explicit = explicit; other.explicit = explicit;
other.sc = sc; 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 * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0 * are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at * which accompanies this distribution, and is available at
@ -13,7 +13,7 @@
*******************************************************************************/ *******************************************************************************/
package org.eclipse.cdt.internal.core.dom.parser.cpp; 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.ArrayList;
import java.util.List; 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.IBinding;
import org.eclipse.cdt.core.dom.ast.IEnumerator; import org.eclipse.cdt.core.dom.ast.IEnumerator;
import org.eclipse.cdt.core.dom.ast.IFunction; 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.IProblemBinding;
import org.eclipse.cdt.core.dom.ast.IType; import org.eclipse.cdt.core.dom.ast.IType;
import org.eclipse.cdt.core.dom.ast.IVariable; 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.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.ICPPFunction;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPMember; import org.eclipse.cdt.core.dom.ast.cpp.ICPPMember;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPMethod; 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.ASTNode;
import org.eclipse.cdt.internal.core.dom.parser.IASTAmbiguityParent; 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.CPPSemantics;
import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CVQualifier;
import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.SemanticUtil; import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.SemanticUtil;
public class CPPASTFieldReference extends ASTNode implements ICPPASTFieldReference, IASTAmbiguityParent, public class CPPASTFieldReference extends ASTNode implements ICPPASTFieldReference, IASTAmbiguityParent,
@ -190,7 +193,28 @@ public class CPPASTFieldReference extends ASTNode implements ICPPASTFieldReferen
IBinding binding = name.resolvePreBinding(); IBinding binding = name.resolvePreBinding();
try { try {
if (binding instanceof IVariable) { 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) { } else if (binding instanceof IEnumerator) {
return ((IEnumerator) binding).getType(); return ((IEnumerator) binding).getType();
} else if (binding instanceof IFunction) { } 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 * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0 * are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at * which accompanies this distribution, and is available at
@ -12,16 +12,23 @@
package org.eclipse.cdt.internal.core.dom.parser.cpp; package org.eclipse.cdt.internal.core.dom.parser.cpp;
import org.eclipse.cdt.core.dom.ast.ASTVisitor; 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.IBasicType.Kind;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTSimpleDeclSpecifier; 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 int type;
private boolean isSigned; private boolean isSigned;
private boolean isUnsigned; private boolean isUnsigned;
private boolean isShort; private boolean isShort;
private boolean isLong; private boolean isLong;
private boolean isLonglong;
private boolean isComplex=false;
private boolean isImaginary=false;
private IASTExpression fDeclTypeExpression;
public CPPASTSimpleDeclSpecifier copy() { public CPPASTSimpleDeclSpecifier copy() {
CPPASTSimpleDeclSpecifier copy = new CPPASTSimpleDeclSpecifier(); CPPASTSimpleDeclSpecifier copy = new CPPASTSimpleDeclSpecifier();
@ -36,6 +43,12 @@ public class CPPASTSimpleDeclSpecifier extends CPPASTBaseDeclSpecifier implement
other.isUnsigned = isUnsigned; other.isUnsigned = isUnsigned;
other.isShort = isShort; other.isShort = isShort;
other.isLong = isLong; 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; 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(); assertNotFrozen();
isSigned = value; isSigned = value;
} }
@ -112,7 +141,31 @@ public class CPPASTSimpleDeclSpecifier extends CPPASTBaseDeclSpecifier implement
isShort = value; 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) { public boolean accept(ASTVisitor action) {
if (action.shouldVisitDeclSpecifiers) { if (action.shouldVisitDeclSpecifiers) {
switch (action.visit(this)) { switch (action.visit(this)) {
@ -121,6 +174,10 @@ public class CPPASTSimpleDeclSpecifier extends CPPASTBaseDeclSpecifier implement
default: break; default: break;
} }
} }
if (fDeclTypeExpression != null && !fDeclTypeExpression.accept(action))
return false;
if (action.shouldVisitDeclSpecifiers) { if (action.shouldVisitDeclSpecifiers) {
switch (action.leave(this)) { switch (action.leave(this)) {
case ASTVisitor.PROCESS_ABORT: return false; case ASTVisitor.PROCESS_ABORT: return false;
@ -130,4 +187,12 @@ public class CPPASTSimpleDeclSpecifier extends CPPASTBaseDeclSpecifier implement
} }
return true; 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 * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0 * are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at * 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.ITypedef;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTSimpleDeclSpecifier; 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.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.ISerializableType;
import org.eclipse.cdt.internal.core.dom.parser.ITypeMarshalBuffer; import org.eclipse.cdt.internal.core.dom.parser.ITypeMarshalBuffer;
import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.CoreException;
@ -58,19 +57,14 @@ public class CPPBasicType implements ICPPBasicType, ISerializableType {
} }
private static int getModifiers(ICPPASTSimpleDeclSpecifier sds) { private static int getModifiers(ICPPASTSimpleDeclSpecifier sds) {
int qualifiers= return
( sds.isLong() ? IBasicType.IS_LONG : 0 ) | ( sds.isLong() ? IBasicType.IS_LONG : 0 ) |
( sds.isShort() ? IBasicType.IS_SHORT : 0 ) | ( sds.isShort() ? IBasicType.IS_SHORT : 0 ) |
( sds.isSigned() ? IBasicType.IS_SIGNED: 0 ) | ( sds.isSigned() ? IBasicType.IS_SIGNED: 0 ) |
( sds.isUnsigned()? IBasicType.IS_UNSIGNED : 0 ); ( sds.isUnsigned()? IBasicType.IS_UNSIGNED : 0 ) |
if (sds instanceof IGPPASTSimpleDeclSpecifier) { ( sds.isLongLong()? IBasicType.IS_LONG_LONG : 0 ) |
IGPPASTSimpleDeclSpecifier gsds= (IGPPASTSimpleDeclSpecifier) sds; ( sds.isComplex() ? IBasicType.IS_COMPLEX : 0 ) |
qualifiers |= ( sds.isImaginary()?IBasicType.IS_IMAGINARY : 0 );
( gsds.isLongLong()? IBasicType.IS_LONG_LONG : 0 ) |
( gsds.isComplex() ? IBasicType.IS_COMPLEX : 0 ) |
( gsds.isImaginary()?IBasicType.IS_IMAGINARY : 0 );
}
return qualifiers;
} }
private static Kind getKind(ICPPASTSimpleDeclSpecifier sds) { private static Kind getKind(ICPPASTSimpleDeclSpecifier sds) {
@ -79,11 +73,11 @@ public class CPPBasicType implements ICPPBasicType, ISerializableType {
static Kind getKind(final int simpleDeclSpecType) { static Kind getKind(final int simpleDeclSpecType) {
switch(simpleDeclSpecType) { switch(simpleDeclSpecType) {
case ICPPASTSimpleDeclSpecifier.t_bool: case IASTSimpleDeclSpecifier.t_bool:
return Kind.eBoolean; return Kind.eBoolean;
case IASTSimpleDeclSpecifier.t_char: case IASTSimpleDeclSpecifier.t_char:
return Kind.eChar; return Kind.eChar;
case ICPPASTSimpleDeclSpecifier.t_wchar_t: case IASTSimpleDeclSpecifier.t_wchar_t:
return Kind.eWChar; return Kind.eWChar;
case IASTSimpleDeclSpecifier.t_double: case IASTSimpleDeclSpecifier.t_double:
return Kind.eDouble; 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 * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0 * are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at * 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.IGPPASTExplicitTemplateInstantiation;
import org.eclipse.cdt.core.dom.ast.gnu.cpp.IGPPASTPointer; 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.IGPPASTPointerToMember;
import org.eclipse.cdt.core.dom.ast.gnu.cpp.IGPPASTSimpleDeclSpecifier;
import org.eclipse.cdt.core.parser.IScanner; import org.eclipse.cdt.core.parser.IScanner;
import org.eclipse.cdt.internal.core.dom.parser.NodeFactory; import org.eclipse.cdt.internal.core.dom.parser.NodeFactory;
@ -356,10 +355,6 @@ public class CPPNodeFactory extends NodeFactory implements ICPPNodeFactory {
return new CPPASTSimpleDeclSpecifier(); return new CPPASTSimpleDeclSpecifier();
} }
public IGPPASTSimpleDeclSpecifier newSimpleDeclSpecifierGPP() {
return new GPPASTSimpleDeclSpecifier();
}
public ICPPASTFunctionDeclarator newFunctionDeclarator(IASTName name) { public ICPPASTFunctionDeclarator newFunctionDeclarator(IASTName name) {
return new CPPASTFunctionDeclarator(name); return new CPPASTFunctionDeclarator(name);
} }
@ -529,4 +524,9 @@ public class CPPNodeFactory extends NodeFactory implements ICPPNodeFactory {
public ICPPASTPackExpansionExpression newPackExpansionExpression(IASTExpression pattern) { public ICPPASTPackExpansionExpression newPackExpansionExpression(IASTExpression pattern) {
return new CPPASTPackExpansionExpression(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.ICPPNodeFactory;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTCompositeTypeSpecifier.ICPPASTBaseSpecifier; 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.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.IGPPASTExplicitTemplateInstantiation;
import org.eclipse.cdt.core.dom.ast.gnu.cpp.IGPPASTPointer; 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.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.IExtensionToken;
import org.eclipse.cdt.core.dom.parser.cpp.ICPPParserExtensionConfiguration; import org.eclipse.cdt.core.dom.parser.cpp.ICPPParserExtensionConfiguration;
import org.eclipse.cdt.core.index.IIndex; import org.eclipse.cdt.core.index.IIndex;
@ -152,7 +150,6 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser {
private final boolean allowCPPRestrict; private final boolean allowCPPRestrict;
private final boolean supportExtendedTemplateSyntax; private final boolean supportExtendedTemplateSyntax;
private final boolean supportLongLong;
private final IIndex index; private final IIndex index;
protected ICPPASTTranslationUnit translationUnit; protected ICPPASTTranslationUnit translationUnit;
@ -181,7 +178,6 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser {
config.getBuiltinBindingsProvider()); config.getBuiltinBindingsProvider());
allowCPPRestrict = config.allowRestrictPointerOperators(); allowCPPRestrict = config.allowRestrictPointerOperators();
supportExtendedTemplateSyntax = config.supportExtendedTemplateSyntax(); supportExtendedTemplateSyntax = config.supportExtendedTemplateSyntax();
supportLongLong = config.supportLongLongs();
supportParameterInfoBlock= config.supportParameterInfoBlock(); supportParameterInfoBlock= config.supportParameterInfoBlock();
supportExtendedSizeofOperator= config.supportExtendedSizeofOperator(); supportExtendedSizeofOperator= config.supportExtendedSizeofOperator();
supportFunctionStyleAsm= config.supportFunctionStyleAssembler(); supportFunctionStyleAsm= config.supportFunctionStyleAssembler();
@ -414,7 +410,6 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser {
case IToken.t_new: case IToken.t_new:
case IToken.t_delete: case IToken.t_delete:
case IToken.t_sizeof: case IToken.t_sizeof:
case IGCCToken.t_typeof:
case IGCCToken.t___alignof__: case IGCCToken.t___alignof__:
// postfix expression // postfix expression
case IToken.t_typename: case IToken.t_typename:
@ -1087,9 +1082,6 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser {
} }
return parseTypeidInParenthesisOrUnaryExpression(false, consume().getOffset(), return parseTypeidInParenthesisOrUnaryExpression(false, consume().getOffset(),
IASTTypeIdExpression.op_sizeof, IASTUnaryExpression.op_sizeof, ctx); 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__: case IGCCToken.t___alignof__:
return parseTypeidInParenthesisOrUnaryExpression(false, consume().getOffset(), return parseTypeidInParenthesisOrUnaryExpression(false, consume().getOffset(),
IASTTypeIdExpression.op_alignof, IASTUnaryExpression.op_alignOf, ctx); IASTTypeIdExpression.op_alignof, IASTUnaryExpression.op_alignOf, ctx);
@ -2442,13 +2434,28 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser {
if (encounteredRawType || encounteredTypename) if (encounteredRawType || encounteredTypename)
throwBacktrack(LA(1)); throwBacktrack(LA(1));
typeofExpression= parseTypeidInParenthesisOrUnaryExpression(false, consume().getOffset(), simpleType= IASTSimpleDeclSpecifier.t_typeof;
IGNUASTTypeIdExpression.op_typeof, IGNUASTUnaryExpression.op_typeof, CastExprCtx.eNotBExpr); consume(IGCCToken.t_typeof);
typeofExpression= parseTypeidInParenthesisOrUnaryExpression(false, LA(1).getOffset(),
IGNUASTTypeIdExpression.op_typeof, -1, CastExprCtx.eNotBExpr);
encounteredTypename= true; encounteredTypename= true;
endOffset= calculateEndOffset(typeofExpression); endOffset= calculateEndOffset(typeofExpression);
break; 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: default:
if (lt1 >= IExtensionToken.t__otherDeclSpecModifierFirst && lt1 <= IExtensionToken.t__otherDeclSpecModifierLast) { if (lt1 >= IExtensionToken.t__otherDeclSpecModifierFirst && lt1 <= IExtensionToken.t__otherDeclSpecModifierLast) {
handleOtherDeclSpecModifier(); handleOtherDeclSpecModifier();
@ -2510,31 +2517,19 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser {
private ICPPASTSimpleDeclSpecifier buildSimpleDeclSpec(int storageClass, int simpleType, private ICPPASTSimpleDeclSpecifier buildSimpleDeclSpec(int storageClass, int simpleType,
int options, int isLong, IASTExpression typeofExpression, int offset, int endOffset) { int options, int isLong, IASTExpression typeofExpression, int offset, int endOffset) {
ICPPASTSimpleDeclSpecifier declSpec= nodeFactory.newSimpleDeclSpecifier();
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();
}
configureDeclSpec(declSpec, storageClass, options); configureDeclSpec(declSpec, storageClass, options);
declSpec.setType(simpleType); declSpec.setType(simpleType);
declSpec.setLong(isLong == 1); declSpec.setLong(isLong == 1);
declSpec.setLongLong(isLong > 1);
declSpec.setShort((options & SHORT) != 0); declSpec.setShort((options & SHORT) != 0);
declSpec.setUnsigned((options & UNSIGNED) != 0); declSpec.setUnsigned((options & UNSIGNED) != 0);
declSpec.setSigned((options & SIGNED) != 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); ((ASTNode) declSpec).setOffsetAndLength(offset, endOffset-offset);
return declSpec; return declSpec;
@ -2548,6 +2543,7 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser {
declSpec.setFriend((options & FRIEND) != 0); declSpec.setFriend((options & FRIEND) != 0);
declSpec.setVirtual((options & VIRTUAL) != 0); declSpec.setVirtual((options & VIRTUAL) != 0);
declSpec.setExplicit((options & EXPLICIT) != 0); declSpec.setExplicit((options & EXPLICIT) != 0);
declSpec.setRestrict((options & RESTRICT) != 0);
} }
/** /**
@ -2717,18 +2713,10 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser {
if (declspec instanceof ICPPASTSimpleDeclSpecifier) { if (declspec instanceof ICPPASTSimpleDeclSpecifier) {
ICPPASTSimpleDeclSpecifier sspec= (ICPPASTSimpleDeclSpecifier) declspec; ICPPASTSimpleDeclSpecifier sspec= (ICPPASTSimpleDeclSpecifier) declspec;
switch(sspec.getType()) { if (CPPVisitor.doesNotSpecifyType(declspec)) {
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;
}
return false; return false;
}
case IASTSimpleDeclSpecifier.t_void: if (sspec.getType() == IASTSimpleDeclSpecifier.t_void) {
return false; 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 * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0 * are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at * which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html * http://www.eclipse.org/legal/epl-v10.html
* *
* Contributors: * Contributors:
* IBM - Initial API and implementation * John Camelon (IBM) - Initial API and implementation
* Markus Schorn (Wind River Systems) * Markus Schorn (Wind River Systems)
*******************************************************************************/ *******************************************************************************/
package org.eclipse.cdt.internal.core.dom.parser.cpp; 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.IASTExpression;
import org.eclipse.cdt.core.dom.ast.IASTNode;
import org.eclipse.cdt.core.dom.ast.gnu.cpp.IGPPASTSimpleDeclSpecifier; 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 @Deprecated
implements IGPPASTSimpleDeclSpecifier, IASTAmbiguityParent { 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() {
} }
public GPPASTSimpleDeclSpecifier(IASTExpression typeofExpression) { public GPPASTSimpleDeclSpecifier(IASTExpression typeofExpression) {
setTypeofExpression(typeofExpression); super();
setDeclTypeExpression(typeofExpression);
} }
@Override @Override
public GPPASTSimpleDeclSpecifier copy() { public GPPASTSimpleDeclSpecifier copy() {
GPPASTSimpleDeclSpecifier copy = new GPPASTSimpleDeclSpecifier(); GPPASTSimpleDeclSpecifier copy = new GPPASTSimpleDeclSpecifier();
copySimpleDeclSpec(copy); copySimpleDeclSpec(copy);
copy.setTypeofExpression(typeOfExpression == null ? null : typeOfExpression.copy());
copy.longLong = longLong;
copy.restrict = restrict;
copy.complex = complex;
copy.imaginary = imaginary;
return copy; 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) { public void setTypeofExpression(IASTExpression typeofExpression) {
typeOfExpression = typeofExpression; setDeclTypeExpression(typeofExpression);
if (typeofExpression != null) {
typeofExpression.setParent(this);
typeofExpression.setPropertyInParent(TYPEOF_EXPRESSION);
}
} }
public IASTExpression getTypeofExpression() { 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 * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0 * are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at * 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.ICompositeType;
import org.eclipse.cdt.core.dom.ast.IEnumeration; import org.eclipse.cdt.core.dom.ast.IEnumeration;
import org.eclipse.cdt.core.dom.ast.IEnumerator; 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.IFunctionType;
import org.eclipse.cdt.core.dom.ast.ILabel; import org.eclipse.cdt.core.dom.ast.ILabel;
import org.eclipse.cdt.core.dom.ast.IParameter; 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.cpp.ICPPASTCompositeTypeSpecifier.ICPPASTBaseSpecifier;
import org.eclipse.cdt.core.dom.ast.gnu.cpp.IGPPASTPointer; 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.IGPPASTPointerToMember;
import org.eclipse.cdt.core.dom.ast.gnu.cpp.IGPPASTSimpleDeclSpecifier;
import org.eclipse.cdt.core.index.IIndexBinding; import org.eclipse.cdt.core.index.IIndexBinding;
import org.eclipse.cdt.core.parser.util.ArrayUtil; import org.eclipse.cdt.core.parser.util.ArrayUtil;
import org.eclipse.cdt.core.parser.util.CharArrayUtils; import org.eclipse.cdt.core.parser.util.CharArrayUtils;
@ -1742,13 +1742,8 @@ public class CPPVisitor extends ASTQueries {
name = ((IASTEnumerationSpecifier)declSpec).getName(); name = ((IASTEnumerationSpecifier)declSpec).getName();
} else if (declSpec instanceof ICPPASTSimpleDeclSpecifier) { } else if (declSpec instanceof ICPPASTSimpleDeclSpecifier) {
ICPPASTSimpleDeclSpecifier spec = (ICPPASTSimpleDeclSpecifier) declSpec; ICPPASTSimpleDeclSpecifier spec = (ICPPASTSimpleDeclSpecifier) declSpec;
if (spec instanceof IGPPASTSimpleDeclSpecifier) { // Check for decltype(expr)
IGPPASTSimpleDeclSpecifier gspec = (IGPPASTSimpleDeclSpecifier) spec; type = getDeclType(spec);
final IASTExpression typeofExpression = gspec.getTypeofExpression();
if (typeofExpression != null) {
type = typeofExpression.getExpressionType();
}
}
if (type == null) { if (type == null) {
type = new CPPBasicType(spec); type = new CPPBasicType(spec);
} }
@ -1782,6 +1777,55 @@ public class CPPVisitor extends ASTQueries {
return type; 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) { public static IType getThisType(IScope scope) {
try { try {
IASTNode node = null; IASTNode node = null;
@ -2182,12 +2226,7 @@ public class CPPVisitor extends ASTQueries {
if (declspec instanceof ICPPASTSimpleDeclSpecifier) { if (declspec instanceof ICPPASTSimpleDeclSpecifier) {
ICPPASTSimpleDeclSpecifier ds= (ICPPASTSimpleDeclSpecifier) declspec; ICPPASTSimpleDeclSpecifier ds= (ICPPASTSimpleDeclSpecifier) declspec;
if (ds.getType() == IASTSimpleDeclSpecifier.t_unspecified) { if (ds.getType() == IASTSimpleDeclSpecifier.t_unspecified) {
if (ds instanceof IGPPASTSimpleDeclSpecifier) { if (ds.isShort() || ds.isLong() || ds.isLongLong() || ds.isSigned() || ds.isUnsigned())
final IGPPASTSimpleDeclSpecifier gds = (IGPPASTSimpleDeclSpecifier) ds;
if (gds.isLongLong() || gds.getTypeofExpression() != null)
return false;
}
if (ds.isShort() || ds.isLong() || ds.isSigned() || ds.isUnsigned())
return false; return false;
return true; 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. * 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) { if (t instanceof IQualifierType) {
IQualifierType qt= (IQualifierType) t; IQualifierType qt= (IQualifierType) t;
if (qt.isConst()) { 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 * Rapperswil, University of applied sciences and others
* All rights reserved. This program and the accompanying materials * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0 * 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.ICPPASTTypenameExpression;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTUnaryExpression; 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.IGNUASTTypeIdExpression;
import org.eclipse.cdt.core.dom.ast.gnu.IGNUASTUnaryExpression;
import org.eclipse.cdt.core.dom.ast.gnu.cpp.IGPPASTBinaryExpression; import org.eclipse.cdt.core.dom.ast.gnu.cpp.IGPPASTBinaryExpression;
import org.eclipse.cdt.internal.core.dom.rewrite.commenthandler.NodeCommentMap; import org.eclipse.cdt.internal.core.dom.rewrite.commenthandler.NodeCommentMap;
@ -252,8 +251,8 @@ public class ExpressionWriter extends NodeWriter{
case IASTUnaryExpression.op_bracketedPrimary: case IASTUnaryExpression.op_bracketedPrimary:
case ICPPASTUnaryExpression.op_throw: case ICPPASTUnaryExpression.op_throw:
case ICPPASTUnaryExpression.op_typeid: case ICPPASTUnaryExpression.op_typeid:
case IGNUASTUnaryExpression.op_alignOf: case IASTUnaryExpression.op_alignOf:
case IGNUASTUnaryExpression.op_typeof: case IASTUnaryExpression.op_typeof:
return true; return true;
default: default:
@ -268,8 +267,8 @@ public class ExpressionWriter extends NodeWriter{
case IASTUnaryExpression.op_postFixIncr: case IASTUnaryExpression.op_postFixIncr:
case IASTUnaryExpression.op_bracketedPrimary: case IASTUnaryExpression.op_bracketedPrimary:
case ICPPASTUnaryExpression.op_typeid: case ICPPASTUnaryExpression.op_typeid:
case IGNUASTUnaryExpression.op_alignOf: case IASTUnaryExpression.op_alignOf:
case IGNUASTUnaryExpression.op_typeof: case IASTUnaryExpression.op_typeof:
return true; return true;
default: default:
@ -306,9 +305,9 @@ public class ExpressionWriter extends NodeWriter{
return THROW; return THROW;
case ICPPASTUnaryExpression.op_typeid: case ICPPASTUnaryExpression.op_typeid:
return TYPEID_OP; return TYPEID_OP;
case IGNUASTUnaryExpression.op_alignOf: case IASTUnaryExpression.op_alignOf:
return ALIGNOF_OP; return ALIGNOF_OP;
case IGNUASTUnaryExpression.op_typeof: case IASTUnaryExpression.op_typeof:
return TYPEOF_OP; return TYPEOF_OP;
default: default:
System.err.println("Unkwown unaryExpressionType: " + unaryExpressionType); //$NON-NLS-1$ System.err.println("Unkwown unaryExpressionType: " + unaryExpressionType); //$NON-NLS-1$
@ -326,8 +325,8 @@ public class ExpressionWriter extends NodeWriter{
case ICPPASTUnaryExpression.op_typeid: case ICPPASTUnaryExpression.op_typeid:
return CLOSING_BRACKET_OP; return CLOSING_BRACKET_OP;
case IASTUnaryExpression.op_bracketedPrimary: case IASTUnaryExpression.op_bracketedPrimary:
case IGNUASTUnaryExpression.op_alignOf: case IASTUnaryExpression.op_alignOf:
case IGNUASTUnaryExpression.op_typeof: case IASTUnaryExpression.op_typeof:
return CLOSING_BRACKET_OP; return CLOSING_BRACKET_OP;
default: default:
System.err.println("Unkwown unaryExpressionType " + unaryExpressionType); //$NON-NLS-1$ 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 * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0 * are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at * which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html * http://www.eclipse.org/legal/epl-v10.html
* *
* Contributors: * 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; 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.Keywords;
import org.eclipse.cdt.core.parser.ParserLanguage; import org.eclipse.cdt.core.parser.ParserLanguage;
/**
* @author jcamelon
*/
public class KeywordSets { public class KeywordSets {
public static Set<String> getKeywords( KeywordSetKey kind, ParserLanguage language ) 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);
ALL_CPP.add( Keywords.CONST_CAST); ALL_CPP.add( Keywords.CONST_CAST);
ALL_CPP.add( Keywords.CONTINUE); ALL_CPP.add( Keywords.CONTINUE);
ALL_CPP.add( Keywords.DECLTYPE);
ALL_CPP.add( Keywords.DEFAULT); ALL_CPP.add( Keywords.DEFAULT);
ALL_CPP.add( Keywords.DELETE); ALL_CPP.add( Keywords.DELETE);
ALL_CPP.add( Keywords.DO); ALL_CPP.add( Keywords.DO);
@ -504,6 +503,7 @@ public class KeywordSets {
KEYWORDS_CPP.add( Keywords.CONST ); KEYWORDS_CPP.add( Keywords.CONST );
KEYWORDS_CPP.add( Keywords.CONST_CAST ); KEYWORDS_CPP.add( Keywords.CONST_CAST );
KEYWORDS_CPP.add( Keywords.CONTINUE ); KEYWORDS_CPP.add( Keywords.CONTINUE );
KEYWORDS_CPP.add( Keywords.DECLTYPE);
KEYWORDS_CPP.add( Keywords.DEFAULT ); KEYWORDS_CPP.add( Keywords.DEFAULT );
KEYWORDS_CPP.add( Keywords.DELETE ); KEYWORDS_CPP.add( Keywords.DELETE );
KEYWORDS_CPP.add( Keywords.DO ); 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 * Rapperswil, University of applied sciences and others
* All rights reserved. This program and the accompanying materials * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0 * 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 * http://www.eclipse.org/legal/epl-v10.html
* *
* Contributors: * Contributors:
* Institute for Software - initial API and implementation * Institute for Software - initial API and implementation
*******************************************************************************/ *******************************************************************************/
package org.eclipse.cdt.internal.ui.refactoring.extractfunction; package org.eclipse.cdt.internal.ui.refactoring.extractfunction;
import java.util.Arrays; import java.util.Arrays;
import java.util.List; import java.util.List;
import java.util.Map; 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.IType;
import org.eclipse.cdt.core.dom.ast.c.ICASTDeclSpecifier; 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.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.ICPPASTCatchHandler;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTConversionName; import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTConversionName;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTDeclSpecifier; 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.ICPPASTUsingDeclaration;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTVisibilityLabel; 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.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.IGPPASTExplicitTemplateInstantiation;
import org.eclipse.cdt.core.dom.ast.gnu.cpp.IGPPASTPointer; 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.IIndex;
import org.eclipse.cdt.core.index.IIndexName; import org.eclipse.cdt.core.index.IIndexName;
@ -137,33 +132,7 @@ public class TrailNodeEqualityChecker implements EqualityChecker<IASTNode> {
} }
private boolean isDeclSpecifierEquals(IASTNode trailNode, IASTNode node) { private boolean isDeclSpecifierEquals(IASTNode trailNode, IASTNode node) {
if (trailNode instanceof IGPPASTSimpleDeclSpecifier) { if (trailNode instanceof IASTSimpleDeclSpecifier) {
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) {
IASTSimpleDeclSpecifier trailDecl = (IASTSimpleDeclSpecifier) trailNode; IASTSimpleDeclSpecifier trailDecl = (IASTSimpleDeclSpecifier) trailNode;
IASTSimpleDeclSpecifier decl = (IASTSimpleDeclSpecifier) node; IASTSimpleDeclSpecifier decl = (IASTSimpleDeclSpecifier) node;
@ -386,9 +355,21 @@ public class TrailNodeEqualityChecker implements EqualityChecker<IASTNode> {
} }
private boolean isDeclSpecifierEquals(IASTDeclSpecifier trailDeclSpeci, IASTDeclSpecifier declSpeci){ 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() return trailDeclSpeci.isConst() == declSpeci.isConst()
&& trailDeclSpeci.isInline() == declSpeci.isInline() && trailDeclSpeci.isInline() == declSpeci.isInline()
&& trailDeclSpeci.isVolatile() == declSpeci.isVolatile() && trailDeclSpeci.isVolatile() == declSpeci.isVolatile()
&& trailDeclSpeci.isRestrict() == declSpeci.isRestrict()
&& trailDeclSpeci.getStorageClass() == declSpeci.getStorageClass(); && trailDeclSpeci.getStorageClass() == declSpeci.getStorageClass();
} }
@ -398,7 +379,10 @@ public class TrailNodeEqualityChecker implements EqualityChecker<IASTNode> {
&& trailDeclSpeci.isShort() == declSpeci.isShort() && trailDeclSpeci.isShort() == declSpeci.isShort()
&& trailDeclSpeci.isSigned() == declSpeci.isSigned() && trailDeclSpeci.isSigned() == declSpeci.isSigned()
&& trailDeclSpeci.isUnsigned() == declSpeci.isUnsigned() && 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) { private boolean isNameEquals(TrailName trailName, IASTName name) {