1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-08-08 08:45:44 +02:00

Support for __float128 type introduced in GCC 4.7.

This commit is contained in:
Sergey Prigogin 2012-11-25 14:33:44 -08:00
parent 8a9d64443a
commit 8c668bd877
19 changed files with 119 additions and 15 deletions

View file

@ -425,4 +425,11 @@ public class GCCCompleteParseExtensionsTest extends AST2BaseTest {
parseGCC(code);
parseGPP(code);
}
// __float128 f;
public void test__float128() throws Exception {
String code= getAboveComment();
parseGCC(code);
parseGPP(code);
}
}

View file

@ -8,6 +8,18 @@
</message_arguments>
</filter>
</resource>
<resource path="parser/org/eclipse/cdt/core/dom/ast/IASTSimpleDeclSpecifier.java" type="org.eclipse.cdt.core.dom.ast.IASTSimpleDeclSpecifier">
<filter id="1211105284">
<message_arguments>
<message_argument value="t_float128"/>
</message_arguments>
</filter>
<filter id="1211105284">
<message_arguments>
<message_argument value="t_int128"/>
</message_arguments>
</filter>
</resource>
<resource path="parser/org/eclipse/cdt/core/dom/ast/IASTTypeIdExpression.java" type="org.eclipse.cdt.core.dom.ast.IASTTypeIdExpression">
<filter id="1209008130">
<message_arguments>
@ -37,6 +49,18 @@
</message_arguments>
</filter>
</resource>
<resource path="parser/org/eclipse/cdt/core/dom/ast/IBasicType.java" type="org.eclipse.cdt.core.dom.ast.IBasicType$Kind">
<filter id="1177550852">
<message_arguments>
<message_argument value="eFloat128"/>
</message_arguments>
</filter>
<filter id="1177550852">
<message_arguments>
<message_argument value="eInt128"/>
</message_arguments>
</filter>
</resource>
<resource path="parser/org/eclipse/cdt/core/dom/ast/IScope.java" type="org.eclipse.cdt.core.dom.ast.IScope$ScopeLookupData">
<filter id="1211105284">
<message_arguments>
@ -66,11 +90,21 @@
</filter>
</resource>
<resource path="parser/org/eclipse/cdt/core/parser/GCCKeywords.java" type="org.eclipse.cdt.core.parser.GCCKeywords">
<filter id="1143996420">
<message_arguments>
<message_argument value="__FLOAT128"/>
</message_arguments>
</filter>
<filter id="1143996420">
<message_arguments>
<message_argument value="__INT128"/>
</message_arguments>
</filter>
<filter id="1143996420">
<message_arguments>
<message_argument value="cp__float128"/>
</message_arguments>
</filter>
<filter id="1143996420">
<message_arguments>
<message_argument value="cp__int128"/>
@ -108,6 +142,11 @@
<message_argument value="tTT_is_trivial"/>
</message_arguments>
</filter>
<filter id="1211105284">
<message_arguments>
<message_argument value="t__float128"/>
</message_arguments>
</filter>
<filter id="1211105284">
<message_arguments>
<message_argument value="t__int128"/>

View file

