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 479206d61bf..601c6e7924f 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
@@ -87,6 +87,7 @@ 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;
@@ -4429,6 +4430,20 @@ public class AST2CPPTests extends AST2BaseTest {
assertSame(state, col.getName(9).resolveBinding());
}
+ public void testBug95757() throws Exception {
+ StringBuffer buffer = new StringBuffer();
+ buffer.append("float _Complex x;\n"); //$NON-NLS-1$
+ buffer.append("double _Complex y;\n"); //$NON-NLS-1$
+
+ IASTTranslationUnit tu = parse( buffer.toString(), 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);
+ }
+
public void testTypedefQualified() throws Exception {
StringBuffer buffer = new StringBuffer();
buffer.append("class _A { \n"); //$NON-NLS-1$
diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2Tests.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2Tests.java
index 5562dd2e27a..bd0b0c6aec5 100644
--- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2Tests.java
+++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2Tests.java
@@ -72,6 +72,7 @@ import org.eclipse.cdt.core.dom.ast.c.ICASTDesignatedInitializer;
import org.eclipse.cdt.core.dom.ast.c.ICASTEnumerationSpecifier;
import org.eclipse.cdt.core.dom.ast.c.ICASTFieldDesignator;
import org.eclipse.cdt.core.dom.ast.c.ICASTPointer;
+import org.eclipse.cdt.core.dom.ast.c.ICASTSimpleDeclSpecifier;
import org.eclipse.cdt.core.dom.ast.c.ICArrayType;
import org.eclipse.cdt.core.dom.ast.c.ICExternalBinding;
import org.eclipse.cdt.core.dom.ast.c.ICFunctionScope;
@@ -3093,6 +3094,20 @@ public class AST2Tests extends AST2BaseTest {
IASTTranslationUnit tu = parse(buffer.toString(), ParserLanguage.C);
}
+ public void testBug95757() throws Exception {
+ StringBuffer buffer = new StringBuffer();
+ buffer.append("float _Complex x;\n"); //$NON-NLS-1$
+ buffer.append("double _Complex y;\n"); //$NON-NLS-1$
+
+ IASTTranslationUnit tu = parse( buffer.toString(), ParserLanguage.C, true, true );
+ IASTDeclaration[] decls = tu.getDeclarations();
+
+ assertTrue(((ICASTSimpleDeclSpecifier)((IASTSimpleDeclaration)decls[0]).getDeclSpecifier()).isComplex());
+ assertEquals(((ICASTSimpleDeclSpecifier)((IASTSimpleDeclaration)decls[0]).getDeclSpecifier()).getType(), IASTSimpleDeclSpecifier.t_float);
+ assertTrue(((ICASTSimpleDeclSpecifier)((IASTSimpleDeclaration)decls[1]).getDeclSpecifier()).isComplex());
+ assertEquals(((ICASTSimpleDeclSpecifier)((IASTSimpleDeclaration)decls[1]).getDeclSpecifier()).getType(), IASTSimpleDeclSpecifier.t_double);
+ }
+
public void testBug93980() throws Exception {
StringBuffer buffer = new StringBuffer();
buffer.append("int foo(); \n"); //$NON-NLS-1$
diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2UtilTests.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2UtilTests.java
index db5438c038d..aaed90b1039 100644
--- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2UtilTests.java
+++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2UtilTests.java
@@ -133,7 +133,7 @@ public class AST2UtilTests extends AST2BaseTest {
// verify types
isTypeEqual( ((IASTTypeIdExpression)((IASTInitializerExpression)((IASTSimpleDeclaration)d[0]).getDeclarators()[0].getInitializer()).getExpression()).getTypeId(), "int"); //$NON-NLS-1$
isTypeEqual( ((IASTTypeIdExpression)((IASTReturnStatement)((IASTCompoundStatement)((IASTFunctionDefinition)d[2]).getBody()).getStatements()[0]).getReturnValue()).getTypeId(), "union Squaw"); //$NON-NLS-1$
- isTypeEqual( ((IASTCastExpression)((IASTInitializerExpression)((IASTSimpleDeclaration)d[6]).getDeclarators()[0].getInitializer()).getExpression()).getTypeId() , "short"); //$NON-NLS-1$
+ isTypeEqual( ((IASTCastExpression)((IASTInitializerExpression)((IASTSimpleDeclaration)d[6]).getDeclarators()[0].getInitializer()).getExpression()).getTypeId() , "short int"); //$NON-NLS-1$
}
public void testKnRC() throws Exception {
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 f5e150c783e..d6c14b735f3 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
@@ -433,17 +433,13 @@ public class ASTSignatureUtil {
// 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;
- case IGPPASTSimpleDeclSpecifier.t_Complex:
- if (needSpace) { result.append(SPACE); needSpace=false; } result.append(Keywords.c_COMPLEX); needSpace=true;
- break;
- case IGPPASTSimpleDeclSpecifier.t_Imaginary:
- if (needSpace) { result.append(SPACE); needSpace=false; } result.append(Keywords.c_IMAGINARY); needSpace=true;
- break;
}
}
@@ -460,17 +456,13 @@ public class ASTSignatureUtil {
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;
- case ICASTSimpleDeclSpecifier.t_Complex:
- if (needSpace) { result.append(SPACE); needSpace=false; } result.append(Keywords.c_COMPLEX); needSpace=true;
- break;
- case ICASTSimpleDeclSpecifier.t_Imaginary:
- if (needSpace) { result.append(SPACE); needSpace=false; } result.append(Keywords.c_IMAGINARY); needSpace=true;
- break;
}
}
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/ASTTypeUtil.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/ASTTypeUtil.java
index 4065fb0ac16..c5aec95e8b1 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/ASTTypeUtil.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/ASTTypeUtil.java
@@ -119,14 +119,10 @@ public class ASTTypeUtil {
if (type instanceof IGPPBasicType) {
try {
if (((IGPPBasicType)type).isLongLong()) { if (needSpace) { result.append(SPACE); needSpace=false; } result.append(Keywords.LONG_LONG); needSpace=true; }
-
+ if (((IGPPBasicType)type).isComplex()) { if (needSpace) { result.append(SPACE); needSpace=false; } result.append(Keywords.c_COMPLEX); needSpace=true; }
+ if (((IGPPBasicType)type).isImaginary()) { if (needSpace) { result.append(SPACE); needSpace=false; } result.append(Keywords.c_IMAGINARY); needSpace=true; }
+
switch (((IGPPBasicType)type).getType()) {
- case IGPPBasicType.t_Complex:
- result.append(Keywords.c_COMPLEX);
- break;
- case IGPPBasicType.t_Imaginary:
- result.append(Keywords.c_IMAGINARY);
- break;
case IGPPBasicType.t_typeof:
result.append(GCCKeywords.TYPEOF);
break;
@@ -145,21 +141,20 @@ public class ASTTypeUtil {
} catch (DOMException e) {}
} else if (type instanceof ICBasicType) {
try {
+ if (((ICBasicType)type).isComplex()) { if (needSpace) { result.append(SPACE); needSpace=false; } result.append(Keywords.c_COMPLEX); needSpace=true; }
+ if (((ICBasicType)type).isImaginary()) { if (needSpace) { result.append(SPACE); needSpace=false; } result.append(Keywords.c_IMAGINARY); needSpace=true; }
+
switch (((ICBasicType)type).getType()) {
case ICBasicType.t_Bool:
result.append(Keywords.c_BOOL);
break;
- case ICBasicType.t_Complex:
- result.append(Keywords.c_COMPLEX);
- break;
- case ICBasicType.t_Imaginary:
- result.append(Keywords.c_IMAGINARY);
- break;
}
} catch (DOMException e) {}
}
try {
+ if( needSpace )
+ result.append( SPACE );
switch (((IBasicType)type).getType()) {
case IBasicType.t_char:
result.append(Keywords.CHAR);
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 bb969213827..5b551a7205a 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
@@ -26,21 +26,35 @@ public interface ICASTSimpleDeclSpecifier extends IASTSimpleDeclSpecifier,
*/
public static final int t_Bool = IASTSimpleDeclSpecifier.t_last + 1;
- /**
- * t_Complex
complex number. e.g. _Complex t;
- */
- public static final int t_Complex = IASTSimpleDeclSpecifier.t_last + 2;
-
- /**
- * t_Imaginary
complex imaginary number. e.g. _Imaginr
- */
- public static final int t_Imaginary = IASTSimpleDeclSpecifier.t_last + 3;
-
/**
* t_last
is defined for sub-interfaces.
*/
- public static final int t_last = t_Imaginary;
-
+ public static final int t_last = t_Bool;
+
+ /**
+ * Is complex number? e.g. _Complex t;
+ * @return true if it is a complex number, false otherwise
+ */
+ public boolean isComplex();
+
+ /**
+ * Set the number to be complex.
+ * @param value true if it is a complex number, false otherwise
+ */
+ public void setComplex(boolean value);
+
+ /**
+ * Is imaginary number? e.g. _Imaginr
+ * @return true if it is an imaginary number, false otherwise
+ */
+ public boolean isImaginary();
+
+ /**
+ * Set the number to be imaginary.
+ * @param value true if it is an imaginary number, false otherwise
+ */
+ public void setImaginary(boolean value);
+
// allow for long long's
/**
* Is long long?
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/c/ICBasicType.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/c/ICBasicType.java
index 45d0bc124b3..7fe04a80447 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/c/ICBasicType.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/c/ICBasicType.java
@@ -23,9 +23,17 @@ public interface ICBasicType extends IBasicType {
// Extra types in C
public static final int t_Bool = ICASTSimpleDeclSpecifier.t_Bool;
- public static final int t_Complex = ICASTSimpleDeclSpecifier.t_Complex;
-
- public static final int t_Imaginary = ICASTSimpleDeclSpecifier.t_Imaginary;
+ /**
+ * Is complex number? e.g. _Complex t;
+ * @return true if it is a complex number, false otherwise
+ */
+ public boolean isComplex();
+
+ /**
+ * Is imaginary number? e.g. _Imaginr
+ * @return true if it is an imaginary number, false otherwise
+ */
+ public boolean isImaginary();
public boolean isLongLong() throws DOMException;
}
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 ce2e2e52045..a7f0907a9f7 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
@@ -22,26 +22,40 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTSimpleDeclSpecifier;
public interface IGPPASTSimpleDeclSpecifier extends IGPPASTDeclSpecifier,
ICPPASTSimpleDeclSpecifier {
- /**
- * t_Complex
represents a _Complex type.
- */
- public static final int t_Complex = ICPPASTSimpleDeclSpecifier.t_last + 1;
-
- /**
- * t_Imaginary
represents an _Imaginary type.
- */
- public static final int t_Imaginary = ICPPASTSimpleDeclSpecifier.t_last + 2;
-
/**
* t_typeof
represents a typeof() expression type.
*/
- public static final int t_typeof = ICPPASTSimpleDeclSpecifier.t_last + 3;
+ public static final int t_typeof = ICPPASTSimpleDeclSpecifier.t_last + 1;
/**
* t_last
is for subinterfaces to extend these types.
*/
public static final int t_last = t_typeof;
-
+
+ /**
+ * Is complex number? e.g. _Complex t;
+ * @return true if it is a complex number, false otherwise
+ */
+ public boolean isComplex();
+
+ /**
+ * Set the number to be complex.
+ * @param value true if it is a complex number, false otherwise
+ */
+ public void setComplex(boolean value);
+
+ /**
+ * Is imaginary number? e.g. _Imaginr
+ * @return true if it is an imaginary number, false otherwise
+ */
+ public boolean isImaginary();
+
+ /**
+ * Set the number to be imaginary.
+ * @param value true if it is an imaginary number, false otherwise
+ */
+ public void setImaginary(boolean value);
+
/**
* TYPEOF_EXPRESSION
represents the relationship between the
* decl spec & the expression for typeof().
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/gnu/cpp/IGPPBasicType.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/gnu/cpp/IGPPBasicType.java
index f6e2dacc5cd..626d9c3fef1 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/gnu/cpp/IGPPBasicType.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/gnu/cpp/IGPPBasicType.java
@@ -22,12 +22,20 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPBasicType;
*/
public interface IGPPBasicType extends ICPPBasicType {
- public static final int t_Complex = IGPPASTSimpleDeclSpecifier.t_Complex;
-
- public static final int t_Imaginary = IGPPASTSimpleDeclSpecifier.t_Imaginary;
-
public static final int t_typeof = IGPPASTSimpleDeclSpecifier.t_typeof;
-
+
+ /**
+ * Is complex number? e.g. _Complex t;
+ * @return true if it is a complex number, false otherwise
+ */
+ public boolean isComplex();
+
+ /**
+ * Is imaginary number? e.g. _Imaginr
+ * @return true if it is an imaginary number, false otherwise
+ */
+ public boolean isImaginary();
+
public boolean isLongLong() throws DOMException;
public IType getTypeofType() throws DOMException;
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/GCCBuiltinSymbolProvider.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/GCCBuiltinSymbolProvider.java
index 11bda3655aa..bd4d335e0bf 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/GCCBuiltinSymbolProvider.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/GCCBuiltinSymbolProvider.java
@@ -1076,17 +1076,22 @@ public class GCCBuiltinSymbolProvider implements IASTBuiltinSymbolProvider {
private void __builtin_conj() {
IBinding temp = null;
- ICASTSimpleDeclSpecifier complexSds = new CASTSimpleDeclSpecifier();
- complexSds.setType(ICASTSimpleDeclSpecifier.t_Complex);
- IType c_double_complex = new CBasicType(complexSds);
- IType cpp_double_complex = new CPPBasicType(IGPPBasicType.t_Complex, 0);
- IType c_float_complex = c_double_complex;
- IType cpp_float_complex = cpp_double_complex;
+ ICASTSimpleDeclSpecifier doubleComplexSds = new CASTSimpleDeclSpecifier();
+ doubleComplexSds.setType(IASTSimpleDeclSpecifier.t_double);
+ doubleComplexSds.setComplex(true);
+ ICASTSimpleDeclSpecifier floatComplexSds = new CASTSimpleDeclSpecifier();
+ floatComplexSds.setType(IASTSimpleDeclSpecifier.t_float);
+ floatComplexSds.setComplex(true);
+ IType c_double_complex = new CBasicType(doubleComplexSds);
+ IType cpp_double_complex = new GPPBasicType(IGPPBasicType.t_double, GPPBasicType.IS_COMPLEX, null);
+ IType c_float_complex = new CBasicType(floatComplexSds);
+ IType cpp_float_complex = new GPPBasicType(IGPPBasicType.t_float, GPPBasicType.IS_COMPLEX, null);
ICASTSimpleDeclSpecifier longDoubleComplexSds = new CASTSimpleDeclSpecifier();
- longDoubleComplexSds.setType(ICASTSimpleDeclSpecifier.t_Complex);
+ longDoubleComplexSds.setType(IASTSimpleDeclSpecifier.t_double);
+ longDoubleComplexSds.setComplex(true);
longDoubleComplexSds.setLong(true);
IType c_long_double_complex = new CBasicType(longDoubleComplexSds);
- IType cpp_long_double_complex = new CPPBasicType(IGPPBasicType.t_Complex, CPPBasicType.IS_LONG);
+ IType cpp_long_double_complex = new GPPBasicType(IGPPBasicType.t_double, CPPBasicType.IS_LONG & GPPBasicType.IS_COMPLEX, null);
// double complex __builtin_conj(double complex)
if (lang == ParserLanguage.C) {
@@ -1153,17 +1158,22 @@ public class GCCBuiltinSymbolProvider implements IASTBuiltinSymbolProvider {
private void __builtin_creal_cimag() {
IBinding temp = null;
- ICASTSimpleDeclSpecifier complexSds = new CASTSimpleDeclSpecifier();
- complexSds.setType(ICASTSimpleDeclSpecifier.t_Complex);
- IType c_double_complex = new CBasicType(complexSds);
- IType cpp_double_complex = new CPPBasicType(IGPPBasicType.t_Complex, 0);
- IType c_float_complex = c_double_complex;
- IType cpp_float_complex = cpp_double_complex;
+ ICASTSimpleDeclSpecifier doubleComplexSds = new CASTSimpleDeclSpecifier();
+ doubleComplexSds.setType(IASTSimpleDeclSpecifier.t_double);
+ doubleComplexSds.setComplex(true);
+ ICASTSimpleDeclSpecifier floatComplexSds = new CASTSimpleDeclSpecifier();
+ floatComplexSds.setType(IASTSimpleDeclSpecifier.t_float);
+ floatComplexSds.setComplex(true);
+ IType c_double_complex = new CBasicType(doubleComplexSds);
+ IType cpp_double_complex = new GPPBasicType(IGPPBasicType.t_double, GPPBasicType.IS_COMPLEX, null);
+ IType c_float_complex = new CBasicType(floatComplexSds);
+ IType cpp_float_complex = new GPPBasicType(IGPPBasicType.t_float, GPPBasicType.IS_COMPLEX, null);
ICASTSimpleDeclSpecifier longDoubleComplexSds = new CASTSimpleDeclSpecifier();
- longDoubleComplexSds.setType(ICASTSimpleDeclSpecifier.t_Complex);
+ longDoubleComplexSds.setType(IASTSimpleDeclSpecifier.t_double);
+ longDoubleComplexSds.setComplex(true);
longDoubleComplexSds.setLong(true);
IType c_long_double_complex = new CBasicType(longDoubleComplexSds);
- IType cpp_long_double_complex = new CPPBasicType(IGPPBasicType.t_Complex, CPPBasicType.IS_LONG);
+ IType cpp_long_double_complex = new GPPBasicType(IGPPBasicType.t_double, CPPBasicType.IS_LONG & GPPBasicType.IS_COMPLEX, null);
ICASTSimpleDeclSpecifier doubleSds = new CASTSimpleDeclSpecifier();
doubleSds.setType(IASTSimpleDeclSpecifier.t_double);
IType c_double = new CBasicType(doubleSds);
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 8d4fe171148..1a70338d8d4 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
@@ -23,7 +23,8 @@ public class CASTSimpleDeclSpecifier extends CASTBaseDeclSpecifier implements IC
private boolean isShort;
private boolean isLong;
private boolean longlong;
-
+ private boolean complex=false;
+ private boolean imaginary=false;
/* (non-Javadoc)
* @see org.eclipse.cdt.core.dom.ast.IASTSimpleDeclSpecifier#getType()
@@ -120,4 +121,32 @@ public class CASTSimpleDeclSpecifier extends CASTBaseDeclSpecifier implements IC
return true;
}
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.core.dom.ast.c.ICASTSimpleDeclSpecifier#isComplex()
+ */
+ public boolean isComplex() {
+ return complex;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.core.dom.ast.c.ICASTSimpleDeclSpecifier#setComplex(boolean)
+ */
+ public void setComplex(boolean value) {
+ this.complex = value;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.core.dom.ast.c.ICASTSimpleDeclSpecifier#isImaginary()
+ */
+ public boolean isImaginary() {
+ return imaginary;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.core.dom.ast.c.ICASTSimpleDeclSpecifier#setImaginary(boolean)
+ */
+ public void setImaginary(boolean value) {
+ this.imaginary = value;
+ }
+
}
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CBasicType.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CBasicType.java
index 7cd6f060125..9450b6ec050 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CBasicType.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CBasicType.java
@@ -11,6 +11,7 @@
package org.eclipse.cdt.internal.core.dom.parser.c;
import org.eclipse.cdt.core.dom.ast.IASTExpression;
+import org.eclipse.cdt.core.dom.ast.IBasicType;
import org.eclipse.cdt.core.dom.ast.IType;
import org.eclipse.cdt.core.dom.ast.ITypedef;
import org.eclipse.cdt.core.dom.ast.c.ICASTSimpleDeclSpecifier;
@@ -25,6 +26,8 @@ public class CBasicType implements ICBasicType {
static public final int IS_SHORT = 1 << 2;
static public final int IS_SIGNED = 1 << 3;
static public final int IS_UNSIGNED = 1 << 4;
+ static public final int IS_COMPLEX = 1 << 5;
+ static public final int IS_IMAGINARY= 1 << 6;
private int type = 0;
private int qualifiers = 0;
@@ -41,12 +44,28 @@ public class CBasicType implements ICBasicType {
( sds.isShort() ? CBasicType.IS_SHORT : 0 ) |
( sds.isSigned() ? CBasicType.IS_SIGNED: 0 ) |
( sds.isUnsigned()? CBasicType.IS_UNSIGNED : 0 ) |
- ( sds.isUnsigned()? CBasicType.IS_LONGLONG : 0 );
+ ( sds.isUnsigned()? CBasicType.IS_LONGLONG : 0 ) |
+ ( sds.isComplex() ? CBasicType.IS_COMPLEX : 0 ) |
+ ( sds.isImaginary()?CBasicType.IS_IMAGINARY : 0 );
+
+ if( type == IBasicType.t_unspecified ){
+ if( (qualifiers & ( IS_COMPLEX | IS_IMAGINARY )) != 0 )
+ type = IBasicType.t_float;
+ else if( (qualifiers & ~( IS_COMPLEX | IS_IMAGINARY )) != 0 )
+ type = IBasicType.t_int;
+ }
}
public CBasicType( int type, int qualifiers ){
this.type = type;
this.qualifiers = qualifiers;
+
+ if( type == IBasicType.t_unspecified ){
+ if( (qualifiers & ( IS_COMPLEX | IS_IMAGINARY )) != 0 )
+ type = IBasicType.t_float;
+ else if( (qualifiers & ~( IS_COMPLEX | IS_IMAGINARY )) != 0 )
+ type = IBasicType.t_int;
+ }
}
public CBasicType( int type, int qualifiers, IASTExpression value ){
@@ -109,7 +128,9 @@ public class CBasicType implements ICBasicType {
&& cObj.isShort() == this.isShort()
&& cObj.isSigned() == this.isSigned()
&& cObj.isUnsigned() == this.isUnsigned()
- && cObj.isLongLong() == this.isLongLong());
+ && cObj.isLongLong() == this.isLongLong()
+ && cObj.isComplex() == this.isComplex()
+ && cObj.isImaginary() == this.isImaginary());
}
public Object clone(){
@@ -132,4 +153,18 @@ public class CBasicType implements ICBasicType {
public void setValue( IASTExpression expression ){
this.value = expression;
}
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.core.dom.ast.c.ICBasicType#isComplex()
+ */
+ public boolean isComplex() {
+ return ( qualifiers & IS_COMPLEX) != 0;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.core.dom.ast.c.ICBasicType#isImaginary()
+ */
+ public boolean isImaginary() {
+ return ( qualifiers & IS_IMAGINARY) != 0;
+ }
}
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 363c82a4a9b..043971ec5af 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
@@ -1337,6 +1337,7 @@ public class GNUCSourceParser extends AbstractGNUSourceCodeParser {
boolean isInline = false;
boolean isConst = false, isRestrict = false, isVolatile = false;
boolean isShort = false, isLong = false, isUnsigned = false, isIdentifier = false, isSigned = false, isLongLong = false;
+ boolean isComplex = false, isImaginary = false;
int simpleType = IASTSimpleDeclSpecifier.t_unspecified;
IToken identifier = null;
IASTCompositeTypeSpecifier structSpec = null;
@@ -1446,11 +1447,11 @@ public class GNUCSourceParser extends AbstractGNUSourceCodeParser {
break;
case IToken.t__Complex:
last = consume(IToken.t__Complex);
- simpleType = ICASTSimpleDeclSpecifier.t_Complex;
+ isComplex=true;
break;
case IToken.t__Imaginary:
last = consume(IToken.t__Imaginary);
- simpleType = ICASTSimpleDeclSpecifier.t_Imaginary;
+ isImaginary=true;
break;
case IToken.tIDENTIFIER:
@@ -1617,6 +1618,8 @@ public class GNUCSourceParser extends AbstractGNUSourceCodeParser {
declSpec.setUnsigned(isUnsigned);
declSpec.setSigned(isSigned);
declSpec.setShort(isShort);
+ declSpec.setComplex(isComplex);
+ declSpec.setImaginary(isImaginary);
if( typeofExpression != null && last == null ){
((ASTNode)declSpec).setOffsetAndLength( (ASTNode)typeofExpression );
} else {
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 01bf70291e8..b9d88703645 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
@@ -14,6 +14,7 @@
package org.eclipse.cdt.internal.core.dom.parser.cpp;
import org.eclipse.cdt.core.dom.ast.IASTExpression;
+import org.eclipse.cdt.core.dom.ast.IBasicType;
import org.eclipse.cdt.core.dom.ast.IType;
import org.eclipse.cdt.core.dom.ast.ITypedef;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPBasicType;
@@ -35,6 +36,11 @@ public class CPPBasicType implements ICPPBasicType {
public CPPBasicType( int t, int bits ){
type = t;
qualifierBits = bits;
+
+ if( type == IBasicType.t_unspecified ){
+ if( (qualifierBits & ( IS_LONG | IS_SHORT | IS_SIGNED | IS_UNSIGNED )) != 0 )
+ type = IBasicType.t_int;
+ }
}
public CPPBasicType( int t, int bits, IASTExpression val ){
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPSemantics.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPSemantics.java
index 944df4ecca8..1d03a772ad1 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPSemantics.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPSemantics.java
@@ -2708,7 +2708,8 @@ public class CPPSemantics {
if( src instanceof IBasicType && trg instanceof IBasicType ){
int sType = ((IBasicType)src).getType();
int tType = ((IBasicType)trg).getType();
- if( ( tType == IBasicType.t_int && ( sType == IBasicType.t_char ||
+ if( ( tType == IBasicType.t_int && ( sType == IBasicType.t_int || //short, long , unsigned etc
+ sType == IBasicType.t_char ||
sType == ICPPBasicType.t_bool ||
sType == ICPPBasicType.t_wchar_t ||
sType == IBasicType.t_unspecified ) ) || //treat unspecified as int
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 bf1d13a5a52..4ac855c65a6 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
@@ -3169,6 +3169,7 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser {
boolean isInline = false, isVirtual = false, isExplicit = false, isFriend = false;
boolean isConst = false, isVolatile = false, isRestrict = false;
boolean isLong = false, isShort = false, isUnsigned = false, isSigned = false, isLongLong = false;
+ boolean isComplex = false, isImaginary = false;
boolean isTypename = false;
int storageClass = IASTDeclSpecifier.sc_unspecified;
@@ -3271,7 +3272,7 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser {
- la.getOffset());
}
last = consume(IToken.t__Complex);
- simpleType = IGPPASTSimpleDeclSpecifier.t_Complex;
+ isComplex=true;
break;
case IToken.t__Imaginary:
if (!supportComplex) {
@@ -3279,7 +3280,7 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser {
throwBacktrack(la.getOffset(), la.getLength());
}
last = consume(IToken.t__Imaginary);
- simpleType = IGPPASTSimpleDeclSpecifier.t_Imaginary;
+ isImaginary=true;
break;
case IToken.t_char:
simpleType = IASTSimpleDeclSpecifier.t_char;
@@ -3487,10 +3488,14 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser {
return nameSpec;
}
ICPPASTSimpleDeclSpecifier simpleDeclSpec = null;
- if (isLongLong || typeofExpression != null) {
+ if (isComplex || isImaginary || isLongLong || typeofExpression != null) {
simpleDeclSpec = createGPPSimpleDeclSpecifier();
((IGPPASTSimpleDeclSpecifier) simpleDeclSpec)
.setLongLong(isLongLong);
+ ((IGPPASTSimpleDeclSpecifier) simpleDeclSpec)
+ .setComplex(isComplex);
+ ((IGPPASTSimpleDeclSpecifier) simpleDeclSpec)
+ .setImaginary(isImaginary);
if (typeofExpression != null) {
((IGPPASTSimpleDeclSpecifier) simpleDeclSpec)
.setTypeofExpression(typeofExpression);
@@ -3524,7 +3529,7 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser {
simpleDeclSpec.setShort(isShort);
simpleDeclSpec.setUnsigned(isUnsigned);
simpleDeclSpec.setSigned(isSigned);
-
+
return simpleDeclSpec;
}
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 44758e35a2b..cf5e243b64c 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
@@ -22,6 +22,8 @@ public class GPPASTSimpleDeclSpecifier extends CPPASTSimpleDeclSpecifier
private boolean longLong;
private boolean restrict;
+ private boolean complex=false;
+ private boolean imaginary=false;
private IASTExpression typeOfExpression;
/* (non-Javadoc)
@@ -79,4 +81,20 @@ public class GPPASTSimpleDeclSpecifier extends CPPASTSimpleDeclSpecifier
return true;
}
+
+ public boolean isComplex() {
+ return complex;
+ }
+
+ public void setComplex(boolean value) {
+ this.complex = value;
+ }
+
+ public boolean isImaginary() {
+ return imaginary;
+ }
+
+ public void setImaginary(boolean value) {
+ this.imaginary = value;
+ }
}
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/GPPBasicType.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/GPPBasicType.java
index 4be8f9fe5c8..2b1c0743d2a 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/GPPBasicType.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/GPPBasicType.java
@@ -13,6 +13,7 @@
*/
package org.eclipse.cdt.internal.core.dom.parser.cpp;
+import org.eclipse.cdt.core.dom.ast.IBasicType;
import org.eclipse.cdt.core.dom.ast.IType;
import org.eclipse.cdt.core.dom.ast.gnu.cpp.IGPPASTSimpleDeclSpecifier;
import org.eclipse.cdt.core.dom.ast.gnu.cpp.IGPPBasicType;
@@ -22,12 +23,20 @@ import org.eclipse.cdt.core.dom.ast.gnu.cpp.IGPPBasicType;
*/
public class GPPBasicType extends CPPBasicType implements IGPPBasicType {
public static final int IS_LONGLONG = LAST << 1;
+ public static final int IS_COMPLEX = LAST << 2;
+ public static final int IS_IMAGINARY = LAST << 3;
private IType typeOf;
public GPPBasicType( int type, int bits, IType typeOf ){
super( type, bits );
this.typeOf = typeOf;
+ if( type == IBasicType.t_unspecified ){
+ if((qualifierBits & ( IS_COMPLEX | IS_IMAGINARY )) != 0 )
+ type = IBasicType.t_float;
+ else if( (qualifierBits & IS_LONGLONG) != 0 )
+ type = IBasicType.t_int;
+ }
}
/* (non-Javadoc)
@@ -46,4 +55,12 @@ public class GPPBasicType extends CPPBasicType implements IGPPBasicType {
return typeOf;
}
+ public boolean isComplex() {
+ return ( qualifierBits & IS_COMPLEX ) != 0;
+ }
+
+ public boolean isImaginary() {
+ return ( qualifierBits & IS_IMAGINARY ) != 0;
+ }
+
}