mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-29 19:45:01 +02:00
Support for __float128 type introduced in GCC 4.7.
This commit is contained in:
parent
d61fcc17ce
commit
a00758b82c
18 changed files with 75 additions and 11 deletions
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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(' ');
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -106,6 +106,12 @@ public interface IASTSimpleDeclSpecifier extends IASTDeclSpecifier {
|
|||
*/
|
||||
public static final int t_int128 = 13;
|
||||
|
||||
/**
|
||||
* <code>__float128 i;</code>
|
||||
* @since 5.5
|
||||
*/
|
||||
public static final int t_float128 = 14;
|
||||
|
||||
/**
|
||||
* @since 5.1
|
||||
*/
|
||||
|
|
|
@ -23,7 +23,8 @@ 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,
|
||||
/** @since 5.5 */ eInt128, /** @since 5.5 */ eFloat128
|
||||
}
|
||||
|
||||
/** @since 5.2 */
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -25,6 +25,8 @@ public class GCCKeywords {
|
|||
public static final String __DECLSPEC = "__declspec";
|
||||
/** @since 5.5 */
|
||||
public static final String __INT128 = "__int128";
|
||||
/** @since 5.5 */
|
||||
public static final String __FLOAT128 = "__float128";
|
||||
|
||||
public static final char[]
|
||||
cpTYPEOF = TYPEOF.toCharArray(),
|
||||
|
@ -69,6 +71,7 @@ public class GCCKeywords {
|
|||
|
||||
/** @since 5.5 */
|
||||
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(),
|
||||
|
|
|
@ -45,5 +45,6 @@ public interface IGCCToken extends IToken {
|
|||
/** @since 5.5 */ int tTT_is_standard_layout= FIRST_RESERVED_IGCCToken + 23;
|
||||
/** @since 5.5 */ int tTT_is_trivial= FIRST_RESERVED_IGCCToken + 24;
|
||||
|
||||
/** @since 5.5 */ int t__int128 = FIRST_RESERVED_IGCCToken + 25;
|
||||
/** @since 5.5 */ int t__int128= FIRST_RESERVED_IGCCToken + 25;
|
||||
/** @since 5.5 */ int t__float128= FIRST_RESERVED_IGCCToken + 26;
|
||||
}
|
||||
|
|
|
@ -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:
|
||||
|
|
|
@ -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:
|
||||
|
|
|
@ -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:
|
||||
|
|
|
@ -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:
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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:
|
||||
|
|
|
@ -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:
|
||||
|
|
|
@ -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;
|
||||
|
@ -2851,6 +2852,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;
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Add table
Reference in a new issue