@ -635,6 +635,9 @@ public class ASTStringUtil {
case IASTSimpleDeclSpecifier.t_double:
buffer.append(Keywords.DOUBLE).append(' ');
break;
case IASTSimpleDeclSpecifier.t_float128:
buffer.append(GCCKeywords.cp__float128).append(' ');
break;
case IASTSimpleDeclSpecifier.t_bool:
if (simpleDeclSpec instanceof ICASTSimpleDeclSpecifier) {
buffer.append(Keywords.cBOOL).append(' ');

View file

@ -784,6 +784,14 @@ public class ASTSignatureUtil {
result.append(GCCKeywords.__INT128);
needSpace = true;
break;
case IASTSimpleDeclSpecifier.t_float128:
if (needSpace) {
result.append(SPACE);
needSpace = false;
}
result.append(GCCKeywords.__FLOAT128);
needSpace = true;
break;
case IASTSimpleDeclSpecifier.t_void:
if (needSpace) {
result.append(SPACE);

View file

@ -102,10 +102,16 @@ public interface IASTSimpleDeclSpecifier extends IASTDeclSpecifier {
/**
* <code>__int128 i;</code>
* @since 5.5
* Experimental constant. May change without notice.
*/
public static final int t_int128 = 13;
/**
* <code>__float128 i;</code>
* Experimental constant. May change without notice.
*/
public static final int t_float128 = 14;
/**
* @since 5.1
*/

View file

@ -23,7 +23,9 @@ public interface IBasicType extends IType {
*/
enum Kind {
eUnspecified, eVoid, eChar, eWChar, eInt, eFloat, eDouble,
eBoolean, eChar16, eChar32, /** @since 5.4 */ eNullPtr, /** @since 5.5 */ eInt128
eBoolean, eChar16, eChar32, /** @since 5.4 */ eNullPtr,
/** Experimental constant. May change without notice. */ eInt128,
/** Experimental constant. May change without notice. */ eFloat128
}
/** @since 5.2 */

View file

@ -36,7 +36,7 @@ public class GCCScannerExtensionConfiguration extends GNUScannerExtensionConfigu
}
/**
* @since 5.5
* @noreference This method is not intended to be referenced by clients.
*/
public static GCCScannerExtensionConfiguration getInstance(IScannerInfo info) {
if (info != null) {
@ -60,7 +60,7 @@ public class GCCScannerExtensionConfiguration extends GNUScannerExtensionConfigu
}
/**
* @since 5.5
* @noreference This method is not intended to be referenced by clients.
*/
@SuppressWarnings("nls")
public GCCScannerExtensionConfiguration(int version) {
@ -68,6 +68,7 @@ public class GCCScannerExtensionConfiguration extends GNUScannerExtensionConfigu
addMacro("__builtin_offsetof(T,m)", "((size_t) &((T *)0)->m)");
if (version >= VERSION_4_7) {
addKeyword(GCCKeywords.cp__float128, IGCCToken.t__float128);
addKeyword(GCCKeywords.cp__int128, IGCCToken.t__int128);
}
}

View file

@ -104,6 +104,7 @@ public class GPPScannerExtensionConfiguration extends GNUScannerExtensionConfigu
addKeyword(GCCKeywords.cp__is_trivial, IGCCToken.tTT_is_trivial);
}
if (version >= VERSION_4_7) {
addKeyword(GCCKeywords.cp__float128, IGCCToken.t__float128);
addKeyword(GCCKeywords.cp__int128, IGCCToken.t__int128);
}
}

View file

@ -23,8 +23,10 @@ public class GCCKeywords {
public static final String __ALIGNOF__ = "__alignof__";
public static final String __ATTRIBUTE__ = "__attribute__";
public static final String __DECLSPEC = "__declspec";
/** Experimental API. May change without notice. */
/** Experimental constant. May change without notice. */
public static final String __INT128 = "__int128";
/** Experimental constant. May change without notice. */
public static final String __FLOAT128 = "__float128";
public static final char[]
cpTYPEOF = TYPEOF.toCharArray(),
@ -68,9 +70,10 @@ public class GCCKeywords {
cp__is_union= "__is_union".toCharArray();
/**
* Experimental API. May change without notice.
* Experimental constants. May change without notice.
*/
public static final char[]
cp__float128= __FLOAT128.toCharArray(),
cp__int128= __INT128.toCharArray(),
cp__is_literal_type= "__is_literal_type".toCharArray(),
cp__is_standard_layout= "__is_standard_layout".toCharArray(),

View file

@ -46,4 +46,5 @@ public interface IGCCToken extends IToken {
int tTT_is_standard_layout= FIRST_RESERVED_IGCCToken + 23;
int tTT_is_trivial= FIRST_RESERVED_IGCCToken + 24;
int t__int128 = FIRST_RESERVED_IGCCToken + 25;
int t__float128= FIRST_RESERVED_IGCCToken + 26;
}

View file

@ -2591,12 +2591,13 @@ public abstract class AbstractGNUSourceCodeParser implements ISourceCodeParser {
case IToken.t_short:
case IToken.t_int:
case IToken.t_long:
case IGCCToken.t__int128:
case IToken.t_float:
case IToken.t_double:
case IToken.t__Bool:
case IToken.t__Complex:
case IToken.t__Imaginary:
case IGCCToken.t__int128:
case IGCCToken.t__float128:
case IToken.t_signed:
case IToken.t_unsigned:
case IToken.t_decltype:

View file

@ -73,6 +73,8 @@ public class SizeofCalculator {
public final SizeAndAlignment sizeof_complex_double;
public final SizeAndAlignment sizeof_long_double;
public final SizeAndAlignment sizeof_complex_long_double;
public final SizeAndAlignment sizeof_float128;
public final SizeAndAlignment sizeof_complex_float128;
private final IASTTranslationUnit ast;
@ -135,6 +137,8 @@ public class SizeofCalculator {
sizeof_complex_double = getSizeOfPair(sizeof_double);
sizeof_long_double = getSize(sizeofMacros, "__SIZEOF_LONG_DOUBLE__", maxAlignment); //$NON-NLS-1$
sizeof_complex_long_double = getSizeOfPair(sizeof_long_double);
sizeof_float128 = size_16; // GCC does not define __SIZEOF_FLOAT128__
sizeof_complex_float128 = getSizeOfPair(sizeof_float128);
}
private SizeofCalculator() {
@ -156,6 +160,8 @@ public class SizeofCalculator {
sizeof_complex_double = null;
sizeof_long_double = null;
sizeof_complex_long_double = null;
sizeof_float128 = size_16;
sizeof_complex_float128 = getSizeOfPair(sizeof_float128);
ast = null;
}
@ -215,6 +221,8 @@ public class SizeofCalculator {
return type.isComplex() ?
(type.isLong() ? sizeof_long_double : sizeof_double) :
(type.isLong() ? sizeof_complex_long_double : sizeof_complex_double);
case eFloat128:
return type.isComplex() ? sizeof_complex_float128 : sizeof_float128;
case eWChar:
return sizeof_wchar_t;
case eChar16:

View file

@ -6,9 +6,9 @@
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* John Camelon (IBM Rational Software) - Initial API and implementation
* Yuan Zhang / Beth Tibbitts (IBM Research)
* Markus Schorn (Wind River Systems)
* John Camelon (IBM Rational Software) - Initial API and implementation
* Yuan Zhang / Beth Tibbitts (IBM Research)
* Markus Schorn (Wind River Systems)
*******************************************************************************/
package org.eclipse.cdt.internal.core.dom.parser.c;
@ -19,17 +19,16 @@ 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,
IASTAmbiguityParent {
public class CASTSimpleDeclSpecifier extends CASTBaseDeclSpecifier
implements ICASTSimpleDeclSpecifier, IASTAmbiguityParent {
private int simpleType;
private boolean isSigned;
private boolean isUnsigned;
private boolean isShort;
private boolean isLong;
private boolean longlong;
private boolean complex=false;
private boolean imaginary=false;
private boolean complex;
private boolean imaginary;
private IASTExpression fDeclTypeExpression;
@Override
@ -110,6 +109,8 @@ public class CASTSimpleDeclSpecifier extends CASTBaseDeclSpecifier implements IC
return t_double;
case eFloat:
return t_float;
case eFloat128:
return t_float;
case eInt:
return t_int;
case eInt128:

View file

@ -69,6 +69,8 @@ public class CBasicType implements ICBasicType, ISerializableType {
return Kind.eDouble;
case IASTSimpleDeclSpecifier.t_float:
return Kind.eFloat;
case IASTSimpleDeclSpecifier.t_float128:
return Kind.eFloat128;
case IASTSimpleDeclSpecifier.t_int:
return Kind.eInt;
case IASTSimpleDeclSpecifier.t_int128:

View file

@ -1030,6 +1030,13 @@ public class GNUCSourceParser extends AbstractGNUSourceCodeParser {
encounteredRawType= true;
endOffset= consume().getEndOffset();
break;
case IGCCToken.t__float128:
if (encounteredTypename)
break declSpecifiers;
simpleType = IASTSimpleDeclSpecifier.t_float128;
encounteredRawType= true;
endOffset= consume().getEndOffset();
break;
case IToken.t_signed:
if (encounteredTypename)
break declSpecifiers;

View file

@ -90,6 +90,8 @@ public class CPPASTSimpleDeclSpecifier extends CPPASTBaseDeclSpecifier
return t_double;
case eFloat:
return t_float;
case eFloat128:
return t_float128;
case eInt:
return t_int;
case eInt128:

View file

@ -100,6 +100,8 @@ public class CPPBasicType implements ICPPBasicType, ISerializableType {
return Kind.eDouble;
case IASTSimpleDeclSpecifier.t_float:
return Kind.eFloat;
case IASTSimpleDeclSpecifier.t_float128:
return Kind.eFloat128;
case IASTSimpleDeclSpecifier.t_int:
return Kind.eInt;
case IASTSimpleDeclSpecifier.t_int128:

View file

@ -66,6 +66,7 @@ import org.eclipse.cdt.core.dom.ast.IASTUnaryExpression;
import org.eclipse.cdt.core.dom.ast.IASTWhileStatement;
import org.eclipse.cdt.core.dom.ast.IBinding;
import org.eclipse.cdt.core.dom.ast.IScope;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTAliasDeclaration;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTAmbiguousTemplateArgument;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTArrayDeclarator;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTCapture;
@ -2844,6 +2845,13 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser {
encounteredRawType= true;
endOffset= consume().getEndOffset();
break;
case IGCCToken.t__float128:
if (encounteredTypename)
break declSpecifiers;
simpleType = IASTSimpleDeclSpecifier.t_float128;
encounteredRawType= true;
endOffset= consume().getEndOffset();
break;
case IToken.t_void:
if (encounteredTypename)
break declSpecifiers;

View file

@ -87,6 +87,8 @@ public class DeclSpecWriter extends NodeWriter {
return Keywords.FLOAT;
case IASTSimpleDeclSpecifier.t_double:
return Keywords.DOUBLE;
case IASTSimpleDeclSpecifier.t_float128:
return GCCKeywords.__FLOAT128;
case IASTSimpleDeclSpecifier.t_bool:
return isCpp ? Keywords.BOOL : Keywords._BOOL;