Skip to main content
aboutsummaryrefslogtreecommitdiffstats
path: root/core
diff options
context:
space:
mode:
authorMarkus Schorn2010-01-15 18:28:45 +0000
committerMarkus Schorn2010-01-15 18:28:45 +0000
commit5a1293b690c1ec4b51fca1715d546d9e03ba9891 (patch)
tree4ab776e3bb3a6a3ba1d725edd73d8d2f15214b3b /core
parent64c58d177664a4482d96be96068d255af7ff96c5 (diff)
downloadorg.eclipse.cdt-5a1293b690c1ec4b51fca1715d546d9e03ba9891.tar.gz
org.eclipse.cdt-5a1293b690c1ec4b51fca1715d546d9e03ba9891.tar.xz
org.eclipse.cdt-5a1293b690c1ec4b51fca1715d546d9e03ba9891.zip
Bug 294730: Declared type of an expression.
Diffstat (limited to 'core')
-rw-r--r--core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2CPPTests.java45
-rw-r--r--core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/ASTStringUtil.java43
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/ASTSignatureUtil.java215
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTDeclSpecifier.java95
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTSimpleDeclSpecifier.java178
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTUnaryExpression.java6
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/c/ICASTDeclSpecifier.java17
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/c/ICASTSimpleDeclSpecifier.java62
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/c/ICNodeFactory.java13
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPASTDeclSpecifier.java21
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPASTSimpleDeclSpecifier.java25
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPNodeFactory.java10
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/gnu/IGNUASTUnaryExpression.java27
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/gnu/c/IGCCASTSimpleDeclSpecifier.java26
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/gnu/cpp/IGPPASTDeclSpecifier.java19
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/gnu/cpp/IGPPASTSimpleDeclSpecifier.java80
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/IToken.java8
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/Keywords.java9
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/AbstractGNUSourceCodeParser.java7
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/VariableReadWriteFlags.java6
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTSimpleDeclSpecifier.java39
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CNodeFactory.java6
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CScope.java9
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CVisitor.java12
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/GCCASTSimpleDeclSpecifier.java61
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/GNUCSourceParser.java24
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTBaseDeclSpecifier.java26
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTFieldReference.java30
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTSimpleDeclSpecifier.java75
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPBasicType.java22
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPNodeFactory.java12
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/GNUCPPSourceParser.java64
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/GPPASTSimpleDeclSpecifier.java99
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/CPPVisitor.java69
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/SemanticUtil.java2
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/rewrite/astwriter/ExpressionWriter.java19
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/token/KeywordSets.java10
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/extractfunction/TrailNodeEqualityChecker.java54
38 files changed, 705 insertions, 840 deletions
diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2CPPTests.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2CPPTests.java
index 06c24742e42..04129664582 100644
--- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2CPPTests.java
+++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2CPPTests.java
@@ -113,7 +113,6 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPReferenceType;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPUsingDeclaration;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPVariable;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTCompositeTypeSpecifier.ICPPASTBaseSpecifier;
-import org.eclipse.cdt.core.dom.ast.gnu.cpp.IGPPASTSimpleDeclSpecifier;
import org.eclipse.cdt.core.dom.ast.gnu.cpp.IGPPPointerToMemberType;
import org.eclipse.cdt.core.dom.ast.gnu.cpp.IGPPPointerType;
import org.eclipse.cdt.core.parser.ParserLanguage;
@@ -4670,10 +4669,10 @@ public class AST2CPPTests extends AST2BaseTest {
IASTTranslationUnit tu = parse( getAboveComment(), ParserLanguage.CPP, true, true );
IASTDeclaration[] decls = tu.getDeclarations();
- assertTrue(((IGPPASTSimpleDeclSpecifier)((IASTSimpleDeclaration)decls[0]).getDeclSpecifier()).isComplex());
- assertEquals(((IGPPASTSimpleDeclSpecifier)((IASTSimpleDeclaration)decls[0]).getDeclSpecifier()).getType(), IASTSimpleDeclSpecifier.t_float);
- assertTrue(((IGPPASTSimpleDeclSpecifier)((IASTSimpleDeclaration)decls[1]).getDeclSpecifier()).isComplex());
- assertEquals(((IGPPASTSimpleDeclSpecifier)((IASTSimpleDeclaration)decls[1]).getDeclSpecifier()).getType(), IASTSimpleDeclSpecifier.t_double);
+ assertTrue(((IASTSimpleDeclSpecifier)((IASTSimpleDeclaration)decls[0]).getDeclSpecifier()).isComplex());
+ assertEquals(((IASTSimpleDeclSpecifier)((IASTSimpleDeclaration)decls[0]).getDeclSpecifier()).getType(), IASTSimpleDeclSpecifier.t_float);
+ assertTrue(((IASTSimpleDeclSpecifier)((IASTSimpleDeclaration)decls[1]).getDeclSpecifier()).isComplex());
+ assertEquals(((IASTSimpleDeclSpecifier)((IASTSimpleDeclaration)decls[1]).getDeclSpecifier()).getType(), IASTSimpleDeclSpecifier.t_double);
}
// class _A {
@@ -8010,5 +8009,41 @@ public class AST2CPPTests extends AST2BaseTest {
b= bh.assertNonProblem("f(a, 1)", 1);
assertSame(b, glob);
}
+
+ // const int&& foo();
+ // int i;
+ // struct A { double x; };
+ // const A* a = new A();
+ // decltype(foo()) t1(); // type is const int&&
+ // decltype(i) t2(); // type is int
+ // decltype(a->x) t3(); // type is double
+ // decltype((a->x)) t4(); // type is const double&
+ // __typeof foo() t5(); // type is const int
+ // __typeof(i) t6(); // type is int
+ // __typeof(a->x) t7(); // type is const double
+ // __typeof((a->x)) t8(); // type is const double
+
+ public void testDeclType_294730() throws Exception {
+ String code= getAboveComment();
+ parseAndCheckBindings(code, ParserLanguage.CPP);
+ BindingAssertionHelper bh= new BindingAssertionHelper(code, true);
+ IFunction f= bh.assertNonProblem("t1", 2);
+ assertEquals("const int &&", ASTTypeUtil.getType(f.getType().getReturnType()));
+ f= bh.assertNonProblem("t2", 2);
+ assertEquals("int", ASTTypeUtil.getType(f.getType().getReturnType()));
+ f= bh.assertNonProblem("t3", 2);
+ assertEquals("double", ASTTypeUtil.getType(f.getType().getReturnType()));
+ f= bh.assertNonProblem("t4", 2);
+ assertEquals("const double &", ASTTypeUtil.getType(f.getType().getReturnType()));
+
+ f= bh.assertNonProblem("t5", 2);
+ assertEquals("const int", ASTTypeUtil.getType(f.getType().getReturnType()));
+ f= bh.assertNonProblem("t6", 2);
+ assertEquals("int", ASTTypeUtil.getType(f.getType().getReturnType()));
+ f= bh.assertNonProblem("t7", 2);
+ assertEquals("const double", ASTTypeUtil.getType(f.getType().getReturnType()));
+ f= bh.assertNonProblem("t8", 2);
+ assertEquals("const double", ASTTypeUtil.getType(f.getType().getReturnType()));
+ }
}
diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/ASTStringUtil.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/ASTStringUtil.java
index f94d0a35b0d..48d6f7a138e 100644
--- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/ASTStringUtil.java
+++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/ASTStringUtil.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2006, 2009 Wind River Systems, Inc. and others.
+ * Copyright (c) 2006, 2010 Wind River Systems, Inc. and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -51,7 +51,6 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTParameterDeclaration;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTPointerToMember;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTQualifiedName;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTReferenceOperator;
-import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTSimpleDeclSpecifier;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTSimpleTypeTemplateParameter;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTTemplateId;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTTemplateParameter;
@@ -60,7 +59,6 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTTypeId;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTTypenameExpression;
import org.eclipse.cdt.core.dom.ast.gnu.c.ICASTKnRFunctionDeclarator;
import org.eclipse.cdt.core.dom.ast.gnu.cpp.IGPPASTPointer;
-import org.eclipse.cdt.core.dom.ast.gnu.cpp.IGPPASTSimpleDeclSpecifier;
import org.eclipse.cdt.core.parser.Keywords;
import org.eclipse.cdt.internal.core.dom.parser.ASTQueries;
@@ -579,27 +577,14 @@ public class ASTStringUtil {
if (simpleDeclSpec.isLong()) {
buffer.append(Keywords.LONG).append(' ');
}
- if (simpleDeclSpec instanceof ICASTSimpleDeclSpecifier) {
- final ICASTSimpleDeclSpecifier cSimpleDeclSpec= (ICASTSimpleDeclSpecifier)simpleDeclSpec;
- if (cSimpleDeclSpec.isLongLong()) {
- buffer.append(Keywords.LONG_LONG).append(' ');
- }
- if (cSimpleDeclSpec.isComplex()) {
- buffer.append(Keywords._COMPLEX).append(' ');
- }
- if (cSimpleDeclSpec.isImaginary()) {
- buffer.append(Keywords._IMAGINARY).append(' ');
- }
- switch (simpleDeclSpec.getType()) {
- case ICASTSimpleDeclSpecifier.t_Bool:
- buffer.append(Keywords._BOOL).append(' ');
- break;
- }
- } else if (simpleDeclSpec instanceof IGPPASTSimpleDeclSpecifier) {
- final IGPPASTSimpleDeclSpecifier gppSimpleDeclSpec= (IGPPASTSimpleDeclSpecifier)simpleDeclSpec;
- if (gppSimpleDeclSpec.isLongLong()) {
- buffer.append(Keywords.LONG_LONG).append(' ');
- }
+ if (simpleDeclSpec.isLongLong()) {
+ buffer.append(Keywords.LONG_LONG).append(' ');
+ }
+ if (simpleDeclSpec.isComplex()) {
+ buffer.append(Keywords._COMPLEX).append(' ');
+ }
+ if (simpleDeclSpec.isImaginary()) {
+ buffer.append(Keywords._IMAGINARY).append(' ');
}
switch (simpleDeclSpec.getType()) {
case IASTSimpleDeclSpecifier.t_void:
@@ -617,10 +602,14 @@ public class ASTStringUtil {
case IASTSimpleDeclSpecifier.t_double:
buffer.append(Keywords.DOUBLE).append(' ');
break;
- case ICPPASTSimpleDeclSpecifier.t_bool:
- buffer.append(Keywords.BOOL).append(' ');
+ case IASTSimpleDeclSpecifier.t_bool:
+ if (simpleDeclSpec instanceof ICASTSimpleDeclSpecifier) {
+ buffer.append(Keywords.cBOOL).append(' ');
+ } else {
+ buffer.append(Keywords.BOOL).append(' ');
+ }
break;
- case ICPPASTSimpleDeclSpecifier.t_wchar_t:
+ case IASTSimpleDeclSpecifier.t_wchar_t:
buffer.append(Keywords.WCHAR_T).append(' ');
break;
default:
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/ASTSignatureUtil.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/ASTSignatureUtil.java
index 48a37ebcf84..1ac28708624 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/ASTSignatureUtil.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/ASTSignatureUtil.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2005, 2009 IBM Corporation and others.
+ * Copyright (c) 2005, 2010 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -13,7 +13,6 @@ package org.eclipse.cdt.core.dom.ast;
import org.eclipse.cdt.core.dom.ast.c.ICASTArrayDesignator;
import org.eclipse.cdt.core.dom.ast.c.ICASTArrayModifier;
-import org.eclipse.cdt.core.dom.ast.c.ICASTDeclSpecifier;
import org.eclipse.cdt.core.dom.ast.c.ICASTDesignatedInitializer;
import org.eclipse.cdt.core.dom.ast.c.ICASTDesignator;
import org.eclipse.cdt.core.dom.ast.c.ICASTFieldDesignator;
@@ -27,20 +26,15 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTDeleteExpression;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTNewExpression;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTPackExpansionExpression;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTReferenceOperator;
-import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTSimpleDeclSpecifier;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTSimpleTypeConstructorExpression;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTTypeIdExpression;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTTypenameExpression;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTUnaryExpression;
import org.eclipse.cdt.core.dom.ast.gnu.IGNUASTCompoundStatementExpression;
import org.eclipse.cdt.core.dom.ast.gnu.IGNUASTTypeIdExpression;
-import org.eclipse.cdt.core.dom.ast.gnu.IGNUASTUnaryExpression;
import org.eclipse.cdt.core.dom.ast.gnu.c.ICASTKnRFunctionDeclarator;
import org.eclipse.cdt.core.dom.ast.gnu.c.IGCCASTArrayRangeDesignator;
-import org.eclipse.cdt.core.dom.ast.gnu.cpp.IGPPASTDeclSpecifier;
import org.eclipse.cdt.core.dom.ast.gnu.cpp.IGPPASTPointer;
-import org.eclipse.cdt.core.dom.ast.gnu.cpp.IGPPASTSimpleDeclSpecifier;
-import org.eclipse.cdt.core.parser.GCCKeywords;
import org.eclipse.cdt.core.parser.Keywords;
import org.eclipse.cdt.internal.core.dom.parser.ASTProblem;
@@ -440,7 +434,7 @@ public class ASTSignatureUtil {
StringBuffer result = new StringBuffer();
- if (declSpec.getStorageClass() == ICPPASTDeclSpecifier.sc_mutable) {
+ if (declSpec.getStorageClass() == IASTDeclSpecifier.sc_mutable) {
result.append(Keywords.MUTABLE);
needSpace = true;
}
@@ -501,6 +495,14 @@ public class ASTSignatureUtil {
result.append(Keywords.INLINE);
needSpace = true;
}
+ if (declSpec.isRestrict()) {
+ if (needSpace) {
+ result.append(SPACE);
+ needSpace = false;
+ }
+ result.append(Keywords.RESTRICT);
+ needSpace = true;
+ }
if (declSpec.isVolatile()) {
if (needSpace) {
result.append(SPACE);
@@ -510,24 +512,7 @@ public class ASTSignatureUtil {
needSpace = true;
}
- if (declSpec instanceof ICASTDeclSpecifier) {
- if (((ICASTDeclSpecifier) declSpec).isRestrict()) {
- if (needSpace) {
- result.append(SPACE);
- needSpace = false;
- }
- result.append(Keywords.RESTRICT);
- needSpace = true;
- }
- } else if (declSpec instanceof ICPPASTDeclSpecifier) {
- if (declSpec.getStorageClass() == ICPPASTDeclSpecifier.sc_mutable) {
- if (needSpace) {
- result.append(SPACE);
- needSpace = false;
- }
- result.append(Keywords.MUTABLE);
- needSpace = true;
- }
+ if (declSpec instanceof ICPPASTDeclSpecifier) {
if (((ICPPASTDeclSpecifier) declSpec).isExplicit()) {
if (needSpace) {
result.append(SPACE);
@@ -552,16 +537,7 @@ public class ASTSignatureUtil {
result.append(Keywords.VIRTUAL);
needSpace = true;
}
- } else if (declSpec instanceof IGPPASTDeclSpecifier) {
- if (((IGPPASTDeclSpecifier) declSpec).isRestrict()) {
- if (needSpace) {
- result.append(SPACE);
- needSpace = false;
- }
- result.append(Keywords.RESTRICT);
- needSpace = true;
- }
- }
+ }
// handle complex cases
if (declSpec instanceof IASTCompositeTypeSpecifier) {
@@ -631,100 +607,32 @@ public class ASTSignatureUtil {
result.append(((IASTNamedTypeSpecifier) declSpec).getName().toString());
needSpace = true;
} else if (declSpec instanceof IASTSimpleDeclSpecifier) {
- // handle complex cases
- if (declSpec instanceof IGPPASTSimpleDeclSpecifier) {
- if (((IGPPASTSimpleDeclSpecifier) declSpec).isLongLong())
- result.append(Keywords.LONG_LONG);
- if (((IGPPASTSimpleDeclSpecifier) declSpec).isComplex()) {
- if (needSpace) {
- result.append(SPACE);
- needSpace = false;
- }
- result.append(Keywords.c_COMPLEX);
- needSpace = true;
- }
- if (((IGPPASTSimpleDeclSpecifier) declSpec).isImaginary()) {
- if (needSpace) {
- result.append(SPACE);
- needSpace = false;
- }
- result.append(Keywords.c_IMAGINARY);
- needSpace = true;
- }
-
- switch (((IGPPASTSimpleDeclSpecifier) declSpec).getType()) {
- case IGPPASTSimpleDeclSpecifier.t_typeof:
- if (needSpace) {
- result.append(SPACE);
- needSpace = false;
- }
- result.append(GCCKeywords.TYPEOF);
- needSpace = true;
- break;
+ final IASTSimpleDeclSpecifier sds = (IASTSimpleDeclSpecifier) declSpec;
+ if (sds.isLongLong()) {
+ if (needSpace) {
+ result.append(SPACE);
+ needSpace = false;
}
+ result.append(Keywords.LONG_LONG);
+ needSpace = true;
}
-
- if (declSpec instanceof ICPPASTSimpleDeclSpecifier) {
- switch (((ICPPASTSimpleDeclSpecifier) declSpec).getType()) {
- case ICPPASTSimpleDeclSpecifier.t_bool:
- if (needSpace) {
- result.append(SPACE);
- needSpace = false;
- }
- result.append(Keywords.BOOL);
- needSpace = true;
- break;
- case ICPPASTSimpleDeclSpecifier.t_wchar_t:
- if (needSpace) {
- result.append(SPACE);
- needSpace = false;
- }
- result.append(Keywords.WCHAR_T);
- needSpace = true;
- break;
+ if (sds.isComplex()) {
+ if (needSpace) {
+ result.append(SPACE);
+ needSpace = false;
}
+ result.append(Keywords.c_COMPLEX);
+ needSpace = true;
}
-
- if (declSpec instanceof ICASTSimpleDeclSpecifier) {
- if (((ICASTSimpleDeclSpecifier) declSpec).isLongLong()) {
- if (needSpace) {
- result.append(SPACE);
- needSpace = false;
- }
- result.append(Keywords.LONG_LONG);
- needSpace = true;
- }
- if (((ICASTSimpleDeclSpecifier) declSpec).isComplex()) {
- if (needSpace) {
- result.append(SPACE);
- needSpace = false;
- }
- result.append(Keywords.c_COMPLEX);
- needSpace = true;
- }
- if (((ICASTSimpleDeclSpecifier) declSpec).isImaginary()) {
- if (needSpace) {
- result.append(SPACE);
- needSpace = false;
- }
- result.append(Keywords.c_IMAGINARY);
- needSpace = true;
- }
-
- switch (((ICASTSimpleDeclSpecifier) declSpec).getType()) {
- case ICASTSimpleDeclSpecifier.t_Bool:
- if (needSpace) {
- result.append(SPACE);
- needSpace = false;
- }
- result.append(Keywords.c_BOOL);
- needSpace = true;
- break;
+ if (sds.isImaginary()) {
+ if (needSpace) {
+ result.append(SPACE);
+ needSpace = false;
}
+ result.append(Keywords.c_IMAGINARY);
+ needSpace = true;
}
-
- // handle simple cases
- if (((IASTSimpleDeclSpecifier) declSpec).isLong()) {
+ if (sds.isLong()) {
if (needSpace) {
result.append(SPACE);
needSpace = false;
@@ -732,7 +640,7 @@ public class ASTSignatureUtil {
result.append(Keywords.LONG);
needSpace = true;
}
- if (((IASTSimpleDeclSpecifier) declSpec).isShort()) {
+ if (sds.isShort()) {
if (needSpace) {
result.append(SPACE);
needSpace = false;
@@ -740,7 +648,7 @@ public class ASTSignatureUtil {
result.append(Keywords.SHORT);
needSpace = true;
}
- if (((IASTSimpleDeclSpecifier) declSpec).isSigned()) {
+ if (sds.isSigned()) {
if (needSpace) {
result.append(SPACE);
needSpace = false;
@@ -748,7 +656,7 @@ public class ASTSignatureUtil {
result.append(Keywords.SIGNED);
needSpace = true;
}
- if (((IASTSimpleDeclSpecifier) declSpec).isUnsigned()) {
+ if (sds.isUnsigned()) {
if (needSpace) {
result.append(SPACE);
needSpace = false;
@@ -757,7 +665,35 @@ public class ASTSignatureUtil {
needSpace = true;
}
- switch (((IASTSimpleDeclSpecifier) declSpec).getType()) {
+ switch (sds.getType()) {
+ case IASTSimpleDeclSpecifier.t_typeof:
+ if (needSpace) {
+ result.append(SPACE);
+ needSpace = false;
+ }
+ result.append(Keywords.TYPEOF);
+ needSpace = true;
+ break;
+ case IASTSimpleDeclSpecifier.t_decltype:
+ if (needSpace) {
+ result.append(SPACE);
+ needSpace = false;
+ }
+ result.append(Keywords.cDECLTYPE);
+ needSpace = true;
+ break;
+ case IASTSimpleDeclSpecifier.t_bool:
+ if (needSpace) {
+ result.append(SPACE);
+ needSpace = false;
+ }
+ if (declSpec instanceof ICASTSimpleDeclSpecifier) {
+ result.append(Keywords.c_BOOL);
+ } else {
+ result.append(Keywords.BOOL);
+ }
+ needSpace = true;
+ break;
case IASTSimpleDeclSpecifier.t_char:
if (needSpace) {
result.append(SPACE);
@@ -766,6 +702,14 @@ public class ASTSignatureUtil {
result.append(Keywords.CHAR);
needSpace = true;
break;
+ case IASTSimpleDeclSpecifier.t_wchar_t:
+ if (needSpace) {
+ result.append(SPACE);
+ needSpace = false;
+ }
+ result.append(Keywords.WCHAR_T);
+ needSpace = true;
+ break;
case IASTSimpleDeclSpecifier.t_double:
if (needSpace) {
result.append(SPACE);
@@ -1181,21 +1125,14 @@ public class ASTSignatureUtil {
opString = Keywords.TYPEID;
break;
}
- } else if (ue instanceof IGNUASTUnaryExpression) {
- switch (op) {
- case IGNUASTUnaryExpression.op_alignOf:
- opString = Keywords.ALIGNOF;
- break;
- case IGNUASTUnaryExpression.op_typeof:
- opString = Keywords.TYPEOF;
- break;
- }
- }
-
+ }
if (!opString.equals(EMPTY_STRING))
return opString;
switch (op) {
+ case IASTUnaryExpression.op_alignOf:
+ opString = Keywords.ALIGNOF;
+ break;
case IASTUnaryExpression.op_amper:
opString = String.valueOf(Keywords.cpAMPER);
break;
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTDeclSpecifier.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTDeclSpecifier.java
index 661f1841e54..a2cc16c7fe5 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTDeclSpecifier.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTDeclSpecifier.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2004, 2009 IBM Corporation and others.
+ * Copyright (c) 2004, 2010 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -20,108 +20,71 @@ package org.eclipse.cdt.core.dom.ast;
public interface IASTDeclSpecifier extends IASTNode {
/**
- * <code>sc_unspecified</code> undefined storage class
+ * No storage class specified.
*/
public static final int sc_unspecified = 0;
-
- /**
- * <code>sc_typedef</code> typedef
- */
public static final int sc_typedef = 1;
-
- /**
- * <code>sc_extern</code>extern
- */
-
public static final int sc_extern = 2;
-
- /**
- * <code>sc_static</code>static
- */
-
public static final int sc_static = 3;
-
- /**
- * <code>sc_auto</code>auto
- */
-
public static final int sc_auto = 4;
-
- /**
- * <code>sc_register</code>register
- */
public static final int sc_register = 5;
-
/**
- * <code>sc_last</code> for sub-interfaces to continue on
+ * @since 5.2
*/
- public static final int sc_last = sc_register;
+ public static final int sc_mutable = 6;
/**
- * Set the storage class.
- *
- * @param storageClass
- * int
+ * Returns the storage class, which is one of the constants sc_...
*/
- public void setStorageClass(int storageClass);
+ public int getStorageClass();
+ // Type qualifier
+ public boolean isConst();
+ public boolean isVolatile();
/**
- * Get the storage class.
- *
- * @return int
+ * @since 5.2
*/
- public int getStorageClass();
+ public boolean isRestrict();
- // Type qualifier
+ // Function specifier
+ public boolean isInline();
+
/**
- * Is const modifier used?
- *
- * @return boolean
+ * @since 5.1
*/
- public boolean isConst();
+ public IASTDeclSpecifier copy();
/**
- * Set const modifier used.
- *
- * @param value
- * boolean
+ * Not allowed on frozen ast.
*/
- public void setConst(boolean value);
+ public void setStorageClass(int storageClass);
/**
- * Is volatile modifier used?
- *
- * @return boolean
+ * Not allowed on frozen ast.
*/
- public boolean isVolatile();
+ public void setConst(boolean value);
/**
- * Set volatile modifier used.
- *
- * @param value
- * boolean
+ * Not allowed on frozen ast.
*/
public void setVolatile(boolean value);
- // Function specifier
/**
- * Is inline modifier used?
- *
- * @return boolean
+ * Not allowed on frozen ast.
+ * @since 5.2
*/
- public boolean isInline();
+ public void setRestrict(boolean value);
/**
- * Set inline modifier used.
- *
- * @param value
- * boolean
+ * Not allowed on frozen ast.
*/
public void setInline(boolean value);
/**
- * @since 5.1
+ * @deprecated All constants must be defined in this interface.
*/
- public IASTDeclSpecifier copy();
+ @Deprecated
+ public static final int sc_last = sc_register;
+
}
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTSimpleDeclSpecifier.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTSimpleDeclSpecifier.java
index 8ecca73843a..06a848d672e 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTSimpleDeclSpecifier.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTSimpleDeclSpecifier.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2004, 2009 IBM Corporation and others.
+ * Copyright (c) 2004, 2010 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -20,129 +20,195 @@ import org.eclipse.cdt.core.dom.ast.IBasicType.Kind;
* @noimplement This interface is not intended to be implemented by clients.
*/
public interface IASTSimpleDeclSpecifier extends IASTDeclSpecifier {
-
/**
- * 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.
- *
+ * @since 5.2
*/
- 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; //
- * declaration w/t_unspecified type logically defaults to integer.
+ * Used for omitted declaration specifiers. E.g. for declaration of constructors,
+ * or in plain c, where this defaults to an integer.
*/
public static final int t_unspecified = 0;
/**
- * <code>t_void</code> implies void type e.g. void x();
+ * <code>void x();</code>
*/
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;
/**
- * <code>t_int</code> implies int type e.g. int x;
+ * <code>int i;</code>
*/
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;
/**
- * <code>t_double</code> implies double floating point type. e.g. double
- * d;
+ * <code>double d;</code>
*/
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)
+ * @since 5.2
*/
- public static final int t_last = t_double; // used only in subclasses
+ public static final int t_bool = 6;
+
+ /**
+ * <code>t_wchar_t c;</code>
+ * @since 5.2
+ */
+ public static final int t_wchar_t = 7;
/**
- * Set this decl specifier type to <code>type</code>.
- *
- * @param type
- * (int)
+ * <code>typeof 'c' c;</code>
+ * @since 5.2
*/
- public void setType(int type);
-
+ public static final int t_typeof = 8;
+
/**
- * Sets this declaration specifier to the type based on {@link IBasicType.Kind}.
+ * <code>decltype('c') c;</code>
* @since 5.2
*/
- public void setType(Kind kind);
+ public static final int t_decltype = 9;
/**
- * Is the type modified by the signed keyword?
- *
- * @return boolean
+ * @since 5.1
+ */
+ public IASTSimpleDeclSpecifier copy();
+
+ /**
+ * This returns the built-in type for the declaration. The type is then
+ * refined by qualifiers for signed/unsigned and short/long. The type could
+ * also be unspecified which usually means int.
+ */
+ public int getType();
+
+ /**
+ * <code>signed char c;</code>
*/
public boolean isSigned();
/**
- * Is the type modified by the unsigned keyword?
- *
- * @return boolean
+ * <code>unsigned int u;</code>
*/
public boolean isUnsigned();
/**
- * Is the type modified by the short keyword?
- *
- * @return boolean
+ * <code>short int s;</code>
*/
public boolean isShort();
/**
- * Is the type modified by the long keyword?
- *
- * @return boolean
+ * <code>long int l;</code>
*/
public boolean isLong();
/**
- * Change as to if the type is modified by the keyword signed.
- *
- * @param value
- * boolean
+ * <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);
/**
- * Change as to if the type is modified by the keyword unsigned.
- *
- * @param value
- * boolean
+ * Not allowed on frozen ast.
+ * @see #isUnsigned()
*/
public void setUnsigned(boolean value);
/**
- * Change as to if the type is modified by the keyword long.
- *
- * @param value
- * boolean
+ * Not allowed on frozen ast.
+ * @see #isShort()
+ */
+ public void setShort(boolean value);
+
+ /**
+ * Not allowed on frozen ast.
+ * @see #isLong()
*/
public void setLong(boolean value);
/**
- * Change as to if the type is modified by the keyword short.
- *
- * @param value
- * boolean
+ * Not allowed on frozen ast.
+ * @see #isLongLong()
+ * @since 5.2
*/
- public void setShort(boolean value);
+ public void setLongLong(boolean value);
/**
- * @since 5.1
+ * Not allowed on frozen ast.
+ * @see #isComplex()
+ * @since 5.2
*/
- public IASTSimpleDeclSpecifier copy();
+ public void setComplex(boolean value);
+
+ /**
+ * Not allowed on frozen ast.
+ * @see #isImaginary()
+ * @since 5.2
+ */
+ public void setImaginary(boolean value);
+
+ /**
+ * Not allowed on frozen ast.
+ * @see #getDeclTypeExpression()
+ * @since 5.2
+ */
+ public void setDeclTypeExpression(IASTExpression expression);
+
+ /**
+ * @deprecated all constants must be defined in this interface
+ */
+ @Deprecated
+ public static final int t_last = t_double; // used only in subclasses
}
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTUnaryExpression.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTUnaryExpression.java
index 8bcdef58de7..fac3bc109d1 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTUnaryExpression.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTUnaryExpression.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2004, 2009 IBM Corporation and others.
+ * Copyright (c) 2004, 2010 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -101,9 +101,9 @@ public interface IASTUnaryExpression extends IASTExpression {
public static final int op_typeid = 13;
/**
- * for gnu parsers, only. <code>op_typeof</code> is used for typeof( unaryExpression ) type
- * expressions.
+ * @deprecated Shall not be used, 'typeof something' is not an expression, it's a declaration specifier.
*/
+ @Deprecated
public static final int op_typeof = 14;
/**
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/c/ICASTDeclSpecifier.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/c/ICASTDeclSpecifier.java
index 8093dd5dbb0..1665ac244b7 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/c/ICASTDeclSpecifier.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/c/ICASTDeclSpecifier.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2004, 2009 IBM Corporation and others.
+ * Copyright (c) 2004, 2010 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -7,6 +7,7 @@
*
* Contributors:
* Doug Schaefer (IBM) - Initial API and implementation
+ * Markus Schorn (Wind River Systems)
*******************************************************************************/
package org.eclipse.cdt.core.dom.ast.c;
@@ -21,20 +22,6 @@ import org.eclipse.cdt.core.dom.ast.IASTDeclSpecifier;
public interface ICASTDeclSpecifier extends IASTDeclSpecifier {
/**
- * Is restrict keyword used?
- *
- * @return boolean
- */
- public boolean isRestrict();
-
- /**
- * Set restrict to value.
- *
- * @param value
- */
- public void setRestrict(boolean value);
-
- /**
* @since 5.1
*/
public ICASTDeclSpecifier copy();
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/c/ICASTSimpleDeclSpecifier.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/c/ICASTSimpleDeclSpecifier.java
index 5aae5131798..85ebdc65114 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/c/ICASTSimpleDeclSpecifier.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/c/ICASTSimpleDeclSpecifier.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2004, 2009 IBM Corporation and others.
+ * Copyright (c) 2004, 2010 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -7,6 +7,7 @@
*
* Contributors:
* Doug Schaefer (IBM) - Initial API and implementation
+ * Markus Schorn (Wind River Systems)
*******************************************************************************/
package org.eclipse.cdt.core.dom.ast.c;
@@ -18,63 +19,22 @@ import org.eclipse.cdt.core.dom.ast.IASTSimpleDeclSpecifier;
* @noextend This interface is not intended to be extended by clients.
* @noimplement This interface is not intended to be implemented by clients.
*/
-public interface ICASTSimpleDeclSpecifier extends IASTSimpleDeclSpecifier,
- ICASTDeclSpecifier {
+public interface ICASTSimpleDeclSpecifier extends IASTSimpleDeclSpecifier, ICASTDeclSpecifier {
- // Extra types in C
/**
- * <code>t_Bool</code> boolean. e.g. _Bool x;
- */
- public static final int t_Bool = IASTSimpleDeclSpecifier.t_last + 1;
-
- /**
- * <code>t_last</code> is defined for sub-interfaces.
- */
- public static final int t_last = t_Bool;
-
- /**
- * Is complex number? e.g. _Complex t;
- * @return true if it is a complex number, false otherwise
- */
- public boolean isComplex();
-
- /**
- * Set the number to be complex.
- * @param value true if it is a complex number, false otherwise
- */
- public void setComplex(boolean value);
-
- /**
- * Is imaginary number? e.g. _Imaginr
- * @return true if it is an imaginary number, false otherwise
- */
- public boolean isImaginary();
-
- /**
- * Set the number to be imaginary.
- * @param value true if it is an imaginary number, false otherwise
+ * @since 5.1
*/
- public void setImaginary(boolean value);
+ public ICASTSimpleDeclSpecifier copy();
- // allow for long long's
/**
- * Is long long?
- *
- * @return boolean
+ * @deprecated Replaced by {@link IASTSimpleDeclSpecifier#t_bool}.
*/
- public boolean isLongLong();
+ @Deprecated
+ public static final int t_Bool = t_bool;
/**
- * Set long long to be 'value'.
- *
- * @param value
- * boolean
- */
- public void setLongLong(boolean value);
-
- /**
- * @since 5.1
+ * @deprecated All constants must be defined in {@link IASTSimpleDeclSpecifier}.
*/
- public ICASTSimpleDeclSpecifier copy();
-
+ @Deprecated
+ public static final int t_last = t_Bool;
}
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/c/ICNodeFactory.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/c/ICNodeFactory.java
index 18bba753564..7886253a5a1 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/c/ICNodeFactory.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/c/ICNodeFactory.java
@@ -1,12 +1,13 @@
/*******************************************************************************
- * Copyright (c) 2006, 2009 IBM Corporation and others.
+ * Copyright (c) 2006, 2010 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
- * IBM Corporation - initial API and implementation
+ * Mike Kucera (IBM Corporation) - initial API and implementation
+ * Markus Schorn (Wind River Systems)
*******************************************************************************/
package org.eclipse.cdt.core.dom.ast.c;
@@ -18,12 +19,10 @@ import org.eclipse.cdt.core.dom.ast.IASTTypeId;
import org.eclipse.cdt.core.dom.ast.INodeFactory;
import org.eclipse.cdt.core.dom.ast.gnu.c.ICASTKnRFunctionDeclarator;
import org.eclipse.cdt.core.dom.ast.gnu.c.IGCCASTArrayRangeDesignator;
-import org.eclipse.cdt.core.dom.ast.gnu.c.IGCCASTSimpleDeclSpecifier;
/**
* Factory for AST nodes for the C programming language.
*
- * @author Mike Kucera
* @since 5.1
*
* @noextend This interface is not intended to be extended by clients.
@@ -57,5 +56,9 @@ public interface ICNodeFactory extends INodeFactory {
public IGCCASTArrayRangeDesignator newArrayRangeDesignatorGCC(IASTExpression floor, IASTExpression ceiling);
- public IGCCASTSimpleDeclSpecifier newSimpleDeclSpecifierGCC(IASTExpression typeofExpression);
+ /**
+ * @deprecated Replaced by {@link #newSimpleDeclSpecifier()}
+ */
+ @Deprecated
+ public org.eclipse.cdt.core.dom.ast.gnu.c.IGCCASTSimpleDeclSpecifier newSimpleDeclSpecifierGCC(IASTExpression typeofExpression);
} \ No newline at end of file
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPASTDeclSpecifier.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPASTDeclSpecifier.java
index 06296c18c20..24d9a75dbed 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPASTDeclSpecifier.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPASTDeclSpecifier.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2004, 2009 IBM Corporation and others.
+ * Copyright (c) 2004, 2010 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -7,6 +7,7 @@
*
* Contributors:
* Doug Schaefer (IBM) - Initial API and implementation
+ * Markus Schorn (Wind River Systems)
*******************************************************************************/
package org.eclipse.cdt.core.dom.ast.cpp;
@@ -20,17 +21,6 @@ import org.eclipse.cdt.core.dom.ast.IASTDeclSpecifier;
*/
public interface ICPPASTDeclSpecifier extends IASTDeclSpecifier {
- // Extra storage class in C++
- /**
- * <code>sc_mutable</code> represents a mutable storage representation.
- */
- public static final int sc_mutable = IASTDeclSpecifier.sc_last + 1;
-
- /**
- * <code>sc_last</code> is overwritten to allow extensibility.
- */
- public static final int sc_last = sc_mutable;
-
// A declaration in C++ can be a friend declaration
/**
* Is this a friend declaration?
@@ -81,5 +71,10 @@ public interface ICPPASTDeclSpecifier extends IASTDeclSpecifier {
* @since 5.1
*/
public ICPPASTDeclSpecifier copy();
-
+
+ /**
+ * @deprecated All constants must be defined in {@link IASTDeclSpecifier}
+ */
+ @Deprecated
+ public static final int sc_last = sc_mutable;
}
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPASTSimpleDeclSpecifier.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPASTSimpleDeclSpecifier.java
index 9e826baef1e..4721096c9b1 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPASTSimpleDeclSpecifier.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPASTSimpleDeclSpecifier.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2004, 2009 IBM Corporation and others.
+ * Copyright (c) 2004, 2010 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -7,6 +7,7 @@
*
* Contributors:
* Doug Schaefer (IBM) - Initial API and implementation
+ * Markus Schorn (Wind River Systems)
*******************************************************************************/
package org.eclipse.cdt.core.dom.ast.cpp;
@@ -18,27 +19,15 @@ import org.eclipse.cdt.core.dom.ast.IASTSimpleDeclSpecifier;
* @noextend This interface is not intended to be extended by clients.
* @noimplement This interface is not intended to be implemented by clients.
*/
-public interface ICPPASTSimpleDeclSpecifier extends IASTSimpleDeclSpecifier,
- ICPPASTDeclSpecifier {
- // Extra types
+public interface ICPPASTSimpleDeclSpecifier extends IASTSimpleDeclSpecifier, ICPPASTDeclSpecifier {
/**
- * <code>t_bool</code> bool
- */
- public static final int t_bool = IASTSimpleDeclSpecifier.t_last + 1;
-
- /**
- * <code>t_wchar_t</code> wchar_t
+ * @since 5.1
*/
- public static final int t_wchar_t = IASTSimpleDeclSpecifier.t_last + 2;
+ public ICPPASTSimpleDeclSpecifier copy();
/**
- * <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_wchar_t;
-
- /**
- * @since 5.1
- */
- public ICPPASTSimpleDeclSpecifier copy();
-
}
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPNodeFactory.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPNodeFactory.java
index cc152fa2e22..bec59a78f4c 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPNodeFactory.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPNodeFactory.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2006, 2009 IBM Corporation and others.
+ * Copyright (c) 2006, 2010 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -26,7 +26,6 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTCompositeTypeSpecifier.ICPPASTBas
import org.eclipse.cdt.core.dom.ast.gnu.cpp.IGPPASTExplicitTemplateInstantiation;
import org.eclipse.cdt.core.dom.ast.gnu.cpp.IGPPASTPointer;
import org.eclipse.cdt.core.dom.ast.gnu.cpp.IGPPASTPointerToMember;
-import org.eclipse.cdt.core.dom.ast.gnu.cpp.IGPPASTSimpleDeclSpecifier;
import org.eclipse.cdt.core.parser.IScanner;
/**
@@ -127,8 +126,6 @@ public interface ICPPNodeFactory extends INodeFactory {
public ICPPASTDeleteExpression newDeleteExpression(IASTExpression operand);
- public IGPPASTSimpleDeclSpecifier newSimpleDeclSpecifierGPP();
-
public ICPPASTSimpleTypeConstructorExpression newSimpleTypeConstructorExpression(int type, IASTExpression expression);
public ICPPASTTypenameExpression newTypenameExpression(IASTName qualifiedName, IASTExpression expr, boolean isTemplate);
@@ -225,4 +222,9 @@ public interface ICPPNodeFactory extends INodeFactory {
*/
@Deprecated
public ICPPASTTranslationUnit newTranslationUnit();
+ /**
+ * @deprecated Replaced by {@link #newSimpleDeclSpecifier()}
+ */
+ @Deprecated
+ public org.eclipse.cdt.core.dom.ast.gnu.cpp.IGPPASTSimpleDeclSpecifier newSimpleDeclSpecifierGPP();
}
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/gnu/IGNUASTUnaryExpression.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/gnu/IGNUASTUnaryExpression.java
index 1adb02fa4b3..9e372d78c99 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/gnu/IGNUASTUnaryExpression.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/gnu/IGNUASTUnaryExpression.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2005, 2009 IBM Corporation and others.
+ * Copyright (c) 2005, 2010 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -13,33 +13,12 @@ package org.eclipse.cdt.core.dom.ast.gnu;
import org.eclipse.cdt.core.dom.ast.IASTUnaryExpression;
/**
- * There are GNU language extensions that apply to both GCC and G++. Unary
- * expressions for _alignOf() and typeof() along the lines of sizeof().
- *
- * @noextend This interface is not intended to be extended by clients.
- * @noimplement This interface is not intended to be implemented by clients.
+ * @deprecated Replaced by {@link IASTUnaryExpression}.
*/
+@Deprecated
public interface IGNUASTUnaryExpression extends IASTUnaryExpression {
/**
- * <code>op_typeof</code> is used for typeof( unaryExpression ) type
- * expressions.
- */
- public static final int op_typeof = IASTUnaryExpression.op_typeof;
-
- /**
- * <code>op_alignOf</code> is used for __alignOf( unaryExpression ) type
- * expressions.
- */
- public static final int op_alignOf = IASTUnaryExpression.op_alignOf;
-
- /**
- * @deprecated all constants to be defined in {@link IASTUnaryExpression}.
- */
- @Deprecated
- public static final int op_last = IASTUnaryExpression.op_last;
-
- /**
* @since 5.1
*/
public IGNUASTUnaryExpression copy();
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/gnu/c/IGCCASTSimpleDeclSpecifier.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/gnu/c/IGCCASTSimpleDeclSpecifier.java
index 4c1367e9945..0391f619b36 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/gnu/c/IGCCASTSimpleDeclSpecifier.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/gnu/c/IGCCASTSimpleDeclSpecifier.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2005, 2009 IBM Corporation and others.
+ * Copyright (c) 2005, 2010 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -12,44 +12,46 @@ package org.eclipse.cdt.core.dom.ast.gnu.c;
import org.eclipse.cdt.core.dom.ast.ASTNodeProperty;
import org.eclipse.cdt.core.dom.ast.IASTExpression;
+import org.eclipse.cdt.core.dom.ast.IASTSimpleDeclSpecifier;
import org.eclipse.cdt.core.dom.ast.c.ICASTSimpleDeclSpecifier;
/**
* @noextend This interface is not intended to be extended by clients.
* @noimplement This interface is not intended to be implemented by clients.
+ * @deprecated Everything can be expressed as {@link ICASTSimpleDeclSpecifier}.
*/
+@Deprecated
public interface IGCCASTSimpleDeclSpecifier extends ICASTSimpleDeclSpecifier {
/**
- * <code>t_typeof</code> represents a typeof() expression type.
+ * @deprecated Replaced by {@link IASTSimpleDeclSpecifier#t_typeof}.
*/
+ @Deprecated
public static final int t_typeof = ICASTSimpleDeclSpecifier.t_last + 1;
/**
- * <code>t_last</code> is specified for subinterfaces.
+ * @deprecated All constants must be defined in {@link IASTSimpleDeclSpecifier}.
*/
+ @Deprecated
public static final int t_last = t_typeof;
/**
- * <code>TYPEOF_EXPRESSION</code> represents the relationship between the
- * decl spec & the expression for typeof().
+ * @deprecated Replaced by {@link IASTSimpleDeclSpecifier#DECLTYPE_EXPRESSION}.
*/
+ @Deprecated
public static final ASTNodeProperty TYPEOF_EXPRESSION = new ASTNodeProperty(
"IGCCASTSimpleDeclSpecifier.TYPEOF_EXPRESSION - typeof() Expression"); //$NON-NLS-1$
/**
- * Set the typeof() expression.
- *
- * @param typeofExpression
- * <code>IASTExpression</code>
+ * @deprecated Replaced by {@link IASTSimpleDeclSpecifier#setDeclTypeExpression(IASTExpression)}.
*/
+ @Deprecated
public void setTypeofExpression(IASTExpression typeofExpression);
/**
- * Get the typeof expression.
- *
- * @return <code>IASTExpression</code>
+ * @deprecated Replaced by {@link IASTSimpleDeclSpecifier#getDeclTypeExpression()}.
*/
+ @Deprecated
public IASTExpression getTypeofExpression();
/**
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/gnu/cpp/IGPPASTDeclSpecifier.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/gnu/cpp/IGPPASTDeclSpecifier.java
index ccd12df6d49..f95edf9008a 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/gnu/cpp/IGPPASTDeclSpecifier.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/gnu/cpp/IGPPASTDeclSpecifier.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2004, 2009 IBM Corporation and others.
+ * Copyright (c) 2004, 2010 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -17,25 +17,12 @@ import org.eclipse.cdt.core.dom.ast.IASTDeclSpecifier;
*
* @noextend This interface is not intended to be extended by clients.
* @noimplement This interface is not intended to be implemented by clients.
+ * @deprecated Replaced by {@link IASTDeclSpecifier}.
*/
+@Deprecated
public interface IGPPASTDeclSpecifier extends IASTDeclSpecifier {
/**
- * Was restrict keyword encountered?
- *
- * @return boolean
- */
- public boolean isRestrict();
-
- /**
- * Set restrict-modifier-encountered to value.
- *
- * @param value
- * boolean
- */
- public void setRestrict(boolean value);
-
- /**
* @since 5.1
*/
public IGPPASTDeclSpecifier copy();
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/gnu/cpp/IGPPASTSimpleDeclSpecifier.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/gnu/cpp/IGPPASTSimpleDeclSpecifier.java
index 4e914c4648b..3db6a29fe56 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/gnu/cpp/IGPPASTSimpleDeclSpecifier.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/gnu/cpp/IGPPASTSimpleDeclSpecifier.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2004, 2009 IBM Corporation and others.
+ * Copyright (c) 2004, 2010 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -12,6 +12,7 @@ package org.eclipse.cdt.core.dom.ast.gnu.cpp;
import org.eclipse.cdt.core.dom.ast.ASTNodeProperty;
import org.eclipse.cdt.core.dom.ast.IASTExpression;
+import org.eclipse.cdt.core.dom.ast.IASTSimpleDeclSpecifier;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTSimpleDeclSpecifier;
/**
@@ -19,83 +20,38 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTSimpleDeclSpecifier;
*
* @noextend This interface is not intended to be extended by clients.
* @noimplement This interface is not intended to be implemented by clients.
+ * @deprecated Replaced by {@link ICPPASTSimpleDeclSpecifier}.
*/
+@Deprecated
public interface IGPPASTSimpleDeclSpecifier extends IGPPASTDeclSpecifier, ICPPASTSimpleDeclSpecifier {
-
/**
- * <code>t_typeof</code> represents a typeof() expression type.
+ * @deprecated Replaced by {@link ICPPASTSimpleDeclSpecifier#setDeclTypeExpression(IASTExpression)}.
*/
- public static final int t_typeof = ICPPASTSimpleDeclSpecifier.t_last + 1;
+ @Deprecated
+ public void setTypeofExpression(IASTExpression typeofExpression);
/**
- * <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
+ * @deprecated Replaced by {@link ICPPASTSimpleDeclSpecifier#getDeclTypeExpression()}.
*/
- public void setComplex(boolean value);
+ @Deprecated
+ public IASTExpression getTypeofExpression();
/**
- * Is imaginary number? e.g. _Imaginr
- * @return true if it is an imaginary number, false otherwise
+ * @since 5.1
*/
- public boolean isImaginary();
-
+ public IGPPASTSimpleDeclSpecifier copy();
+
/**
- * Set the number to be imaginary.
- * @param value true if it is an imaginary number, false otherwise
+ * @deprecated All constants must be defined in {@link IASTSimpleDeclSpecifier}.
*/
- public void setImaginary(boolean value);
+ @Deprecated
+ public static final int t_last = t_typeof;
/**
- * <code>TYPEOF_EXPRESSION</code> represents the relationship between the
- * decl spec & the expression for typeof().
+ * @deprecated Replaced by {@link ICPPASTSimpleDeclSpecifier#DECLTYPE_EXPRESSION}.
*/
+ @Deprecated
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>
- */
- public void setTypeofExpression(IASTExpression typeofExpression);
-
- /**
- * Get the typeof expression.
- *
- * @return <code>IASTExpression</code>
- */
- public IASTExpression getTypeofExpression();
-
- /**
- * @since 5.1
- */
- public IGPPASTSimpleDeclSpecifier copy();
-
}
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/IToken.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/IToken.java
index 1add0589502..102819b8848 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/IToken.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/IToken.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2002, 2009 IBM Corporation and others.
+ * Copyright (c) 2002, 2010 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -11,7 +11,6 @@
*******************************************************************************/
package org.eclipse.cdt.core.parser;
-
/**
* @noextend This interface is not intended to be extended by clients.
* @noimplement This interface is not intended to be implemented by clients.
@@ -93,7 +92,7 @@ public interface IToken {
* @see IScanner#setSplitShiftROperator(boolean)
* @since 5.2
*/
- int tGT_in_SHIFTR= 53;
+ int tGT_in_SHIFTR= 5200;
/** @deprecated use {@link #tAND} */ @Deprecated int t_and = 54;
/** @deprecated use {@link #tAMPERASSIGN} */ @Deprecated int t_and_eq = 55;
@@ -113,6 +112,7 @@ public interface IToken {
int t_const_cast = 69;
int t_continue = 70;
+ /** @since 5.2 */ int t_decltype= 5201;
int t_default = 71;
int t_delete = 72;
int t_do = 73;
@@ -149,7 +149,7 @@ public interface IToken {
int t_short = 104;
int t_sizeof = 105;
int t_static = 106;
- /** @since 5.2 */ int t_static_assert = 5010;
+ /** @since 5.2 */ int t_static_assert = 5202;
int t_static_cast = 107;
int t_signed = 108;
int t_struct = 109;
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/Keywords.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/Keywords.java
index 7411c46bf0f..bb6d4fbd789 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/Keywords.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/Keywords.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2002, 2009 IBM Corporation and others.
+ * Copyright (c) 2002, 2010 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -43,6 +43,8 @@ public class Keywords {
public static final String CONST = "const"; //$NON-NLS-1$
public static final String CONST_CAST = "const_cast"; //$NON-NLS-1$
public static final String CONTINUE = "continue"; //$NON-NLS-1$
+ /** @since 5.2 */
+ public static final String DECLTYPE = "decltype"; //$NON-NLS-1$
public static final String DEFAULT = "default"; //$NON-NLS-1$
public static final String DELETE = "delete"; //$NON-NLS-1$
public static final String DO = "do"; //$NON-NLS-1$
@@ -127,6 +129,8 @@ public class Keywords {
public static final char[] cCONST_CAST = "const_cast".toCharArray(); //$NON-NLS-1$
public static final char[] cCONTINUE = "continue".toCharArray(); //$NON-NLS-1$
public static final char[] cDEFAULT = "default".toCharArray(); //$NON-NLS-1$
+ /** @since 5.2 */
+ public static final char[] cDECLTYPE = DECLTYPE.toCharArray();
public static final char[] cDELETE = "delete".toCharArray(); //$NON-NLS-1$
public static final char[] cDO = "do".toCharArray(); //$NON-NLS-1$
public static final char[] cDOUBLE = "double".toCharArray(); //$NON-NLS-1$
@@ -165,7 +169,7 @@ public class Keywords {
public static final char[] cSIZEOF = "sizeof".toCharArray(); //$NON-NLS-1$
public static final char[] cSTATIC = "static".toCharArray(); //$NON-NLS-1$
/** @since 5.2 */
- public static final char[] cSTATIC_ASSERT = "static_assert".toCharArray(); //$NON-NLS-1$
+ public static final char[] cSTATIC_ASSERT = STATIC_ASSERT.toCharArray();
public static final char[] cSTATIC_CAST = "static_cast".toCharArray(); //$NON-NLS-1$
public static final char[] cSTRUCT = "struct".toCharArray(); //$NON-NLS-1$
public static final char[] cSWITCH = "switch".toCharArray(); //$NON-NLS-1$
@@ -329,6 +333,7 @@ public class Keywords {
cppkeywords.put(Keywords.cCATCH, IToken.t_catch);
cppkeywords.put(Keywords.cCLASS, IToken.t_class);
cppkeywords.put(Keywords.cCONST_CAST, IToken.t_const_cast);
+ cppkeywords.put(Keywords.cDECLTYPE, IToken.t_decltype);
cppkeywords.put(Keywords.cDELETE, IToken.t_delete);
cppkeywords.put(Keywords.cDYNAMIC_CAST, IToken.t_dynamic_cast);
cppkeywords.put(Keywords.cEXPLICIT, IToken.t_explicit);
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/AbstractGNUSourceCodeParser.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/AbstractGNUSourceCodeParser.java
index ba03031274d..70b0d5b8fe0 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/AbstractGNUSourceCodeParser.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/AbstractGNUSourceCodeParser.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2005, 2009 IBM Corporation and others.
+ * Copyright (c) 2005, 2010 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -2104,7 +2104,7 @@ public abstract class AbstractGNUSourceCodeParser implements ISourceCodeParser {
}
protected IASTStatement parseDefaultStatement() throws EndOfFileException, BacktrackException {
- int startOffset = consume().getOffset(); // t_default
+ int startOffset = consume(IToken.t_default).getOffset();
int lastOffset = consume(IToken.tCOLON).getEndOffset();
IASTDefaultStatement df = nodeFactory.newDefaultStatement();
@@ -2243,7 +2243,7 @@ public abstract class AbstractGNUSourceCodeParser implements ISourceCodeParser {
return result1;
}
- IASTExpression result2= buildUnaryExpression(unaryExprKind, expr, offset, endOffset2);
+ IASTExpression result2= unaryExprKind == -1 ? expr : buildUnaryExpression(unaryExprKind, expr, offset, endOffset2);
if (ca != null)
result2= ca.updateExpression(result2);
@@ -2444,6 +2444,7 @@ public abstract class AbstractGNUSourceCodeParser implements ISourceCodeParser {
case IToken.t__Imaginary:
case IToken.t_signed:
case IToken.t_unsigned:
+ case IToken.t_decltype:
// class-specifier:
case IToken.t_class:
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/VariableReadWriteFlags.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/VariableReadWriteFlags.java
index 3e80a5e342f..88ac199cb3e 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/VariableReadWriteFlags.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/VariableReadWriteFlags.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2007, 2009 Wind River Systems, Inc. and others.
+ * Copyright (c) 2007, 2010 Wind River Systems, Inc. and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -43,7 +43,6 @@ import org.eclipse.cdt.core.dom.ast.IFunctionType;
import org.eclipse.cdt.core.dom.ast.IType;
import org.eclipse.cdt.core.dom.ast.IVariable;
import org.eclipse.cdt.core.dom.ast.gnu.IGNUASTCompoundStatementExpression;
-import org.eclipse.cdt.core.dom.ast.gnu.IGNUASTUnaryExpression;
import org.eclipse.cdt.internal.core.pdom.dom.PDOMName;
/**
@@ -260,8 +259,7 @@ public abstract class VariableReadWriteFlags {
case IASTUnaryExpression.op_sizeof:
case IASTUnaryExpression.op_sizeofParameterPack:
- case IGNUASTUnaryExpression.op_alignOf:
- case IGNUASTUnaryExpression.op_typeof:
+ case IASTUnaryExpression.op_alignOf:
return 0;
}
return READ;
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTSimpleDeclSpecifier.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTSimpleDeclSpecifier.java
index 89bad1ab150..269b383f89d 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTSimpleDeclSpecifier.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTSimpleDeclSpecifier.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2005, 2009 IBM Corporation and others.
+ * Copyright (c) 2005, 2010 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -13,10 +13,14 @@
package org.eclipse.cdt.internal.core.dom.parser.c;
import org.eclipse.cdt.core.dom.ast.ASTVisitor;
+import org.eclipse.cdt.core.dom.ast.IASTExpression;
+import org.eclipse.cdt.core.dom.ast.IASTNode;
import org.eclipse.cdt.core.dom.ast.IBasicType.Kind;
import org.eclipse.cdt.core.dom.ast.c.ICASTSimpleDeclSpecifier;
+import org.eclipse.cdt.internal.core.dom.parser.IASTAmbiguityParent;
-public class CASTSimpleDeclSpecifier extends CASTBaseDeclSpecifier implements ICASTSimpleDeclSpecifier {
+public class CASTSimpleDeclSpecifier extends CASTBaseDeclSpecifier implements ICASTSimpleDeclSpecifier,
+ IASTAmbiguityParent {
private int simpleType;
private boolean isSigned;
@@ -26,6 +30,7 @@ public class CASTSimpleDeclSpecifier extends CASTBaseDeclSpecifier implements IC
private boolean longlong;
private boolean complex=false;
private boolean imaginary=false;
+ private IASTExpression fDeclTypeExpression;
public CASTSimpleDeclSpecifier copy() {
CASTSimpleDeclSpecifier copy = new CASTSimpleDeclSpecifier();
@@ -43,9 +48,10 @@ public class CASTSimpleDeclSpecifier extends CASTBaseDeclSpecifier implements IC
copy.longlong = longlong;
copy.complex = complex;
copy.imaginary = imaginary;
+ if (fDeclTypeExpression != null)
+ copy.setDeclTypeExpression(fDeclTypeExpression.copy());
}
-
public int getType() {
return simpleType;
}
@@ -78,7 +84,7 @@ public class CASTSimpleDeclSpecifier extends CASTBaseDeclSpecifier implements IC
private int getType(Kind kind) {
switch(kind) {
case eBoolean:
- return t_Bool;
+ return t_bool;
case eChar:
case eWChar:
return t_char;
@@ -134,6 +140,10 @@ public class CASTSimpleDeclSpecifier extends CASTBaseDeclSpecifier implements IC
default : break;
}
}
+
+ if (fDeclTypeExpression != null && !fDeclTypeExpression.accept(action))
+ return false;
+
if( action.shouldVisitDeclSpecifiers ){
switch( action.leave( this ) ){
case ASTVisitor.PROCESS_ABORT : return false;
@@ -161,4 +171,25 @@ public class CASTSimpleDeclSpecifier extends CASTBaseDeclSpecifier implements IC
assertNotFrozen();
this.imaginary = value;
}
+
+ public IASTExpression getDeclTypeExpression() {
+ return fDeclTypeExpression;
+ }
+
+ public void setDeclTypeExpression(IASTExpression expression) {
+ assertNotFrozen();
+ fDeclTypeExpression= expression;
+ if (expression != null) {
+ expression.setPropertyInParent(DECLTYPE_EXPRESSION);
+ expression.setParent(this);
+ }
+ }
+
+ public void replace(IASTNode child, IASTNode other) {
+ if (child == fDeclTypeExpression) {
+ other.setPropertyInParent(child.getPropertyInParent());
+ other.setParent(child.getParent());
+ fDeclTypeExpression= (IASTExpression) other;
+ }
+ }
}
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CNodeFactory.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CNodeFactory.java
index de7c37d7d38..6a952ec16cc 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CNodeFactory.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CNodeFactory.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2006, 2009 IBM Corporation and others.
+ * Copyright (c) 2006, 2010 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -77,7 +77,6 @@ import org.eclipse.cdt.core.dom.ast.c.ICNodeFactory;
import org.eclipse.cdt.core.dom.ast.gnu.IGNUASTCompoundStatementExpression;
import org.eclipse.cdt.core.dom.ast.gnu.c.ICASTKnRFunctionDeclarator;
import org.eclipse.cdt.core.dom.ast.gnu.c.IGCCASTArrayRangeDesignator;
-import org.eclipse.cdt.core.dom.ast.gnu.c.IGCCASTSimpleDeclSpecifier;
import org.eclipse.cdt.core.parser.IScanner;
import org.eclipse.cdt.internal.core.dom.parser.NodeFactory;
@@ -349,7 +348,8 @@ public class CNodeFactory extends NodeFactory implements ICNodeFactory {
return new CASTArrayRangeDesignator(floor, ceiling);
}
- public IGCCASTSimpleDeclSpecifier newSimpleDeclSpecifierGCC(IASTExpression typeofExpression) {
+ @Deprecated
+ public org.eclipse.cdt.core.dom.ast.gnu.c.IGCCASTSimpleDeclSpecifier newSimpleDeclSpecifierGCC(IASTExpression typeofExpression) {
return new GCCASTSimpleDeclSpecifier(typeofExpression);
}
}
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CScope.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CScope.java
index b9bdc9d6b16..48cc051427d 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CScope.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CScope.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2004, 2009 IBM Corporation and others.
+ * Copyright (c) 2004, 2010 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -34,12 +34,12 @@ import org.eclipse.cdt.core.dom.ast.IASTName;
import org.eclipse.cdt.core.dom.ast.IASTNamedTypeSpecifier;
import org.eclipse.cdt.core.dom.ast.IASTNode;
import org.eclipse.cdt.core.dom.ast.IASTParameterDeclaration;
+import org.eclipse.cdt.core.dom.ast.IASTSimpleDeclSpecifier;
import org.eclipse.cdt.core.dom.ast.IASTSimpleDeclaration;
import org.eclipse.cdt.core.dom.ast.IASTStandardFunctionDeclarator;
import org.eclipse.cdt.core.dom.ast.IASTStatement;
import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit;
import org.eclipse.cdt.core.dom.ast.IASTTypeIdExpression;
-import org.eclipse.cdt.core.dom.ast.IASTUnaryExpression;
import org.eclipse.cdt.core.dom.ast.IBinding;
import org.eclipse.cdt.core.dom.ast.ICompositeType;
import org.eclipse.cdt.core.dom.ast.IEnumeration;
@@ -50,7 +50,6 @@ import org.eclipse.cdt.core.dom.ast.c.ICASTCompositeTypeSpecifier;
import org.eclipse.cdt.core.dom.ast.c.ICASTElaboratedTypeSpecifier;
import org.eclipse.cdt.core.dom.ast.c.ICASTEnumerationSpecifier;
import org.eclipse.cdt.core.dom.ast.c.ICScope;
-import org.eclipse.cdt.core.dom.ast.gnu.IGNUASTUnaryExpression;
import org.eclipse.cdt.core.dom.ast.gnu.c.ICASTKnRFunctionDeclarator;
import org.eclipse.cdt.core.index.IIndex;
import org.eclipse.cdt.core.index.IIndexFileSet;
@@ -306,8 +305,8 @@ public class CScope implements ICScope, IASTInternalScope {
}
IASTNode parent= name.getParent();
while (parent != null) {
- if (parent instanceof IASTUnaryExpression) {
- if (((IASTUnaryExpression) parent).getOperator() == IGNUASTUnaryExpression.op_typeof)
+ if (parent instanceof IASTSimpleDeclSpecifier) {
+ if (((IASTSimpleDeclSpecifier) parent).getDeclTypeExpression() != null)
return false;
}
else if (parent instanceof IASTTypeIdExpression) {
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CVisitor.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CVisitor.java
index bbbeaef1486..2e78f81f1e0 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CVisitor.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CVisitor.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2005, 2009 IBM Corporation and others.
+ * Copyright (c) 2005, 2010 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -83,7 +83,6 @@ import org.eclipse.cdt.core.dom.ast.c.ICArrayType;
import org.eclipse.cdt.core.dom.ast.c.ICCompositeTypeScope;
import org.eclipse.cdt.core.dom.ast.c.ICFunctionScope;
import org.eclipse.cdt.core.dom.ast.gnu.c.ICASTKnRFunctionDeclarator;
-import org.eclipse.cdt.core.dom.ast.gnu.c.IGCCASTSimpleDeclSpecifier;
import org.eclipse.cdt.core.index.IIndexBinding;
import org.eclipse.cdt.core.index.IIndexFileSet;
import org.eclipse.cdt.core.parser.util.ArrayUtil;
@@ -1332,13 +1331,12 @@ public class CVisitor extends ASTQueries {
* @return the base IType
*/
public static IType createBaseType(IASTDeclSpecifier declSpec) {
- if (declSpec instanceof IGCCASTSimpleDeclSpecifier) {
- IASTExpression exp = ((IGCCASTSimpleDeclSpecifier)declSpec).getTypeofExpression();
+ if (declSpec instanceof ICASTSimpleDeclSpecifier) {
+ final ICASTSimpleDeclSpecifier sds = (ICASTSimpleDeclSpecifier)declSpec;
+ IASTExpression exp = sds.getDeclTypeExpression();
if (exp != null)
return exp.getExpressionType();
- return new CBasicType((ICASTSimpleDeclSpecifier) declSpec);
- } else if (declSpec instanceof ICASTSimpleDeclSpecifier) {
- return new CBasicType((ICASTSimpleDeclSpecifier)declSpec);
+ return new CBasicType(sds);
}
IBinding binding = null;
IASTName name = null;
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/GCCASTSimpleDeclSpecifier.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/GCCASTSimpleDeclSpecifier.java
index f1977c8de6d..be7031e023e 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/GCCASTSimpleDeclSpecifier.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/GCCASTSimpleDeclSpecifier.java
@@ -1,33 +1,28 @@
/*******************************************************************************
- * Copyright (c) 2005, 2008 IBM Corporation and others.
+ * Copyright (c) 2005, 2010 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
- * IBM Corporation - initial API and implementation
+ * Andrew Niefer (IBM Corporation) - initial API and implementation
* Emanuel Graf IFS - Bugfix for #198257
*******************************************************************************/
package org.eclipse.cdt.internal.core.dom.parser.c;
-import org.eclipse.cdt.core.dom.ast.ASTVisitor;
import org.eclipse.cdt.core.dom.ast.IASTExpression;
-import org.eclipse.cdt.core.dom.ast.IASTNode;
import org.eclipse.cdt.core.dom.ast.gnu.c.IGCCASTSimpleDeclSpecifier;
-import org.eclipse.cdt.internal.core.dom.parser.IASTAmbiguityParent;
/**
- * @author aniefer
- *
+ * @deprecated Replaced by {@link CASTSimpleDeclSpecifier}.
*/
-public class GCCASTSimpleDeclSpecifier extends CASTSimpleDeclSpecifier implements IGCCASTSimpleDeclSpecifier, IASTAmbiguityParent {
-
- private IASTExpression typeOfExpression;
+@Deprecated
+public class GCCASTSimpleDeclSpecifier extends CASTSimpleDeclSpecifier implements IGCCASTSimpleDeclSpecifier {
public GCCASTSimpleDeclSpecifier() {
}
-
+
public GCCASTSimpleDeclSpecifier(IASTExpression typeofExpression) {
setTypeofExpression(typeofExpression);
}
@@ -36,50 +31,14 @@ public class GCCASTSimpleDeclSpecifier extends CASTSimpleDeclSpecifier implement
public GCCASTSimpleDeclSpecifier copy() {
GCCASTSimpleDeclSpecifier copy = new GCCASTSimpleDeclSpecifier();
copySimpleDeclSpec(copy);
- copy.setTypeofExpression(typeOfExpression == null ? null : typeOfExpression.copy());
return copy;
}
-
- public void setTypeofExpression(IASTExpression typeofExpression) {
- this.typeOfExpression = typeofExpression;
- if (typeofExpression != null) {
- typeofExpression.setParent(this);
- typeofExpression.setPropertyInParent(TYPEOF_EXPRESSION);
- }
- }
- public IASTExpression getTypeofExpression() {
- return typeOfExpression;
+ public void setTypeofExpression(IASTExpression expr) {
+ setDeclTypeExpression(expr);
}
- @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;
- }
+ public IASTExpression getTypeofExpression() {
+ return getDeclTypeExpression();
}
}
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/GNUCSourceParser.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/GNUCSourceParser.java
index 7c2c647b234..8d19058bba6 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/GNUCSourceParser.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/GNUCSourceParser.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2005, 2009 IBM Corporation and others.
+ * Copyright (c) 2005, 2010 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -71,7 +71,6 @@ import org.eclipse.cdt.core.dom.ast.c.ICASTSimpleDeclSpecifier;
import org.eclipse.cdt.core.dom.ast.c.ICASTTypedefNameSpecifier;
import org.eclipse.cdt.core.dom.ast.c.ICNodeFactory;
import org.eclipse.cdt.core.dom.ast.gnu.IGNUASTTypeIdExpression;
-import org.eclipse.cdt.core.dom.ast.gnu.IGNUASTUnaryExpression;
import org.eclipse.cdt.core.dom.ast.gnu.c.ICASTKnRFunctionDeclarator;
import org.eclipse.cdt.core.dom.ast.gnu.c.IGCCASTArrayRangeDesignator;
import org.eclipse.cdt.core.dom.parser.IExtensionToken;
@@ -589,9 +588,6 @@ public class GNUCSourceParser extends AbstractGNUSourceCodeParser {
case IToken.t_sizeof:
return parseTypeidInParenthesisOrUnaryExpression(false, consume().getOffset(),
IASTTypeIdExpression.op_sizeof, IASTUnaryExpression.op_sizeof, ctx);
- case IGCCToken.t_typeof:
- return parseTypeidInParenthesisOrUnaryExpression(false, consume().getOffset(),
- IASTTypeIdExpression.op_typeof, IASTUnaryExpression.op_typeof, ctx);
case IGCCToken.t___alignof__:
return parseTypeidInParenthesisOrUnaryExpression(false, consume().getOffset(),
IASTTypeIdExpression.op_alignof, IASTUnaryExpression.op_alignOf, ctx);
@@ -1004,7 +1000,7 @@ public class GNUCSourceParser extends AbstractGNUSourceCodeParser {
case IToken.t__Bool:
if (encounteredTypename)
break declSpecifiers;
- simpleType = ICASTSimpleDeclSpecifier.t_Bool;
+ simpleType = IASTSimpleDeclSpecifier.t_bool;
encounteredRawType= true;
endOffset= consume().getEndOffset();
break;
@@ -1081,8 +1077,10 @@ public class GNUCSourceParser extends AbstractGNUSourceCodeParser {
if (encounteredRawType || encounteredTypename)
throwBacktrack(LA(1));
- typeofExpression = parseTypeidInParenthesisOrUnaryExpression(false, consume().getOffset(),
- IGNUASTTypeIdExpression.op_typeof, IGNUASTUnaryExpression.op_typeof, CastExprCtx.eNotBExpr);
+ simpleType= IASTSimpleDeclSpecifier.t_typeof;
+ consume(IGCCToken.t_typeof);
+ typeofExpression = parseTypeidInParenthesisOrUnaryExpression(false, LA(1).getOffset(),
+ IGNUASTTypeIdExpression.op_typeof, -1, CastExprCtx.eNotBExpr);
encounteredTypename= true;
endOffset= calculateEndOffset(typeofExpression);
@@ -1155,11 +1153,7 @@ public class GNUCSourceParser extends AbstractGNUSourceCodeParser {
private ICASTSimpleDeclSpecifier buildSimpleDeclSpec(int storageClass, int simpleType,
int options, int isLong, IASTExpression typeofExpression, int offset, int endOffset) {
- ICASTSimpleDeclSpecifier declSpec;
- if (typeofExpression != null)
- declSpec = nodeFactory.newSimpleDeclSpecifierGCC(typeofExpression);
- else
- declSpec = nodeFactory.newSimpleDeclSpecifier();
+ ICASTSimpleDeclSpecifier declSpec= nodeFactory.newSimpleDeclSpecifier();
configureDeclSpec(declSpec, storageClass, options);
declSpec.setType(simpleType);
@@ -1171,6 +1165,10 @@ public class GNUCSourceParser extends AbstractGNUSourceCodeParser {
declSpec.setShort((options & SHORT) != 0);
declSpec.setComplex((options & COMPLEX) != 0);
declSpec.setImaginary((options & IMAGINARY) != 0);
+ if (typeofExpression != null) {
+ declSpec.setDeclTypeExpression(typeofExpression);
+ typeofExpression.setParent(declSpec);
+ }
((ASTNode) declSpec).setOffsetAndLength(offset, endOffset - offset);
return declSpec;
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTBaseDeclSpecifier.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTBaseDeclSpecifier.java
index f1cbae94fe5..ed5d0f52881 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTBaseDeclSpecifier.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTBaseDeclSpecifier.java
@@ -1,12 +1,13 @@
/*******************************************************************************
- * Copyright (c) 2004, 2008 IBM Corporation and others.
+ * Copyright (c) 2004, 2010 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
- * IBM - Initial API and implementation
+ * John Camelon (IBM) - Initial API and implementation
+ * Markus Schorn (Wind River Systems)
*******************************************************************************/
package org.eclipse.cdt.internal.core.dom.parser.cpp;
@@ -15,14 +16,15 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTDeclSpecifier;
import org.eclipse.cdt.internal.core.dom.parser.ASTNode;
/**
- * @author jcamelon
+ * Base for all c++ declaration specifiers
*/
public abstract class CPPASTBaseDeclSpecifier extends ASTNode implements ICPPASTDeclSpecifier {
private boolean friend;
private boolean inline;
- private boolean volatil;
private boolean isConst;
+ private boolean isVolatile;
+ private boolean isRestrict;
private int sc;
private boolean virtual;
private boolean explicit;
@@ -50,12 +52,21 @@ public abstract class CPPASTBaseDeclSpecifier extends ASTNode implements ICPPAST
}
public boolean isVolatile() {
- return volatil;
+ return isVolatile;
}
public void setVolatile(boolean value) {
assertNotFrozen();
- volatil = value;
+ isVolatile = value;
+ }
+
+ public boolean isRestrict() {
+ return isRestrict;
+ }
+
+ public void setRestrict(boolean value) {
+ assertNotFrozen();
+ isRestrict = value;
}
public boolean isInline() {
@@ -93,8 +104,9 @@ public abstract class CPPASTBaseDeclSpecifier extends ASTNode implements ICPPAST
protected void copyBaseDeclSpec(CPPASTBaseDeclSpecifier other) {
other.friend = friend;
other.inline = inline;
- other.volatil = volatil;
other.isConst = isConst;
+ other.isVolatile = isVolatile;
+ other.isRestrict= isRestrict;
other.virtual = virtual;
other.explicit = explicit;
other.sc = sc;
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTFieldReference.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTFieldReference.java
index 12694d6c926..314236c2332 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTFieldReference.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTFieldReference.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2004, 2009 IBM Corporation and others.
+ * Copyright (c) 2004, 2010 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -13,7 +13,7 @@
*******************************************************************************/
package org.eclipse.cdt.internal.core.dom.parser.cpp;
-import static org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.SemanticUtil.TDEF;
+import static org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.SemanticUtil.*;
import java.util.ArrayList;
import java.util.List;
@@ -28,10 +28,12 @@ import org.eclipse.cdt.core.dom.ast.IASTNode;
import org.eclipse.cdt.core.dom.ast.IBinding;
import org.eclipse.cdt.core.dom.ast.IEnumerator;
import org.eclipse.cdt.core.dom.ast.IFunction;
+import org.eclipse.cdt.core.dom.ast.IPointerType;
import org.eclipse.cdt.core.dom.ast.IProblemBinding;
import org.eclipse.cdt.core.dom.ast.IType;
import org.eclipse.cdt.core.dom.ast.IVariable;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTFieldReference;
+import org.eclipse.cdt.core.dom.ast.cpp.ICPPField;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPFunction;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPMember;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPMethod;
@@ -39,6 +41,7 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPReferenceType;
import org.eclipse.cdt.internal.core.dom.parser.ASTNode;
import org.eclipse.cdt.internal.core.dom.parser.IASTAmbiguityParent;
import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPSemantics;
+import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CVQualifier;
import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.SemanticUtil;
public class CPPASTFieldReference extends ASTNode implements ICPPASTFieldReference, IASTAmbiguityParent,
@@ -190,7 +193,28 @@ public class CPPASTFieldReference extends ASTNode implements ICPPASTFieldReferen
IBinding binding = name.resolvePreBinding();
try {
if (binding instanceof IVariable) {
- return SemanticUtil.mapToAST(((IVariable) binding).getType(), this);
+ IType e2= ((IVariable) binding).getType();
+ if (binding instanceof ICPPField && !((ICPPField) binding).isStatic()) {
+ IType e1= getFieldOwner().getExpressionType();
+ if (isPointerDereference()) {
+ e1= SemanticUtil.getNestedType(e1, TDEF | REF | CVTYPE);
+ if (e1 instanceof IPointerType) {
+ e1= ((IPointerType) e1).getType();
+ }
+ }
+ CVQualifier cvq1 = SemanticUtil.getCVQualifier(e1);
+ if (((ICPPField) binding).isMutable()) {
+ // Remove const, add union of volatile.
+ CVQualifier cvq2 = SemanticUtil.getCVQualifier(e2);
+ if (cvq2.isConst()) {
+ e2= SemanticUtil.getNestedType(e2, ALLCVQ | TDEF | REF);
+ }
+ e2= SemanticUtil.addQualifiers(e2, false, cvq1.isVolatile() || cvq2.isVolatile());
+ } else {
+ e2= SemanticUtil.addQualifiers(e2, cvq1.isConst(), cvq1.isVolatile());
+ }
+ }
+ return SemanticUtil.mapToAST(e2, this);
} else if (binding instanceof IEnumerator) {
return ((IEnumerator) binding).getType();
} else if (binding instanceof IFunction) {
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTSimpleDeclSpecifier.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTSimpleDeclSpecifier.java
index a12fe8b99c8..03dfd9886b2 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTSimpleDeclSpecifier.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTSimpleDeclSpecifier.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2004, 2009 IBM Corporation and others.
+ * Copyright (c) 2004, 2010 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -12,16 +12,23 @@
package org.eclipse.cdt.internal.core.dom.parser.cpp;
import org.eclipse.cdt.core.dom.ast.ASTVisitor;
+import org.eclipse.cdt.core.dom.ast.IASTExpression;
+import org.eclipse.cdt.core.dom.ast.IASTNode;
import org.eclipse.cdt.core.dom.ast.IBasicType.Kind;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTSimpleDeclSpecifier;
+import org.eclipse.cdt.internal.core.dom.parser.IASTAmbiguityParent;
-public class CPPASTSimpleDeclSpecifier extends CPPASTBaseDeclSpecifier implements ICPPASTSimpleDeclSpecifier {
-
+public class CPPASTSimpleDeclSpecifier extends CPPASTBaseDeclSpecifier implements ICPPASTSimpleDeclSpecifier,
+ IASTAmbiguityParent {
private int type;
private boolean isSigned;
private boolean isUnsigned;
private boolean isShort;
private boolean isLong;
+ private boolean isLonglong;
+ private boolean isComplex=false;
+ private boolean isImaginary=false;
+ private IASTExpression fDeclTypeExpression;
public CPPASTSimpleDeclSpecifier copy() {
CPPASTSimpleDeclSpecifier copy = new CPPASTSimpleDeclSpecifier();
@@ -36,6 +43,12 @@ public class CPPASTSimpleDeclSpecifier extends CPPASTBaseDeclSpecifier implement
other.isUnsigned = isUnsigned;
other.isShort = isShort;
other.isLong = isLong;
+ other.isLonglong= isLonglong;
+ other.isComplex= isComplex;
+ other.isImaginary= isImaginary;
+ if (fDeclTypeExpression != null) {
+ other.setDeclTypeExpression(fDeclTypeExpression.copy());
+ }
}
/**
@@ -92,7 +105,23 @@ public class CPPASTSimpleDeclSpecifier extends CPPASTBaseDeclSpecifier implement
return isLong;
}
- public void setSigned(boolean value) {
+ public boolean isLongLong() {
+ return isLonglong;
+ }
+
+ public boolean isComplex() {
+ return isComplex;
+ }
+
+ public boolean isImaginary() {
+ return isImaginary;
+ }
+
+ public IASTExpression getDeclTypeExpression() {
+ return fDeclTypeExpression;
+ }
+
+ public void setSigned(boolean value) {
assertNotFrozen();
isSigned = value;
}
@@ -112,7 +141,31 @@ public class CPPASTSimpleDeclSpecifier extends CPPASTBaseDeclSpecifier implement
isShort = value;
}
- @Override
+ public void setLongLong(boolean value) {
+ assertNotFrozen();
+ isLonglong = value;
+ }
+
+ public void setComplex(boolean value) {
+ assertNotFrozen();
+ isComplex = value;
+ }
+
+ public void setImaginary(boolean value) {
+ assertNotFrozen();
+ isImaginary = value;
+ }
+
+ public void setDeclTypeExpression(IASTExpression expression) {
+ assertNotFrozen();
+ fDeclTypeExpression = expression;
+ if (expression != null) {
+ expression.setPropertyInParent(DECLTYPE_EXPRESSION);
+ expression.setParent(this);
+ }
+ }
+
+ @Override
public boolean accept(ASTVisitor action) {
if (action.shouldVisitDeclSpecifiers) {
switch (action.visit(this)) {
@@ -121,6 +174,10 @@ public class CPPASTSimpleDeclSpecifier extends CPPASTBaseDeclSpecifier implement
default: break;
}
}
+
+ if (fDeclTypeExpression != null && !fDeclTypeExpression.accept(action))
+ return false;
+
if (action.shouldVisitDeclSpecifiers) {
switch (action.leave(this)) {
case ASTVisitor.PROCESS_ABORT: return false;
@@ -130,4 +187,12 @@ public class CPPASTSimpleDeclSpecifier extends CPPASTBaseDeclSpecifier implement
}
return true;
}
+
+ public void replace(IASTNode child, IASTNode other) {
+ if (child == fDeclTypeExpression) {
+ other.setPropertyInParent(child.getPropertyInParent());
+ other.setParent(child.getParent());
+ fDeclTypeExpression= (IASTExpression) other;
+ }
+ }
}
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPBasicType.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPBasicType.java
index 040c3450fb7..017f52f453c 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPBasicType.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPBasicType.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2004, 2009 IBM Corporation and others.
+ * Copyright (c) 2004, 2010 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -19,7 +19,6 @@ import org.eclipse.cdt.core.dom.ast.IType;
import org.eclipse.cdt.core.dom.ast.ITypedef;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTSimpleDeclSpecifier;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPBasicType;
-import org.eclipse.cdt.core.dom.ast.gnu.cpp.IGPPASTSimpleDeclSpecifier;
import org.eclipse.cdt.internal.core.dom.parser.ISerializableType;
import org.eclipse.cdt.internal.core.dom.parser.ITypeMarshalBuffer;
import org.eclipse.core.runtime.CoreException;
@@ -58,19 +57,14 @@ public class CPPBasicType implements ICPPBasicType, ISerializableType {
}
private static int getModifiers(ICPPASTSimpleDeclSpecifier sds) {
- int qualifiers=
+ return
( sds.isLong() ? IBasicType.IS_LONG : 0 ) |
( sds.isShort() ? IBasicType.IS_SHORT : 0 ) |
( sds.isSigned() ? IBasicType.IS_SIGNED: 0 ) |
- ( sds.isUnsigned()? IBasicType.IS_UNSIGNED : 0 );
- if (sds instanceof IGPPASTSimpleDeclSpecifier) {
- IGPPASTSimpleDeclSpecifier gsds= (IGPPASTSimpleDeclSpecifier) sds;
- qualifiers |=
- ( gsds.isLongLong()? IBasicType.IS_LONG_LONG : 0 ) |
- ( gsds.isComplex() ? IBasicType.IS_COMPLEX : 0 ) |
- ( gsds.isImaginary()?IBasicType.IS_IMAGINARY : 0 );
- }
- return qualifiers;
+ ( sds.isUnsigned()? IBasicType.IS_UNSIGNED : 0 ) |
+ ( sds.isLongLong()? IBasicType.IS_LONG_LONG : 0 ) |
+ ( sds.isComplex() ? IBasicType.IS_COMPLEX : 0 ) |
+ ( sds.isImaginary()?IBasicType.IS_IMAGINARY : 0 );
}
private static Kind getKind(ICPPASTSimpleDeclSpecifier sds) {
@@ -79,11 +73,11 @@ public class CPPBasicType implements ICPPBasicType, ISerializableType {
static Kind getKind(final int simpleDeclSpecType) {
switch(simpleDeclSpecType) {
- case ICPPASTSimpleDeclSpecifier.t_bool:
+ case IASTSimpleDeclSpecifier.t_bool:
return Kind.eBoolean;
case IASTSimpleDeclSpecifier.t_char:
return Kind.eChar;
- case ICPPASTSimpleDeclSpecifier.t_wchar_t:
+ case IASTSimpleDeclSpecifier.t_wchar_t:
return Kind.eWChar;
case IASTSimpleDeclSpecifier.t_double:
return Kind.eDouble;
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPNodeFactory.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPNodeFactory.java
index 1fe4146c505..67191d5cf51 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPNodeFactory.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPNodeFactory.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2006, 2009 IBM Corporation and others.
+ * Copyright (c) 2006, 2010 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -107,7 +107,6 @@ import org.eclipse.cdt.core.dom.ast.gnu.IGNUASTCompoundStatementExpression;
import org.eclipse.cdt.core.dom.ast.gnu.cpp.IGPPASTExplicitTemplateInstantiation;
import org.eclipse.cdt.core.dom.ast.gnu.cpp.IGPPASTPointer;
import org.eclipse.cdt.core.dom.ast.gnu.cpp.IGPPASTPointerToMember;
-import org.eclipse.cdt.core.dom.ast.gnu.cpp.IGPPASTSimpleDeclSpecifier;
import org.eclipse.cdt.core.parser.IScanner;
import org.eclipse.cdt.internal.core.dom.parser.NodeFactory;
@@ -356,10 +355,6 @@ public class CPPNodeFactory extends NodeFactory implements ICPPNodeFactory {
return new CPPASTSimpleDeclSpecifier();
}
- public IGPPASTSimpleDeclSpecifier newSimpleDeclSpecifierGPP() {
- return new GPPASTSimpleDeclSpecifier();
- }
-
public ICPPASTFunctionDeclarator newFunctionDeclarator(IASTName name) {
return new CPPASTFunctionDeclarator(name);
}
@@ -529,4 +524,9 @@ public class CPPNodeFactory extends NodeFactory implements ICPPNodeFactory {
public ICPPASTPackExpansionExpression newPackExpansionExpression(IASTExpression pattern) {
return new CPPASTPackExpansionExpression(pattern);
}
+
+ @Deprecated
+ public org.eclipse.cdt.core.dom.ast.gnu.cpp.IGPPASTSimpleDeclSpecifier newSimpleDeclSpecifierGPP() {
+ return new GPPASTSimpleDeclSpecifier();
+ }
}
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/GNUCPPSourceParser.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/GNUCPPSourceParser.java
index b2938d4127b..c89a43ed554 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/GNUCPPSourceParser.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/GNUCPPSourceParser.java
@@ -111,11 +111,9 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTVisibilityLabel;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPNodeFactory;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTCompositeTypeSpecifier.ICPPASTBaseSpecifier;
import org.eclipse.cdt.core.dom.ast.gnu.IGNUASTTypeIdExpression;
-import org.eclipse.cdt.core.dom.ast.gnu.IGNUASTUnaryExpression;
import org.eclipse.cdt.core.dom.ast.gnu.cpp.IGPPASTExplicitTemplateInstantiation;
import org.eclipse.cdt.core.dom.ast.gnu.cpp.IGPPASTPointer;
import org.eclipse.cdt.core.dom.ast.gnu.cpp.IGPPASTPointerToMember;
-import org.eclipse.cdt.core.dom.ast.gnu.cpp.IGPPASTSimpleDeclSpecifier;
import org.eclipse.cdt.core.dom.parser.IExtensionToken;
import org.eclipse.cdt.core.dom.parser.cpp.ICPPParserExtensionConfiguration;
import org.eclipse.cdt.core.index.IIndex;
@@ -152,7 +150,6 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser {
private final boolean allowCPPRestrict;
private final boolean supportExtendedTemplateSyntax;
- private final boolean supportLongLong;
private final IIndex index;
protected ICPPASTTranslationUnit translationUnit;
@@ -181,7 +178,6 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser {
config.getBuiltinBindingsProvider());
allowCPPRestrict = config.allowRestrictPointerOperators();
supportExtendedTemplateSyntax = config.supportExtendedTemplateSyntax();
- supportLongLong = config.supportLongLongs();
supportParameterInfoBlock= config.supportParameterInfoBlock();
supportExtendedSizeofOperator= config.supportExtendedSizeofOperator();
supportFunctionStyleAsm= config.supportFunctionStyleAssembler();
@@ -414,7 +410,6 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser {
case IToken.t_new:
case IToken.t_delete:
case IToken.t_sizeof:
- case IGCCToken.t_typeof:
case IGCCToken.t___alignof__:
// postfix expression
case IToken.t_typename:
@@ -1087,9 +1082,6 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser {
}
return parseTypeidInParenthesisOrUnaryExpression(false, consume().getOffset(),
IASTTypeIdExpression.op_sizeof, IASTUnaryExpression.op_sizeof, ctx);
- case IGCCToken.t_typeof:
- return parseTypeidInParenthesisOrUnaryExpression(false, consume().getOffset(),
- IASTTypeIdExpression.op_typeof, IASTUnaryExpression.op_typeof, ctx);
case IGCCToken.t___alignof__:
return parseTypeidInParenthesisOrUnaryExpression(false, consume().getOffset(),
IASTTypeIdExpression.op_alignof, IASTUnaryExpression.op_alignOf, ctx);
@@ -2442,13 +2434,28 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser {
if (encounteredRawType || encounteredTypename)
throwBacktrack(LA(1));
- typeofExpression= parseTypeidInParenthesisOrUnaryExpression(false, consume().getOffset(),
- IGNUASTTypeIdExpression.op_typeof, IGNUASTUnaryExpression.op_typeof, CastExprCtx.eNotBExpr);
+ simpleType= IASTSimpleDeclSpecifier.t_typeof;
+ consume(IGCCToken.t_typeof);
+ typeofExpression= parseTypeidInParenthesisOrUnaryExpression(false, LA(1).getOffset(),
+ IGNUASTTypeIdExpression.op_typeof, -1, CastExprCtx.eNotBExpr);
encounteredTypename= true;
endOffset= calculateEndOffset(typeofExpression);
break;
+ case IToken.t_decltype:
+ if (encounteredRawType || encounteredTypename)
+ throwBacktrack(LA(1));
+
+ simpleType= IASTSimpleDeclSpecifier.t_decltype;
+ consume(IToken.t_decltype);
+ consume(IToken.tLPAREN);
+ typeofExpression= unaryExpression(CastExprCtx.eNotBExpr);
+ endOffset= consumeOrEOC(IToken.tRPAREN).getEndOffset();
+
+ encounteredTypename= true;
+ break;
+
default:
if (lt1 >= IExtensionToken.t__otherDeclSpecModifierFirst && lt1 <= IExtensionToken.t__otherDeclSpecModifierLast) {
handleOtherDeclSpecModifier();
@@ -2510,31 +2517,19 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser {
private ICPPASTSimpleDeclSpecifier buildSimpleDeclSpec(int storageClass, int simpleType,
int options, int isLong, IASTExpression typeofExpression, int offset, int endOffset) {
-
- if (isLong > 1 && !supportLongLong)
- isLong= 1;
-
- ICPPASTSimpleDeclSpecifier declSpec= null;
- if (isLong > 1 || (options & (RESTRICT|COMPLEX|IMAGINARY)) != 0 || typeofExpression != null) {
- final IGPPASTSimpleDeclSpecifier gppDeclSpec= nodeFactory.newSimpleDeclSpecifierGPP();
- gppDeclSpec.setLongLong(isLong > 1);
- gppDeclSpec.setRestrict((options & RESTRICT) != 0);
- gppDeclSpec.setComplex((options & COMPLEX) != 0);
- gppDeclSpec.setImaginary((options & IMAGINARY) != 0);
- gppDeclSpec.setTypeofExpression(typeofExpression);
-
- declSpec= gppDeclSpec;
- } else {
- declSpec = nodeFactory.newSimpleDeclSpecifier();
- }
+ ICPPASTSimpleDeclSpecifier declSpec= nodeFactory.newSimpleDeclSpecifier();
configureDeclSpec(declSpec, storageClass, options);
declSpec.setType(simpleType);
declSpec.setLong(isLong == 1);
+ declSpec.setLongLong(isLong > 1);
declSpec.setShort((options & SHORT) != 0);
declSpec.setUnsigned((options & UNSIGNED) != 0);
declSpec.setSigned((options & SIGNED) != 0);
+ declSpec.setComplex((options & COMPLEX) != 0);
+ declSpec.setImaginary((options & IMAGINARY) != 0);
+ declSpec.setDeclTypeExpression(typeofExpression);
((ASTNode) declSpec).setOffsetAndLength(offset, endOffset-offset);
return declSpec;
@@ -2548,6 +2543,7 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser {
declSpec.setFriend((options & FRIEND) != 0);
declSpec.setVirtual((options & VIRTUAL) != 0);
declSpec.setExplicit((options & EXPLICIT) != 0);
+ declSpec.setRestrict((options & RESTRICT) != 0);
}
/**
@@ -2717,18 +2713,10 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser {
if (declspec instanceof ICPPASTSimpleDeclSpecifier) {
ICPPASTSimpleDeclSpecifier sspec= (ICPPASTSimpleDeclSpecifier) declspec;
- switch(sspec.getType()) {
- case IASTSimpleDeclSpecifier.t_unspecified:
- if (sspec.isLong() || sspec.isShort() || sspec.isSigned() || sspec.isUnsigned())
- return true;
- if (sspec instanceof IGPPASTSimpleDeclSpecifier) {
- final IGPPASTSimpleDeclSpecifier gspec = (IGPPASTSimpleDeclSpecifier) sspec;
- if (gspec.isLongLong())
- return true;
- }
+ if (CPPVisitor.doesNotSpecifyType(declspec)) {
return false;
-
- case IASTSimpleDeclSpecifier.t_void:
+ }
+ if (sspec.getType() == IASTSimpleDeclSpecifier.t_void) {
return false;
}
}
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/GPPASTSimpleDeclSpecifier.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/GPPASTSimpleDeclSpecifier.java
index 49973a871d1..5e458cdfe8e 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/GPPASTSimpleDeclSpecifier.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/GPPASTSimpleDeclSpecifier.java
@@ -1,126 +1,47 @@
/*******************************************************************************
- * Copyright (c) 2004, 2008 IBM Corporation and others.
+ * Copyright (c) 2004, 2010 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
- * IBM - Initial API and implementation
+ * John Camelon (IBM) - Initial API and implementation
* Markus Schorn (Wind River Systems)
*******************************************************************************/
package org.eclipse.cdt.internal.core.dom.parser.cpp;
-import org.eclipse.cdt.core.dom.ast.ASTVisitor;
import org.eclipse.cdt.core.dom.ast.IASTExpression;
-import org.eclipse.cdt.core.dom.ast.IASTNode;
import org.eclipse.cdt.core.dom.ast.gnu.cpp.IGPPASTSimpleDeclSpecifier;
-import org.eclipse.cdt.internal.core.dom.parser.IASTAmbiguityParent;
/**
- * @author jcamelon
+ * @deprecated Replaced by {@link CPPASTSimpleDeclSpecifier}
*/
-public class GPPASTSimpleDeclSpecifier extends CPPASTSimpleDeclSpecifier
- implements IGPPASTSimpleDeclSpecifier, IASTAmbiguityParent {
+@Deprecated
+public class GPPASTSimpleDeclSpecifier extends CPPASTSimpleDeclSpecifier implements
+ IGPPASTSimpleDeclSpecifier {
- private boolean longLong;
- private boolean restrict;
- private boolean complex=false;
- private boolean imaginary=false;
- private IASTExpression typeOfExpression;
-
-
-
public GPPASTSimpleDeclSpecifier() {
}
public GPPASTSimpleDeclSpecifier(IASTExpression typeofExpression) {
- setTypeofExpression(typeofExpression);
+ super();
+ setDeclTypeExpression(typeofExpression);
}
@Override
public GPPASTSimpleDeclSpecifier copy() {
GPPASTSimpleDeclSpecifier copy = new GPPASTSimpleDeclSpecifier();
copySimpleDeclSpec(copy);
- copy.setTypeofExpression(typeOfExpression == null ? null : typeOfExpression.copy());
- copy.longLong = longLong;
- copy.restrict = restrict;
- copy.complex = complex;
- copy.imaginary = imaginary;
return copy;
}
- public boolean isLongLong() {
- return longLong;
- }
-
- public void setLongLong(boolean value) {
- longLong = value;
- }
-
- public boolean isRestrict() {
- return restrict;
- }
-
- public void setRestrict(boolean value) {
- restrict = value;
- }
public void setTypeofExpression(IASTExpression typeofExpression) {
- typeOfExpression = typeofExpression;
- if (typeofExpression != null) {
- typeofExpression.setParent(this);
- typeofExpression.setPropertyInParent(TYPEOF_EXPRESSION);
- }
+ setDeclTypeExpression(typeofExpression);
}
public IASTExpression getTypeofExpression() {
- return typeOfExpression;
- }
-
- @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;
+ return getDeclTypeExpression();
}
-
- 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;
- }
- }
}
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/CPPVisitor.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/CPPVisitor.java
index 63bd3aaf8d8..35e9eb8beb7 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/CPPVisitor.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/CPPVisitor.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2004, 2009 IBM Corporation and others.
+ * Copyright (c) 2004, 2010 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -64,6 +64,7 @@ import org.eclipse.cdt.core.dom.ast.IBinding;
import org.eclipse.cdt.core.dom.ast.ICompositeType;
import org.eclipse.cdt.core.dom.ast.IEnumeration;
import org.eclipse.cdt.core.dom.ast.IEnumerator;
+import org.eclipse.cdt.core.dom.ast.IFunction;
import org.eclipse.cdt.core.dom.ast.IFunctionType;
import org.eclipse.cdt.core.dom.ast.ILabel;
import org.eclipse.cdt.core.dom.ast.IParameter;
@@ -129,7 +130,6 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPUsingDeclaration;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTCompositeTypeSpecifier.ICPPASTBaseSpecifier;
import org.eclipse.cdt.core.dom.ast.gnu.cpp.IGPPASTPointer;
import org.eclipse.cdt.core.dom.ast.gnu.cpp.IGPPASTPointerToMember;
-import org.eclipse.cdt.core.dom.ast.gnu.cpp.IGPPASTSimpleDeclSpecifier;
import org.eclipse.cdt.core.index.IIndexBinding;
import org.eclipse.cdt.core.parser.util.ArrayUtil;
import org.eclipse.cdt.core.parser.util.CharArrayUtils;
@@ -1742,13 +1742,8 @@ public class CPPVisitor extends ASTQueries {
name = ((IASTEnumerationSpecifier)declSpec).getName();
} else if (declSpec instanceof ICPPASTSimpleDeclSpecifier) {
ICPPASTSimpleDeclSpecifier spec = (ICPPASTSimpleDeclSpecifier) declSpec;
- if (spec instanceof IGPPASTSimpleDeclSpecifier) {
- IGPPASTSimpleDeclSpecifier gspec = (IGPPASTSimpleDeclSpecifier) spec;
- final IASTExpression typeofExpression = gspec.getTypeofExpression();
- if (typeofExpression != null) {
- type = typeofExpression.getExpressionType();
- }
- }
+ // Check for decltype(expr)
+ type = getDeclType(spec);
if (type == null) {
type = new CPPBasicType(spec);
}
@@ -1782,6 +1777,55 @@ public class CPPVisitor extends ASTQueries {
return type;
}
+ /**
+ * Compute the type for decltype(expr) or typeof(expr)
+ */
+ private static IType getDeclType(ICPPASTSimpleDeclSpecifier spec) {
+ IASTExpression expr = spec.getDeclTypeExpression();
+ if (expr == null)
+ return null;
+
+ if (spec.getType() == IASTSimpleDeclSpecifier.t_decltype) {
+ IASTName namedEntity= null;
+ if (expr instanceof IASTIdExpression) {
+ namedEntity= ((IASTIdExpression) expr).getName();
+ } else if (expr instanceof IASTFieldReference) {
+ namedEntity= ((IASTFieldReference) expr).getFieldName();
+ }
+ if (namedEntity != null) {
+ IBinding b= namedEntity.resolvePreBinding();
+ if (b instanceof IType) {
+ return (IType) b;
+ }
+ try {
+ if (b instanceof IVariable) {
+ return ((IVariable) b).getType();
+ }
+ if (b instanceof IFunction) {
+ return ((IFunction) b).getType();
+ }
+ } catch (DOMException e) {
+ return e.getProblem();
+ }
+ }
+ }
+ IType type = expr.getExpressionType();
+ if (spec.getType() == IASTSimpleDeclSpecifier.t_decltype) {
+ while (expr instanceof IASTUnaryExpression
+ && ((IASTUnaryExpression) expr).getOperator() == IASTUnaryExpression.op_bracketedPrimary) {
+ expr = ((IASTUnaryExpression) expr).getOperand();
+ }
+ if (!(expr instanceof IASTFunctionCallExpression)) {
+ type= SemanticUtil.getNestedType(type, TDEF | REF);
+ if (expr.isLValue())
+ type= new CPPReferenceType(type, false);
+ }
+ } else {
+ type= SemanticUtil.getNestedType(type, TDEF | REF);
+ }
+ return type;
+ }
+
public static IType getThisType(IScope scope) {
try {
IASTNode node = null;
@@ -2182,12 +2226,7 @@ public class CPPVisitor extends ASTQueries {
if (declspec instanceof ICPPASTSimpleDeclSpecifier) {
ICPPASTSimpleDeclSpecifier ds= (ICPPASTSimpleDeclSpecifier) declspec;
if (ds.getType() == IASTSimpleDeclSpecifier.t_unspecified) {
- if (ds instanceof IGPPASTSimpleDeclSpecifier) {
- final IGPPASTSimpleDeclSpecifier gds = (IGPPASTSimpleDeclSpecifier) ds;
- if (gds.isLongLong() || gds.getTypeofExpression() != null)
- return false;
- }
- if (ds.isShort() || ds.isLong() || ds.isSigned() || ds.isUnsigned())
+ if (ds.isShort() || ds.isLong() || ds.isLongLong() || ds.isSigned() || ds.isUnsigned())
return false;
return true;
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/SemanticUtil.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/SemanticUtil.java
index e6c3b0bd9d1..8e5e09ef739 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/SemanticUtil.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/SemanticUtil.java
@@ -171,7 +171,7 @@ public class SemanticUtil {
/**
* Returns 0 for no qualifier, 1 for const, 2 for volatile and 3 for const volatile.
*/
- static CVQualifier getCVQualifier(IType t) {
+ public static CVQualifier getCVQualifier(IType t) {
if (t instanceof IQualifierType) {
IQualifierType qt= (IQualifierType) t;
if (qt.isConst()) {
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/rewrite/astwriter/ExpressionWriter.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/rewrite/astwriter/ExpressionWriter.java
index 734ccd0dd5f..aaf65e1914c 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/rewrite/astwriter/ExpressionWriter.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/rewrite/astwriter/ExpressionWriter.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2008, 2009 Institute for Software, HSR Hochschule fuer Technik
+ * Copyright (c) 2008, 2010 Institute for Software, HSR Hochschule fuer Technik
* Rapperswil, University of applied sciences and others
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
@@ -37,7 +37,6 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTTypeIdExpression;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTTypenameExpression;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTUnaryExpression;
import org.eclipse.cdt.core.dom.ast.gnu.IGNUASTTypeIdExpression;
-import org.eclipse.cdt.core.dom.ast.gnu.IGNUASTUnaryExpression;
import org.eclipse.cdt.core.dom.ast.gnu.cpp.IGPPASTBinaryExpression;
import org.eclipse.cdt.internal.core.dom.rewrite.commenthandler.NodeCommentMap;
@@ -252,8 +251,8 @@ public class ExpressionWriter extends NodeWriter{
case IASTUnaryExpression.op_bracketedPrimary:
case ICPPASTUnaryExpression.op_throw:
case ICPPASTUnaryExpression.op_typeid:
- case IGNUASTUnaryExpression.op_alignOf:
- case IGNUASTUnaryExpression.op_typeof:
+ case IASTUnaryExpression.op_alignOf:
+ case IASTUnaryExpression.op_typeof:
return true;
default:
@@ -268,8 +267,8 @@ public class ExpressionWriter extends NodeWriter{
case IASTUnaryExpression.op_postFixIncr:
case IASTUnaryExpression.op_bracketedPrimary:
case ICPPASTUnaryExpression.op_typeid:
- case IGNUASTUnaryExpression.op_alignOf:
- case IGNUASTUnaryExpression.op_typeof:
+ case IASTUnaryExpression.op_alignOf:
+ case IASTUnaryExpression.op_typeof:
return true;
default:
@@ -306,9 +305,9 @@ public class ExpressionWriter extends NodeWriter{
return THROW;
case ICPPASTUnaryExpression.op_typeid:
return TYPEID_OP;
- case IGNUASTUnaryExpression.op_alignOf:
+ case IASTUnaryExpression.op_alignOf:
return ALIGNOF_OP;
- case IGNUASTUnaryExpression.op_typeof:
+ case IASTUnaryExpression.op_typeof:
return TYPEOF_OP;
default:
System.err.println("Unkwown unaryExpressionType: " + unaryExpressionType); //$NON-NLS-1$
@@ -326,8 +325,8 @@ public class ExpressionWriter extends NodeWriter{
case ICPPASTUnaryExpression.op_typeid:
return CLOSING_BRACKET_OP;
case IASTUnaryExpression.op_bracketedPrimary:
- case IGNUASTUnaryExpression.op_alignOf:
- case IGNUASTUnaryExpression.op_typeof:
+ case IASTUnaryExpression.op_alignOf:
+ case IASTUnaryExpression.op_typeof:
return CLOSING_BRACKET_OP;
default:
System.err.println("Unkwown unaryExpressionType " + unaryExpressionType); //$NON-NLS-1$
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/token/KeywordSets.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/token/KeywordSets.java
index 09843f630f4..501ee2086cb 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/token/KeywordSets.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/token/KeywordSets.java
@@ -1,12 +1,13 @@
/*******************************************************************************
- * Copyright (c) 2002, 2008 IBM Corporation and others.
+ * Copyright (c) 2002, 2010 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
- * IBM Rational Software - Initial API and implementation
+ * John Camelon (IBM Rational Software) - Initial API and implementation
+ * Markus Schorn (Wind River Systems)
*******************************************************************************/
package org.eclipse.cdt.internal.core.parser.token;
@@ -21,9 +22,6 @@ import org.eclipse.cdt.core.parser.KeywordSetKey;
import org.eclipse.cdt.core.parser.Keywords;
import org.eclipse.cdt.core.parser.ParserLanguage;
-/**
- * @author jcamelon
- */
public class KeywordSets {
public static Set<String> getKeywords( KeywordSetKey kind, ParserLanguage language )
@@ -417,6 +415,7 @@ public class KeywordSets {
ALL_CPP.add( Keywords.CONST);
ALL_CPP.add( Keywords.CONST_CAST);
ALL_CPP.add( Keywords.CONTINUE);
+ ALL_CPP.add( Keywords.DECLTYPE);
ALL_CPP.add( Keywords.DEFAULT);
ALL_CPP.add( Keywords.DELETE);
ALL_CPP.add( Keywords.DO);
@@ -504,6 +503,7 @@ public class KeywordSets {
KEYWORDS_CPP.add( Keywords.CONST );
KEYWORDS_CPP.add( Keywords.CONST_CAST );
KEYWORDS_CPP.add( Keywords.CONTINUE );
+ KEYWORDS_CPP.add( Keywords.DECLTYPE);
KEYWORDS_CPP.add( Keywords.DEFAULT );
KEYWORDS_CPP.add( Keywords.DELETE );
KEYWORDS_CPP.add( Keywords.DO );
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/extractfunction/TrailNodeEqualityChecker.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/extractfunction/TrailNodeEqualityChecker.java
index 168af77a52a..cd12ad395d2 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/extractfunction/TrailNodeEqualityChecker.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/extractfunction/TrailNodeEqualityChecker.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2008 Institute for Software, HSR Hochschule fuer Technik
+ * Copyright (c) 2008, 2010 Institute for Software, HSR Hochschule fuer Technik
* Rapperswil, University of applied sciences and others
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
@@ -7,12 +7,10 @@
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
- * Institute for Software - initial API and implementation
+ * Institute for Software - initial API and implementation
*******************************************************************************/
package org.eclipse.cdt.internal.ui.refactoring.extractfunction;
-
-
import java.util.Arrays;
import java.util.List;
import java.util.Map;
@@ -47,7 +45,6 @@ import org.eclipse.cdt.core.dom.ast.IBinding;
import org.eclipse.cdt.core.dom.ast.IType;
import org.eclipse.cdt.core.dom.ast.c.ICASTDeclSpecifier;
import org.eclipse.cdt.core.dom.ast.c.ICASTPointer;
-import org.eclipse.cdt.core.dom.ast.c.ICASTSimpleDeclSpecifier;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTCatchHandler;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTConversionName;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTDeclSpecifier;
@@ -64,10 +61,8 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTTypenameExpression;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTUsingDeclaration;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTVisibilityLabel;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPVariable;
-import org.eclipse.cdt.core.dom.ast.gnu.cpp.IGPPASTDeclSpecifier;
import org.eclipse.cdt.core.dom.ast.gnu.cpp.IGPPASTExplicitTemplateInstantiation;
import org.eclipse.cdt.core.dom.ast.gnu.cpp.IGPPASTPointer;
-import org.eclipse.cdt.core.dom.ast.gnu.cpp.IGPPASTSimpleDeclSpecifier;
import org.eclipse.cdt.core.index.IIndex;
import org.eclipse.cdt.core.index.IIndexName;
@@ -137,33 +132,7 @@ public class TrailNodeEqualityChecker implements EqualityChecker<IASTNode> {
}
private boolean isDeclSpecifierEquals(IASTNode trailNode, IASTNode node) {
- if (trailNode instanceof IGPPASTSimpleDeclSpecifier) {
- IGPPASTSimpleDeclSpecifier trailSimpleDecl = (IGPPASTSimpleDeclSpecifier) trailNode;
- IGPPASTSimpleDeclSpecifier simpleDecl = (IGPPASTSimpleDeclSpecifier) node;
-
- return isSimpleDeclSpecifierEquals(trailSimpleDecl, simpleDecl)
- && trailSimpleDecl.isComplex() == simpleDecl.isComplex()
- && trailSimpleDecl.isImaginary() == simpleDecl.isImaginary()
- && trailSimpleDecl.isLongLong() == simpleDecl.isLongLong()
- && trailSimpleDecl.isComplex() == simpleDecl.isComplex()
- && trailSimpleDecl.isExplicit() == simpleDecl.isExplicit()
- && trailSimpleDecl.isFriend() == simpleDecl.isFriend();
- } else if (trailNode instanceof IGPPASTDeclSpecifier) {
- IGPPASTDeclSpecifier trailDecl = (IGPPASTDeclSpecifier) trailNode;
- IGPPASTDeclSpecifier decl = (IGPPASTDeclSpecifier) node;
-
- return isDeclSpecifierEquals(trailDecl, decl)
- && trailDecl.isRestrict() == decl.isRestrict();
- } else if (trailNode instanceof ICASTSimpleDeclSpecifier) {
- ICASTSimpleDeclSpecifier trailDecl = (ICASTSimpleDeclSpecifier) trailNode;
- ICASTSimpleDeclSpecifier decl = (ICASTSimpleDeclSpecifier) node;
-
- return isSimpleDeclSpecifierEquals(trailDecl, decl)
- && trailDecl.isRestrict() == decl.isRestrict()
- && trailDecl.isComplex() == decl.isComplex()
- && trailDecl.isImaginary() == decl.isImaginary()
- && trailDecl.isLongLong() == decl.isLongLong();
- } else if (trailNode instanceof IASTSimpleDeclSpecifier) {
+ if (trailNode instanceof IASTSimpleDeclSpecifier) {
IASTSimpleDeclSpecifier trailDecl = (IASTSimpleDeclSpecifier) trailNode;
IASTSimpleDeclSpecifier decl = (IASTSimpleDeclSpecifier) node;
@@ -386,9 +355,21 @@ public class TrailNodeEqualityChecker implements EqualityChecker<IASTNode> {
}
private boolean isDeclSpecifierEquals(IASTDeclSpecifier trailDeclSpeci, IASTDeclSpecifier declSpeci){
+ if (trailDeclSpeci instanceof ICPPASTDeclSpecifier) {
+ ICPPASTDeclSpecifier trailCppDecl= (ICPPASTDeclSpecifier) trailDeclSpeci;
+ ICPPASTDeclSpecifier cppDecl= (ICPPASTDeclSpecifier) declSpeci;
+ if (trailCppDecl.isExplicit() == cppDecl.isExplicit()
+ && trailCppDecl.isFriend() == cppDecl.isFriend()
+ && trailCppDecl.isVirtual() == cppDecl.isVirtual()) {
+ // ok
+ } else {
+ return false;
+ }
+ }
return trailDeclSpeci.isConst() == declSpeci.isConst()
&& trailDeclSpeci.isInline() == declSpeci.isInline()
&& trailDeclSpeci.isVolatile() == declSpeci.isVolatile()
+ && trailDeclSpeci.isRestrict() == declSpeci.isRestrict()
&& trailDeclSpeci.getStorageClass() == declSpeci.getStorageClass();
}
@@ -398,7 +379,10 @@ public class TrailNodeEqualityChecker implements EqualityChecker<IASTNode> {
&& trailDeclSpeci.isShort() == declSpeci.isShort()
&& trailDeclSpeci.isSigned() == declSpeci.isSigned()
&& trailDeclSpeci.isUnsigned() == declSpeci.isUnsigned()
- && trailDeclSpeci.getType() == declSpeci.getType();
+ && trailDeclSpeci.getType() == declSpeci.getType()
+ && trailDeclSpeci.isComplex() == declSpeci.isComplex()
+ && trailDeclSpeci.isImaginary() == declSpeci.isImaginary()
+ && trailDeclSpeci.isLongLong() == declSpeci.isLongLong();
}
private boolean isNameEquals(TrailName trailName, IASTName name) {

Back to the top