diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2BaseTest.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2BaseTest.java index dbebb3faec8..814b5d1b62f 100644 --- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2BaseTest.java +++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2BaseTest.java @@ -153,18 +153,20 @@ public class AST2BaseTest extends BaseTestCase { AbstractGNUSourceCodeParser parser = null; if (lang == ParserLanguage.CPP) { ICPPParserExtensionConfiguration config = null; - if (useGNUExtensions) + if (useGNUExtensions) { config = new GPPParserExtensionConfiguration(); - else + } else { config = new ANSICPPParserExtensionConfiguration(); + } parser = new GNUCPPSourceParser(scanner, ParserMode.COMPLETE_PARSE, NULL_LOG,config, null); } else { ICParserExtensionConfiguration config = null; - if (useGNUExtensions) + if (useGNUExtensions) { config = new GCCParserExtensionConfiguration(); - else + } else { config = new ANSICParserExtensionConfiguration(); + } parser = new GNUCSourceParser(scanner, ParserMode.COMPLETE_PARSE, NULL_LOG, config, null); } @@ -204,10 +206,11 @@ public class AST2BaseTest extends BaseTestCase { public static IScanner createScanner(FileContent codeReader, ParserLanguage lang, ParserMode mode, IScannerInfo scannerInfo) { IScannerExtensionConfiguration configuration = null; - if (lang == ParserLanguage.C) - configuration= GCCScannerExtensionConfiguration.getInstance(); - else + if (lang == ParserLanguage.C) { + configuration= GCCScannerExtensionConfiguration.getInstance(scannerInfo); + } else { configuration= GPPScannerExtensionConfiguration.getInstance(scannerInfo); + } IScanner scanner; scanner= new CPreprocessor(codeReader, scannerInfo, lang, NULL_LOG, configuration, IncludeFileContentProvider.getSavedFilesProvider()); diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/GCCCompleteParseExtensionsTest.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/GCCCompleteParseExtensionsTest.java index 52f78c60ff0..f031afca0a5 100644 --- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/GCCCompleteParseExtensionsTest.java +++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/GCCCompleteParseExtensionsTest.java @@ -417,4 +417,12 @@ public class GCCCompleteParseExtensionsTest extends AST2BaseTest { public void testTypeTraits_Bug342683() throws Exception { parseGPP(getAboveComment()); } + + // __int128 a; + // unsigned __int128 b; + public void test__int128() throws Exception { + String code= getAboveComment(); + parseGCC(code); + parseGPP(code); + } } diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/rewrite/changegenerator/insertbefore/AddDeclarationBug.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/rewrite/changegenerator/insertbefore/AddDeclarationBugTest.java similarity index 88% rename from core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/rewrite/changegenerator/insertbefore/AddDeclarationBug.java rename to core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/rewrite/changegenerator/insertbefore/AddDeclarationBugTest.java index e02fd1869bf..31d6ca8e89e 100644 --- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/rewrite/changegenerator/insertbefore/AddDeclarationBug.java +++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/rewrite/changegenerator/insertbefore/AddDeclarationBugTest.java @@ -35,14 +35,14 @@ import org.eclipse.cdt.internal.core.dom.rewrite.ASTModificationStore; /** * @author Emanuel Graf IFS */ -public class AddDeclarationBug extends ChangeGeneratorTest { +public class AddDeclarationBugTest extends ChangeGeneratorTest { - AddDeclarationBug() { + AddDeclarationBugTest() { super("AddDeclarationBug"); } public static Test suite() { - return new AddDeclarationBug(); + return new AddDeclarationBugTest(); } @Override @@ -65,16 +65,16 @@ public class AddDeclarationBug extends ChangeGeneratorTest { ICPPASTCompositeTypeSpecifier classNode = (ICPPASTCompositeTypeSpecifier) declSpec; IASTSimpleDeclaration newDecl = new CPPASTSimpleDeclaration(); - IASTSimpleDeclSpecifier returnTyp = new CPPASTSimpleDeclSpecifier(); - returnTyp.setType(IASTSimpleDeclSpecifier.t_int); - newDecl.setDeclSpecifier(returnTyp); + IASTSimpleDeclSpecifier returnType = new CPPASTSimpleDeclSpecifier(); + returnType.setType(IASTSimpleDeclSpecifier.t_int); + newDecl.setDeclSpecifier(returnType); IASTStandardFunctionDeclarator declarator = new CPPASTFunctionDeclarator( new CPPASTName("exp".toCharArray())); //$NON-NLS-1$ - IASTSimpleDeclSpecifier paramTyp = new CPPASTSimpleDeclSpecifier(); - paramTyp.setType(IASTSimpleDeclSpecifier.t_int); + IASTSimpleDeclSpecifier paramType = new CPPASTSimpleDeclSpecifier(); + paramType.setType(IASTSimpleDeclSpecifier.t_int); IASTDeclarator decl = new CPPASTDeclarator(new CPPASTName("i".toCharArray())); //$NON-NLS-1$ - ICPPASTParameterDeclaration param = new CPPASTParameterDeclaration(paramTyp, decl); + ICPPASTParameterDeclaration param = new CPPASTParameterDeclaration(paramType, decl); declarator.addParameterDeclaration(param); newDecl.addDeclarator(declarator); diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/rewrite/changegenerator/insertbefore/InsertBeforeTestSuite.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/rewrite/changegenerator/insertbefore/InsertBeforeTestSuite.java index 4fcc0039c70..f22e76c32e0 100644 --- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/rewrite/changegenerator/insertbefore/InsertBeforeTestSuite.java +++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/rewrite/changegenerator/insertbefore/InsertBeforeTestSuite.java @@ -29,7 +29,7 @@ public class InsertBeforeTestSuite { suite.addTest(ArrayModifierTest.suite()); suite.addTest(ExpressionTest.suite()); suite.addTest(ArraySizeExpressionTest.suite()); - suite.addTest(AddDeclarationBug.suite()); + suite.addTest(AddDeclarationBugTest.suite()); suite.addTest(MultilineWhitespaceHandlingTest.suite()); suite.addTest(SelfInsertionTest.suite()); diff --git a/core/org.eclipse.cdt.core/.settings/.api_filters b/core/org.eclipse.cdt.core/.settings/.api_filters index d0bd80cfa84..76043c21887 100644 --- a/core/org.eclipse.cdt.core/.settings/.api_filters +++ b/core/org.eclipse.cdt.core/.settings/.api_filters @@ -66,6 +66,16 @@ + + + + + + + + + + @@ -98,6 +108,11 @@ + + + + + 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 b7d37b494cd..6eb4359f1ab 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 @@ -73,6 +73,7 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTTypeIdExpression; 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.c.ICASTKnRFunctionDeclarator; +import org.eclipse.cdt.core.parser.GCCKeywords; import org.eclipse.cdt.core.parser.Keywords; import org.eclipse.cdt.core.parser.util.CharArrayUtils; import org.eclipse.cdt.internal.core.dom.parser.ASTQueries; @@ -625,6 +626,9 @@ public class ASTStringUtil { case IASTSimpleDeclSpecifier.t_int: buffer.append(Keywords.INT).append(' '); break; + case IASTSimpleDeclSpecifier.t_int128: + buffer.append(GCCKeywords.cp__int128).append(' '); + break; case IASTSimpleDeclSpecifier.t_float: buffer.append(Keywords.FLOAT).append(' '); break; 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 4754e8f09e8..8b367ba9017 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 @@ -33,6 +33,7 @@ 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.c.ICASTKnRFunctionDeclarator; import org.eclipse.cdt.core.dom.ast.gnu.c.IGCCASTArrayRangeDesignator; +import org.eclipse.cdt.core.parser.GCCKeywords; import org.eclipse.cdt.core.parser.Keywords; import org.eclipse.cdt.internal.core.dom.parser.ASTProblem; import org.eclipse.cdt.internal.core.model.ASTStringUtil; @@ -775,6 +776,14 @@ public class ASTSignatureUtil { result.append(Keywords.INT); needSpace = true; break; + case IASTSimpleDeclSpecifier.t_int128: + if (needSpace) { + result.append(SPACE); + needSpace = false; + } + result.append(GCCKeywords.__INT128); + needSpace = true; + break; case IASTSimpleDeclSpecifier.t_void: if (needSpace) { result.append(SPACE); 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 b10654669a4..8562e33e5b4 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 @@ -100,6 +100,11 @@ public interface IASTSimpleDeclSpecifier extends IASTDeclSpecifier { */ public static final int t_char32_t = 12; + /** + * __int128 i; + * @since 5.5 + */ + public static final int t_int128 = 13; /** * @since 5.1 diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IBasicType.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IBasicType.java index cae0573c04a..88429ccc4e0 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IBasicType.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IBasicType.java @@ -22,40 +22,25 @@ public interface IBasicType extends IType { * @since 5.2 */ enum Kind { - eUnspecified, eVoid, eChar, eWChar, eInt, eFloat, eDouble, eBoolean, eChar16, eChar32, - /** @since 5.4 */ eNullPtr + eUnspecified, eVoid, eChar, eWChar, eInt, /** @since 5.5 */ eInt128, eFloat, eDouble, + eBoolean, eChar16, eChar32, /** @since 5.4 */ eNullPtr } - /** - * @since 5.2 - */ + /** @since 5.2 */ final int IS_LONG = 1; - /** - * @since 5.2 - */ + /** @since 5.2 */ final int IS_SHORT = 1 << 1; - /** - * @since 5.2 - */ + /** @since 5.2 */ final int IS_SIGNED = 1 << 2; - /** - * @since 5.2 - */ + /** @since 5.2 */ final int IS_UNSIGNED = 1 << 3; - /** - * @since 5.2 - */ + /** @since 5.2 */ final int IS_COMPLEX = 1 << 4; - /** - * @since 5.2 - */ + /** @since 5.2 */ final int IS_IMAGINARY = 1 << 5; - /** - * @since 5.2 - */ + /** @since 5.2 */ final int IS_LONG_LONG = 1 << 6; - /** * This returns the kind of basic type you are looking at. The type is * then refined by qualifiers for signed/unsigned and short/long/long long. diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/gnu/c/GCCLanguage.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/gnu/c/GCCLanguage.java index bb22d42ff5a..36b3711d1fc 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/gnu/c/GCCLanguage.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/gnu/c/GCCLanguage.java @@ -25,6 +25,7 @@ import org.eclipse.cdt.core.dom.parser.c.ICParserExtensionConfiguration; import org.eclipse.cdt.core.index.IIndex; import org.eclipse.cdt.core.parser.IParserLogService; import org.eclipse.cdt.core.parser.IScanner; +import org.eclipse.cdt.core.parser.IScannerInfo; import org.eclipse.cdt.core.parser.ParserLanguage; import org.eclipse.cdt.core.parser.ParserMode; import org.eclipse.cdt.internal.core.dom.parser.c.GNUCSourceParser; @@ -70,6 +71,11 @@ public class GCCLanguage extends AbstractCLikeLanguage { return C_GNU_SCANNER_EXTENSION; } + @Override + protected IScannerExtensionConfiguration getScannerExtensionConfiguration(IScannerInfo info) { + return GCCScannerExtensionConfiguration.getInstance(info); + } + /** * Returns the extension configuration used for creating the parser. * @since 5.1 diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/parser/GNUScannerExtensionConfiguration.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/parser/GNUScannerExtensionConfiguration.java index ba8107ec9f3..b6e62c0f8de 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/parser/GNUScannerExtensionConfiguration.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/parser/GNUScannerExtensionConfiguration.java @@ -27,7 +27,14 @@ import org.eclipse.cdt.core.parser.util.CharArrayIntMap; */ public abstract class GNUScannerExtensionConfiguration extends AbstractScannerExtensionConfiguration { private static GNUScannerExtensionConfiguration sInstance; - + + /** + * @noreference This method is not intended to be referenced by clients. + */ + protected static int version(int major, int minor) { + return (major << 16) + minor; + } + @SuppressWarnings("nls") public GNUScannerExtensionConfiguration() { addMacro("__complex__", "_Complex"); diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/parser/c/GCCScannerExtensionConfiguration.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/parser/c/GCCScannerExtensionConfiguration.java index 0d6ec995977..fc9a3ac3758 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/parser/c/GCCScannerExtensionConfiguration.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/parser/c/GCCScannerExtensionConfiguration.java @@ -1,42 +1,77 @@ /******************************************************************************* - * 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 + * 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 - * Ed Swartz (Nokia) - * Markus Schorn (Wind River Systems) - * Sergey Prigogin (Google) + * Contributors: + * IBM - Initial API and implementation + * Ed Swartz (Nokia) + * Markus Schorn (Wind River Systems) + * Sergey Prigogin (Google) *******************************************************************************/ package org.eclipse.cdt.core.dom.parser.c; +import java.util.Map; + import org.eclipse.cdt.core.dom.parser.GNUScannerExtensionConfiguration; +import org.eclipse.cdt.core.parser.GCCKeywords; +import org.eclipse.cdt.core.parser.IGCCToken; +import org.eclipse.cdt.core.parser.IScannerInfo; /** * Configures the preprocessor for parsing c-sources as accepted by gcc. */ public class GCCScannerExtensionConfiguration extends GNUScannerExtensionConfiguration { + private static final int VERSION_4_7 = version(4, 7); + private static GCCScannerExtensionConfiguration CONFIG= new GCCScannerExtensionConfiguration(); + private static GCCScannerExtensionConfiguration CONFIG_4_7= new GCCScannerExtensionConfiguration(VERSION_4_7); - private static GCCScannerExtensionConfiguration sInstance= new GCCScannerExtensionConfiguration(); /** * @since 5.1 */ public static GCCScannerExtensionConfiguration getInstance() { - return sInstance; + return CONFIG; + } + + /** + * @since 5.5 + */ + public static GCCScannerExtensionConfiguration getInstance(IScannerInfo info) { + if (info != null) { + try { + final Map definedSymbols = info.getDefinedSymbols(); + int major= Integer.valueOf(definedSymbols.get("__GNUC__")); //$NON-NLS-1$ + int minor= Integer.valueOf(definedSymbols.get("__GNUC_MINOR__")); //$NON-NLS-1$ + int version= version(major, minor); + if (version >= VERSION_4_7) { + return CONFIG_4_7; + } + } catch (Exception e) { + // Fall-back to the default configuration. + } + } + return CONFIG; } - @SuppressWarnings("nls") public GCCScannerExtensionConfiguration() { + this(0); + } + + /** + * @since 5.5 + */ + @SuppressWarnings("nls") + public GCCScannerExtensionConfiguration(int version) { addMacro("__null", "(void *)0"); addMacro("__builtin_offsetof(T,m)", "((size_t) &((T *)0)->m)"); + + if (version >= VERSION_4_7) { + addKeyword(GCCKeywords.cp__int128, IGCCToken.t__int128); + } } - /* (non-Javadoc) - * @see org.eclipse.cdt.internal.core.parser.scanner2.IScannerConfiguration#supportMinAndMaxOperators() - */ @Override public boolean supportMinAndMaxOperators() { return false; diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/parser/cpp/GPPScannerExtensionConfiguration.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/parser/cpp/GPPScannerExtensionConfiguration.java index dbeeadf4140..b643cd4652b 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/parser/cpp/GPPScannerExtensionConfiguration.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/parser/cpp/GPPScannerExtensionConfiguration.java @@ -29,13 +29,11 @@ import org.eclipse.cdt.core.parser.Keywords; public class GPPScannerExtensionConfiguration extends GNUScannerExtensionConfiguration { private static final int VERSION_4_3 = version(4, 3); private static final int VERSION_4_6 = version(4, 6); + private static final int VERSION_4_7 = version(4, 7); private static GPPScannerExtensionConfiguration CONFIG= new GPPScannerExtensionConfiguration(); private static GPPScannerExtensionConfiguration CONFIG_4_3= new GPPScannerExtensionConfiguration(VERSION_4_3); private static GPPScannerExtensionConfiguration CONFIG_4_6= new GPPScannerExtensionConfiguration(VERSION_4_6); - - private static int version(int major, int minor) { - return (major << 16) + minor; - } + private static GPPScannerExtensionConfiguration CONFIG_4_7= new GPPScannerExtensionConfiguration(VERSION_4_7); public static GPPScannerExtensionConfiguration getInstance() { return CONFIG; @@ -51,6 +49,9 @@ public class GPPScannerExtensionConfiguration extends GNUScannerExtensionConfigu int major= Integer.valueOf(definedSymbols.get("__GNUC__")); //$NON-NLS-1$ int minor= Integer.valueOf(definedSymbols.get("__GNUC_MINOR__")); //$NON-NLS-1$ int version= version(major, minor); + if (version >= VERSION_4_7) { + return CONFIG_4_7; + } if (version >= VERSION_4_6) { return CONFIG_4_6; } @@ -102,11 +103,11 @@ public class GPPScannerExtensionConfiguration extends GNUScannerExtensionConfigu addKeyword(GCCKeywords.cp__is_standard_layout, IGCCToken.tTT_is_standard_layout); addKeyword(GCCKeywords.cp__is_trivial, IGCCToken.tTT_is_trivial); } + if (version >= VERSION_4_7) { + addKeyword(GCCKeywords.cp__int128, IGCCToken.t__int128); + } } - /* (non-Javadoc) - * @see org.eclipse.cdt.internal.core.parser.scanner2.IScannerConfiguration#supportMinAndMaxOperators() - */ @Override public boolean supportMinAndMaxOperators() { return true; diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/GCCKeywords.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/GCCKeywords.java index 6c424d25e37..93f40b14104 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/GCCKeywords.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/GCCKeywords.java @@ -23,6 +23,8 @@ 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. */ + public static final String __INT128 = "__int128"; public static final char[] cpTYPEOF = TYPEOF.toCharArray(), @@ -46,9 +48,7 @@ public class GCCKeywords { cp__TYPEOF= "__typeof".toCharArray(), cp__TYPEOF__= "__typeof__".toCharArray(); - /** - * @since 5.3 - */ + /** @since 5.3 */ public static final char[] cp__has_nothrow_assign= "__has_nothrow_assign".toCharArray(), cp__has_nothrow_copy= "__has_nothrow_copy".toCharArray(), @@ -71,6 +71,7 @@ public class GCCKeywords { * Experimental API. May change without notice. */ public static final char[] + cp__int128= __INT128.toCharArray(), cp__is_literal_type= "__is_literal_type".toCharArray(), cp__is_standard_layout= "__is_standard_layout".toCharArray(), cp__is_trivial= "__is_trivial".toCharArray(); diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/IGCCToken.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/IGCCToken.java index 716a94fda3a..8ff078dcf53 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/IGCCToken.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/IGCCToken.java @@ -45,4 +45,5 @@ public interface IGCCToken extends IToken { int tTT_is_literal_type= FIRST_RESERVED_IGCCToken + 22; int tTT_is_standard_layout= FIRST_RESERVED_IGCCToken + 23; int tTT_is_trivial= FIRST_RESERVED_IGCCToken + 24; + int t__int128 = FIRST_RESERVED_IGCCToken + 25; } 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 d01186b5027..cc8f38428db 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 @@ -2591,6 +2591,7 @@ 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: diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/SizeofCalculator.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/SizeofCalculator.java index b8d7de011e3..d04bacd3eb6 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/SizeofCalculator.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/SizeofCalculator.java @@ -58,10 +58,12 @@ public class SizeofCalculator { public final SizeAndAlignment size_2; public final SizeAndAlignment size_4; public final SizeAndAlignment size_8; + public final SizeAndAlignment size_16; public final SizeAndAlignment sizeof_pointer; public final SizeAndAlignment sizeof_int; public final SizeAndAlignment sizeof_long; public final SizeAndAlignment sizeof_long_long; + public final SizeAndAlignment sizeof_int128; public final SizeAndAlignment sizeof_short; public final SizeAndAlignment sizeof_bool; public final SizeAndAlignment sizeof_wchar_t; @@ -118,10 +120,12 @@ public class SizeofCalculator { size_2 = new SizeAndAlignment(2, Math.min(2, maxAlignment)); size_4 = new SizeAndAlignment(4, Math.min(4, maxAlignment)); size_8 = new SizeAndAlignment(8, Math.min(8, maxAlignment)); + size_16 = new SizeAndAlignment(16, Math.min(16, maxAlignment)); sizeof_pointer = getSize(sizeofMacros, "__SIZEOF_POINTER__", maxAlignment); //$NON-NLS-1$ sizeof_int = getSize(sizeofMacros, "__SIZEOF_INT__", maxAlignment); //$NON-NLS-1$ sizeof_long = getSize(sizeofMacros, "__SIZEOF_LONG__", maxAlignment); //$NON-NLS-1$ sizeof_long_long = getSize(sizeofMacros, "__SIZEOF_LONG_LONG__", maxAlignment); //$NON-NLS-1$ + sizeof_int128 = getSize(sizeofMacros, "__SIZEOF_INT128__", maxAlignment); //$NON-NLS-1$ sizeof_short = getSize(sizeofMacros, "__SIZEOF_SHORT__", maxAlignment); //$NON-NLS-1$ sizeof_bool = getSize(sizeofMacros, "__SIZEOF_BOOL__", maxAlignment); //$NON-NLS-1$ sizeof_wchar_t = getSize(sizeofMacros, "__SIZEOF_WCHAR_T__", maxAlignment); //$NON-NLS-1$ @@ -137,10 +141,12 @@ public class SizeofCalculator { size_2 = new SizeAndAlignment(2, 2); size_4 = new SizeAndAlignment(4, 4); size_8 = new SizeAndAlignment(8, 8); + size_16 = new SizeAndAlignment(16, 16); sizeof_pointer = null; sizeof_int = null; sizeof_long = null; sizeof_long_long = null; + sizeof_int128 = size_16; sizeof_short = null; sizeof_bool = null; sizeof_wchar_t = null; @@ -201,9 +207,10 @@ public class SizeofCalculator { case eInt: return type.isShort() ? sizeof_short : type.isLong() ? sizeof_long : type.isLongLong() ? sizeof_long_long : sizeof_int; - case eFloat: { + case eInt128: + return sizeof_int128; + case eFloat: return type.isComplex() ? sizeof_complex_float : sizeof_float; - } case eDouble: return type.isComplex() ? (type.isLong() ? sizeof_long_double : sizeof_double) : @@ -215,7 +222,7 @@ public class SizeofCalculator { case eChar32: return size_4; case eNullPtr: - return sizeAndAlignmentOfPointer(); + return sizeof_pointer; default: return null; } 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 7e2b043811f..f2cf88daf27 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 @@ -98,7 +98,7 @@ public class CASTSimpleDeclSpecifier extends CASTBaseDeclSpecifier implements IC } private int getType(Kind kind) { - switch(kind) { + switch (kind) { case eBoolean: return t_bool; case eChar: @@ -112,6 +112,8 @@ public class CASTSimpleDeclSpecifier extends CASTBaseDeclSpecifier implements IC return t_float; case eInt: return t_int; + case eInt128: + return t_int128; case eUnspecified: return t_unspecified; case eVoid: 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 377d591ab31..3409058e745 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 @@ -71,6 +71,8 @@ public class CBasicType implements ICBasicType, ISerializableType { return Kind.eFloat; case IASTSimpleDeclSpecifier.t_int: return Kind.eInt; + case IASTSimpleDeclSpecifier.t_int128: + return Kind.eInt128; case IASTSimpleDeclSpecifier.t_void: return Kind.eVoid; default: 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 613b0bcee29..7aa0db02fd8 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 @@ -1002,6 +1002,13 @@ public class GNUCSourceParser extends AbstractGNUSourceCodeParser { encounteredRawType= true; endOffset= consume().getEndOffset(); break; + case IGCCToken.t__int128: + if (encounteredTypename) + break declSpecifiers; + simpleType = IASTSimpleDeclSpecifier.t_int128; + encounteredRawType= true; + endOffset= consume().getEndOffset(); + break; case IToken.t_long: if (encounteredTypename) break declSpecifiers; 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 45804b803d4..6c7333ffc2c 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 @@ -92,6 +92,8 @@ public class CPPASTSimpleDeclSpecifier extends CPPASTBaseDeclSpecifier return t_float; case eInt: return t_int; + case eInt128: + return t_int128; case eUnspecified: return t_unspecified; case eVoid: 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 bf2677b028a..0dd4aba9b71 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 @@ -102,6 +102,8 @@ public class CPPBasicType implements ICPPBasicType, ISerializableType { return Kind.eFloat; case IASTSimpleDeclSpecifier.t_int: return Kind.eInt; + case IASTSimpleDeclSpecifier.t_int128: + return Kind.eInt128; case IASTSimpleDeclSpecifier.t_void: return Kind.eVoid; default: 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 6c3d9216050..cb37226a299 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 @@ -2823,6 +2823,13 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser { encounteredRawType= true; endOffset= consume().getEndOffset(); break; + case IGCCToken.t__int128: + if (encounteredTypename) + break declSpecifiers; + simpleType = IASTSimpleDeclSpecifier.t_int128; + encounteredRawType= true; + endOffset= consume().getEndOffset(); + break; case IToken.t_float: if (encounteredTypename) break declSpecifiers; diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/TemplateArgumentDeduction.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/TemplateArgumentDeduction.java index fb683e6602c..4813905721f 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/TemplateArgumentDeduction.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/TemplateArgumentDeduction.java @@ -202,8 +202,9 @@ public class TemplateArgumentDeduction { IType type2= arg.getTypeOfNonTypeValue(); // Template-argument deduced from an array bound may be of any integral // type. - if (type2 instanceof TypeOfValueDeducedFromArraySize && isIntegerType(type1)) { - arg = new CPPTemplateNonTypeArgument(arg.getNonTypeValue(), type1); + if (type2 instanceof TypeOfValueDeducedFromArraySize && isIntegralType(type1)) { + IValue value = isBooleanType(type1) ? Value.create(true) : arg.getNonTypeValue(); + arg = new CPPTemplateNonTypeArgument(value, type1); deduct.fDeducedArgs.put(tpar, arg); } else if (!type1.isSameType(type2)) { return false; @@ -218,9 +219,28 @@ public class TemplateArgumentDeduction { return false; } - private static boolean isIntegerType(IType type) { + // 3.9.1 - 7 + private static boolean isIntegralType(IType type) { type = SemanticUtil.getNestedType(type, SemanticUtil.TDEF); - return type instanceof IBasicType && ((IBasicType) type).getKind() == IBasicType.Kind.eInt; + if (!(type instanceof IBasicType)) + return false; + switch (((IBasicType) type).getKind()) { + case eInt: + case eInt128: + case eBoolean: + case eChar: + case eChar16: + case eChar32: + case eWChar: + return true; + default: + return false; + } + } + + private static boolean isBooleanType(IType type) { + type = SemanticUtil.getNestedType(type, SemanticUtil.TDEF); + return type instanceof IBasicType && ((IBasicType) type).getKind() == IBasicType.Kind.eBoolean; } private static boolean deduceFromFunctionArg(IType par, IType arg, ValueCategory valueCat, diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/rewrite/astwriter/DeclSpecWriter.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/rewrite/astwriter/DeclSpecWriter.java index e1ddfb49265..df7e77c86cf 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/rewrite/astwriter/DeclSpecWriter.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/rewrite/astwriter/DeclSpecWriter.java @@ -34,6 +34,7 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTDeclSpecifier; import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTElaboratedTypeSpecifier; import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTNamedTypeSpecifier; import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTSimpleDeclSpecifier; +import org.eclipse.cdt.core.parser.GCCKeywords; import org.eclipse.cdt.core.parser.Keywords; import org.eclipse.cdt.internal.core.dom.rewrite.commenthandler.NodeCommentMap; @@ -79,6 +80,8 @@ public class DeclSpecWriter extends NodeWriter { return Keywords.CHAR; case IASTSimpleDeclSpecifier.t_int: return Keywords.INT; + case IASTSimpleDeclSpecifier.t_int128: + return GCCKeywords.__INT128; case IASTSimpleDeclSpecifier.t_float: return Keywords.FLOAT;