mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-06-08 10:16:03 +02:00
Support for __int128 type introduced in GCC 4.7.
This commit is contained in:
parent
da5b169b44
commit
25c47d3cbb
24 changed files with 196 additions and 79 deletions
|
@ -153,18 +153,20 @@ public class AST2BaseTest extends BaseTestCase {
|
||||||
AbstractGNUSourceCodeParser parser = null;
|
AbstractGNUSourceCodeParser parser = null;
|
||||||
if (lang == ParserLanguage.CPP) {
|
if (lang == ParserLanguage.CPP) {
|
||||||
ICPPParserExtensionConfiguration config = null;
|
ICPPParserExtensionConfiguration config = null;
|
||||||
if (useGNUExtensions)
|
if (useGNUExtensions) {
|
||||||
config = new GPPParserExtensionConfiguration();
|
config = new GPPParserExtensionConfiguration();
|
||||||
else
|
} else {
|
||||||
config = new ANSICPPParserExtensionConfiguration();
|
config = new ANSICPPParserExtensionConfiguration();
|
||||||
|
}
|
||||||
parser = new GNUCPPSourceParser(scanner, ParserMode.COMPLETE_PARSE, NULL_LOG,config, null);
|
parser = new GNUCPPSourceParser(scanner, ParserMode.COMPLETE_PARSE, NULL_LOG,config, null);
|
||||||
} else {
|
} else {
|
||||||
ICParserExtensionConfiguration config = null;
|
ICParserExtensionConfiguration config = null;
|
||||||
|
|
||||||
if (useGNUExtensions)
|
if (useGNUExtensions) {
|
||||||
config = new GCCParserExtensionConfiguration();
|
config = new GCCParserExtensionConfiguration();
|
||||||
else
|
} else {
|
||||||
config = new ANSICParserExtensionConfiguration();
|
config = new ANSICParserExtensionConfiguration();
|
||||||
|
}
|
||||||
|
|
||||||
parser = new GNUCSourceParser(scanner, ParserMode.COMPLETE_PARSE, NULL_LOG, config, null);
|
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,
|
public static IScanner createScanner(FileContent codeReader, ParserLanguage lang, ParserMode mode,
|
||||||
IScannerInfo scannerInfo) {
|
IScannerInfo scannerInfo) {
|
||||||
IScannerExtensionConfiguration configuration = null;
|
IScannerExtensionConfiguration configuration = null;
|
||||||
if (lang == ParserLanguage.C)
|
if (lang == ParserLanguage.C) {
|
||||||
configuration= GCCScannerExtensionConfiguration.getInstance();
|
configuration= GCCScannerExtensionConfiguration.getInstance(scannerInfo);
|
||||||
else
|
} else {
|
||||||
configuration= GPPScannerExtensionConfiguration.getInstance(scannerInfo);
|
configuration= GPPScannerExtensionConfiguration.getInstance(scannerInfo);
|
||||||
|
}
|
||||||
IScanner scanner;
|
IScanner scanner;
|
||||||
scanner= new CPreprocessor(codeReader, scannerInfo, lang, NULL_LOG, configuration,
|
scanner= new CPreprocessor(codeReader, scannerInfo, lang, NULL_LOG, configuration,
|
||||||
IncludeFileContentProvider.getSavedFilesProvider());
|
IncludeFileContentProvider.getSavedFilesProvider());
|
||||||
|
|
|
@ -417,4 +417,12 @@ public class GCCCompleteParseExtensionsTest extends AST2BaseTest {
|
||||||
public void testTypeTraits_Bug342683() throws Exception {
|
public void testTypeTraits_Bug342683() throws Exception {
|
||||||
parseGPP(getAboveComment());
|
parseGPP(getAboveComment());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// __int128 a;
|
||||||
|
// unsigned __int128 b;
|
||||||
|
public void test__int128() throws Exception {
|
||||||
|
String code= getAboveComment();
|
||||||
|
parseGCC(code);
|
||||||
|
parseGPP(code);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -35,14 +35,14 @@ import org.eclipse.cdt.internal.core.dom.rewrite.ASTModificationStore;
|
||||||
/**
|
/**
|
||||||
* @author Emanuel Graf IFS
|
* @author Emanuel Graf IFS
|
||||||
*/
|
*/
|
||||||
public class AddDeclarationBug extends ChangeGeneratorTest {
|
public class AddDeclarationBugTest extends ChangeGeneratorTest {
|
||||||
|
|
||||||
AddDeclarationBug() {
|
AddDeclarationBugTest() {
|
||||||
super("AddDeclarationBug");
|
super("AddDeclarationBug");
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Test suite() {
|
public static Test suite() {
|
||||||
return new AddDeclarationBug();
|
return new AddDeclarationBugTest();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -65,16 +65,16 @@ public class AddDeclarationBug extends ChangeGeneratorTest {
|
||||||
ICPPASTCompositeTypeSpecifier classNode = (ICPPASTCompositeTypeSpecifier) declSpec;
|
ICPPASTCompositeTypeSpecifier classNode = (ICPPASTCompositeTypeSpecifier) declSpec;
|
||||||
IASTSimpleDeclaration newDecl = new CPPASTSimpleDeclaration();
|
IASTSimpleDeclaration newDecl = new CPPASTSimpleDeclaration();
|
||||||
|
|
||||||
IASTSimpleDeclSpecifier returnTyp = new CPPASTSimpleDeclSpecifier();
|
IASTSimpleDeclSpecifier returnType = new CPPASTSimpleDeclSpecifier();
|
||||||
returnTyp.setType(IASTSimpleDeclSpecifier.t_int);
|
returnType.setType(IASTSimpleDeclSpecifier.t_int);
|
||||||
newDecl.setDeclSpecifier(returnTyp);
|
newDecl.setDeclSpecifier(returnType);
|
||||||
|
|
||||||
IASTStandardFunctionDeclarator declarator = new CPPASTFunctionDeclarator(
|
IASTStandardFunctionDeclarator declarator = new CPPASTFunctionDeclarator(
|
||||||
new CPPASTName("exp".toCharArray())); //$NON-NLS-1$
|
new CPPASTName("exp".toCharArray())); //$NON-NLS-1$
|
||||||
IASTSimpleDeclSpecifier paramTyp = new CPPASTSimpleDeclSpecifier();
|
IASTSimpleDeclSpecifier paramType = new CPPASTSimpleDeclSpecifier();
|
||||||
paramTyp.setType(IASTSimpleDeclSpecifier.t_int);
|
paramType.setType(IASTSimpleDeclSpecifier.t_int);
|
||||||
IASTDeclarator decl = new CPPASTDeclarator(new CPPASTName("i".toCharArray())); //$NON-NLS-1$
|
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);
|
declarator.addParameterDeclaration(param);
|
||||||
newDecl.addDeclarator(declarator);
|
newDecl.addDeclarator(declarator);
|
||||||
|
|
|
@ -29,7 +29,7 @@ public class InsertBeforeTestSuite {
|
||||||
suite.addTest(ArrayModifierTest.suite());
|
suite.addTest(ArrayModifierTest.suite());
|
||||||
suite.addTest(ExpressionTest.suite());
|
suite.addTest(ExpressionTest.suite());
|
||||||
suite.addTest(ArraySizeExpressionTest.suite());
|
suite.addTest(ArraySizeExpressionTest.suite());
|
||||||
suite.addTest(AddDeclarationBug.suite());
|
suite.addTest(AddDeclarationBugTest.suite());
|
||||||
suite.addTest(MultilineWhitespaceHandlingTest.suite());
|
suite.addTest(MultilineWhitespaceHandlingTest.suite());
|
||||||
suite.addTest(SelfInsertionTest.suite());
|
suite.addTest(SelfInsertionTest.suite());
|
||||||
|
|
||||||
|
|
|
@ -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.cpp.ICPPASTUnaryExpression;
|
||||||
import org.eclipse.cdt.core.dom.ast.gnu.IGNUASTCompoundStatementExpression;
|
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.ICASTKnRFunctionDeclarator;
|
||||||
|
import org.eclipse.cdt.core.parser.GCCKeywords;
|
||||||
import org.eclipse.cdt.core.parser.Keywords;
|
import org.eclipse.cdt.core.parser.Keywords;
|
||||||
import org.eclipse.cdt.core.parser.util.CharArrayUtils;
|
import org.eclipse.cdt.core.parser.util.CharArrayUtils;
|
||||||
import org.eclipse.cdt.internal.core.dom.parser.ASTQueries;
|
import org.eclipse.cdt.internal.core.dom.parser.ASTQueries;
|
||||||
|
@ -625,6 +626,9 @@ public class ASTStringUtil {
|
||||||
case IASTSimpleDeclSpecifier.t_int:
|
case IASTSimpleDeclSpecifier.t_int:
|
||||||
buffer.append(Keywords.INT).append(' ');
|
buffer.append(Keywords.INT).append(' ');
|
||||||
break;
|
break;
|
||||||
|
case IASTSimpleDeclSpecifier.t_int128:
|
||||||
|
buffer.append(GCCKeywords.cp__int128).append(' ');
|
||||||
|
break;
|
||||||
case IASTSimpleDeclSpecifier.t_float:
|
case IASTSimpleDeclSpecifier.t_float:
|
||||||
buffer.append(Keywords.FLOAT).append(' ');
|
buffer.append(Keywords.FLOAT).append(' ');
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -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.IGNUASTTypeIdExpression;
|
||||||
import org.eclipse.cdt.core.dom.ast.gnu.c.ICASTKnRFunctionDeclarator;
|
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.IGCCASTArrayRangeDesignator;
|
||||||
|
import org.eclipse.cdt.core.parser.GCCKeywords;
|
||||||
import org.eclipse.cdt.core.parser.Keywords;
|
import org.eclipse.cdt.core.parser.Keywords;
|
||||||
import org.eclipse.cdt.internal.core.dom.parser.ASTProblem;
|
import org.eclipse.cdt.internal.core.dom.parser.ASTProblem;
|
||||||
import org.eclipse.cdt.internal.core.model.ASTStringUtil;
|
import org.eclipse.cdt.internal.core.model.ASTStringUtil;
|
||||||
|
@ -775,6 +776,14 @@ public class ASTSignatureUtil {
|
||||||
result.append(Keywords.INT);
|
result.append(Keywords.INT);
|
||||||
needSpace = true;
|
needSpace = true;
|
||||||
break;
|
break;
|
||||||
|
case IASTSimpleDeclSpecifier.t_int128:
|
||||||
|
if (needSpace) {
|
||||||
|
result.append(SPACE);
|
||||||
|
needSpace = false;
|
||||||
|
}
|
||||||
|
result.append(GCCKeywords.__INT128);
|
||||||
|
needSpace = true;
|
||||||
|
break;
|
||||||
case IASTSimpleDeclSpecifier.t_void:
|
case IASTSimpleDeclSpecifier.t_void:
|
||||||
if (needSpace) {
|
if (needSpace) {
|
||||||
result.append(SPACE);
|
result.append(SPACE);
|
||||||
|
|
|
@ -100,6 +100,11 @@ public interface IASTSimpleDeclSpecifier extends IASTDeclSpecifier {
|
||||||
*/
|
*/
|
||||||
public static final int t_char32_t = 12;
|
public static final int t_char32_t = 12;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <code>__int128 i;</code>
|
||||||
|
* @since 5.5
|
||||||
|
*/
|
||||||
|
public static final int t_int128 = 13;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @since 5.1
|
* @since 5.1
|
||||||
|
|
|
@ -22,40 +22,25 @@ public interface IBasicType extends IType {
|
||||||
* @since 5.2
|
* @since 5.2
|
||||||
*/
|
*/
|
||||||
enum Kind {
|
enum Kind {
|
||||||
eUnspecified, eVoid, eChar, eWChar, eInt, eFloat, eDouble, eBoolean, eChar16, eChar32,
|
eUnspecified, eVoid, eChar, eWChar, eInt, /** @since 5.5 */ eInt128, eFloat, eDouble,
|
||||||
/** @since 5.4 */ eNullPtr
|
eBoolean, eChar16, eChar32, /** @since 5.4 */ eNullPtr
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/** @since 5.2 */
|
||||||
* @since 5.2
|
|
||||||
*/
|
|
||||||
final int IS_LONG = 1;
|
final int IS_LONG = 1;
|
||||||
/**
|
/** @since 5.2 */
|
||||||
* @since 5.2
|
|
||||||
*/
|
|
||||||
final int IS_SHORT = 1 << 1;
|
final int IS_SHORT = 1 << 1;
|
||||||
/**
|
/** @since 5.2 */
|
||||||
* @since 5.2
|
|
||||||
*/
|
|
||||||
final int IS_SIGNED = 1 << 2;
|
final int IS_SIGNED = 1 << 2;
|
||||||
/**
|
/** @since 5.2 */
|
||||||
* @since 5.2
|
|
||||||
*/
|
|
||||||
final int IS_UNSIGNED = 1 << 3;
|
final int IS_UNSIGNED = 1 << 3;
|
||||||
/**
|
/** @since 5.2 */
|
||||||
* @since 5.2
|
|
||||||
*/
|
|
||||||
final int IS_COMPLEX = 1 << 4;
|
final int IS_COMPLEX = 1 << 4;
|
||||||
/**
|
/** @since 5.2 */
|
||||||
* @since 5.2
|
|
||||||
*/
|
|
||||||
final int IS_IMAGINARY = 1 << 5;
|
final int IS_IMAGINARY = 1 << 5;
|
||||||
/**
|
/** @since 5.2 */
|
||||||
* @since 5.2
|
|
||||||
*/
|
|
||||||
final int IS_LONG_LONG = 1 << 6;
|
final int IS_LONG_LONG = 1 << 6;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This returns the kind of basic type you are looking at. The type is
|
* 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.
|
* then refined by qualifiers for signed/unsigned and short/long/long long.
|
||||||
|
|
|
@ -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.index.IIndex;
|
||||||
import org.eclipse.cdt.core.parser.IParserLogService;
|
import org.eclipse.cdt.core.parser.IParserLogService;
|
||||||
import org.eclipse.cdt.core.parser.IScanner;
|
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.ParserLanguage;
|
||||||
import org.eclipse.cdt.core.parser.ParserMode;
|
import org.eclipse.cdt.core.parser.ParserMode;
|
||||||
import org.eclipse.cdt.internal.core.dom.parser.c.GNUCSourceParser;
|
import org.eclipse.cdt.internal.core.dom.parser.c.GNUCSourceParser;
|
||||||
|
@ -70,6 +71,11 @@ public class GCCLanguage extends AbstractCLikeLanguage {
|
||||||
return C_GNU_SCANNER_EXTENSION;
|
return C_GNU_SCANNER_EXTENSION;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected IScannerExtensionConfiguration getScannerExtensionConfiguration(IScannerInfo info) {
|
||||||
|
return GCCScannerExtensionConfiguration.getInstance(info);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the extension configuration used for creating the parser.
|
* Returns the extension configuration used for creating the parser.
|
||||||
* @since 5.1
|
* @since 5.1
|
||||||
|
|
|
@ -28,6 +28,13 @@ import org.eclipse.cdt.core.parser.util.CharArrayIntMap;
|
||||||
public abstract class GNUScannerExtensionConfiguration extends AbstractScannerExtensionConfiguration {
|
public abstract class GNUScannerExtensionConfiguration extends AbstractScannerExtensionConfiguration {
|
||||||
private static GNUScannerExtensionConfiguration sInstance;
|
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")
|
@SuppressWarnings("nls")
|
||||||
public GNUScannerExtensionConfiguration() {
|
public GNUScannerExtensionConfiguration() {
|
||||||
addMacro("__complex__", "_Complex");
|
addMacro("__complex__", "_Complex");
|
||||||
|
|
|
@ -13,30 +13,65 @@
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.cdt.core.dom.parser.c;
|
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.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.
|
* Configures the preprocessor for parsing c-sources as accepted by gcc.
|
||||||
*/
|
*/
|
||||||
public class GCCScannerExtensionConfiguration extends GNUScannerExtensionConfiguration {
|
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
|
* @since 5.1
|
||||||
*/
|
*/
|
||||||
public static GCCScannerExtensionConfiguration getInstance() {
|
public static GCCScannerExtensionConfiguration getInstance() {
|
||||||
return sInstance;
|
return CONFIG;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @since 5.5
|
||||||
|
*/
|
||||||
|
public static GCCScannerExtensionConfiguration getInstance(IScannerInfo info) {
|
||||||
|
if (info != null) {
|
||||||
|
try {
|
||||||
|
final Map<String, String> 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() {
|
public GCCScannerExtensionConfiguration() {
|
||||||
|
this(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @since 5.5
|
||||||
|
*/
|
||||||
|
@SuppressWarnings("nls")
|
||||||
|
public GCCScannerExtensionConfiguration(int version) {
|
||||||
addMacro("__null", "(void *)0");
|
addMacro("__null", "(void *)0");
|
||||||
addMacro("__builtin_offsetof(T,m)", "((size_t) &((T *)0)->m)");
|
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
|
@Override
|
||||||
public boolean supportMinAndMaxOperators() {
|
public boolean supportMinAndMaxOperators() {
|
||||||
return false;
|
return false;
|
||||||
|
|
|
@ -29,13 +29,11 @@ import org.eclipse.cdt.core.parser.Keywords;
|
||||||
public class GPPScannerExtensionConfiguration extends GNUScannerExtensionConfiguration {
|
public class GPPScannerExtensionConfiguration extends GNUScannerExtensionConfiguration {
|
||||||
private static final int VERSION_4_3 = version(4, 3);
|
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_6 = version(4, 6);
|
||||||
|
private static final int VERSION_4_7 = version(4, 7);
|
||||||
private static GPPScannerExtensionConfiguration CONFIG= new GPPScannerExtensionConfiguration();
|
private static GPPScannerExtensionConfiguration CONFIG= new GPPScannerExtensionConfiguration();
|
||||||
private static GPPScannerExtensionConfiguration CONFIG_4_3= new GPPScannerExtensionConfiguration(VERSION_4_3);
|
private static GPPScannerExtensionConfiguration CONFIG_4_3= new GPPScannerExtensionConfiguration(VERSION_4_3);
|
||||||
private static GPPScannerExtensionConfiguration CONFIG_4_6= new GPPScannerExtensionConfiguration(VERSION_4_6);
|
private static GPPScannerExtensionConfiguration CONFIG_4_6= new GPPScannerExtensionConfiguration(VERSION_4_6);
|
||||||
|
private static GPPScannerExtensionConfiguration CONFIG_4_7= new GPPScannerExtensionConfiguration(VERSION_4_7);
|
||||||
private static int version(int major, int minor) {
|
|
||||||
return (major << 16) + minor;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static GPPScannerExtensionConfiguration getInstance() {
|
public static GPPScannerExtensionConfiguration getInstance() {
|
||||||
return CONFIG;
|
return CONFIG;
|
||||||
|
@ -51,6 +49,9 @@ public class GPPScannerExtensionConfiguration extends GNUScannerExtensionConfigu
|
||||||
int major= Integer.valueOf(definedSymbols.get("__GNUC__")); //$NON-NLS-1$
|
int major= Integer.valueOf(definedSymbols.get("__GNUC__")); //$NON-NLS-1$
|
||||||
int minor= Integer.valueOf(definedSymbols.get("__GNUC_MINOR__")); //$NON-NLS-1$
|
int minor= Integer.valueOf(definedSymbols.get("__GNUC_MINOR__")); //$NON-NLS-1$
|
||||||
int version= version(major, minor);
|
int version= version(major, minor);
|
||||||
|
if (version >= VERSION_4_7) {
|
||||||
|
return CONFIG_4_7;
|
||||||
|
}
|
||||||
if (version >= VERSION_4_6) {
|
if (version >= VERSION_4_6) {
|
||||||
return CONFIG_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_standard_layout, IGCCToken.tTT_is_standard_layout);
|
||||||
addKeyword(GCCKeywords.cp__is_trivial, IGCCToken.tTT_is_trivial);
|
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
|
@Override
|
||||||
public boolean supportMinAndMaxOperators() {
|
public boolean supportMinAndMaxOperators() {
|
||||||
return true;
|
return true;
|
||||||
|
|
|
@ -23,6 +23,8 @@ public class GCCKeywords {
|
||||||
public static final String __ALIGNOF__ = "__alignof__";
|
public static final String __ALIGNOF__ = "__alignof__";
|
||||||
public static final String __ATTRIBUTE__ = "__attribute__";
|
public static final String __ATTRIBUTE__ = "__attribute__";
|
||||||
public static final String __DECLSPEC = "__declspec";
|
public static final String __DECLSPEC = "__declspec";
|
||||||
|
/** @since 5.5 */
|
||||||
|
public static final String __INT128 = "__int128";
|
||||||
|
|
||||||
public static final char[]
|
public static final char[]
|
||||||
cpTYPEOF = TYPEOF.toCharArray(),
|
cpTYPEOF = TYPEOF.toCharArray(),
|
||||||
|
@ -46,9 +48,7 @@ public class GCCKeywords {
|
||||||
cp__TYPEOF= "__typeof".toCharArray(),
|
cp__TYPEOF= "__typeof".toCharArray(),
|
||||||
cp__TYPEOF__= "__typeof__".toCharArray();
|
cp__TYPEOF__= "__typeof__".toCharArray();
|
||||||
|
|
||||||
/**
|
/** @since 5.3 */
|
||||||
* @since 5.3
|
|
||||||
*/
|
|
||||||
public static final char[]
|
public static final char[]
|
||||||
cp__has_nothrow_assign= "__has_nothrow_assign".toCharArray(),
|
cp__has_nothrow_assign= "__has_nothrow_assign".toCharArray(),
|
||||||
cp__has_nothrow_copy= "__has_nothrow_copy".toCharArray(),
|
cp__has_nothrow_copy= "__has_nothrow_copy".toCharArray(),
|
||||||
|
@ -67,10 +67,9 @@ public class GCCKeywords {
|
||||||
cp__is_polymorphic= "__is_polymorphic".toCharArray(),
|
cp__is_polymorphic= "__is_polymorphic".toCharArray(),
|
||||||
cp__is_union= "__is_union".toCharArray();
|
cp__is_union= "__is_union".toCharArray();
|
||||||
|
|
||||||
/**
|
/** @since 5.5 */
|
||||||
* @since 5.5
|
|
||||||
*/
|
|
||||||
public static final char[]
|
public static final char[]
|
||||||
|
cp__int128= __INT128.toCharArray(),
|
||||||
cp__is_literal_type= "__is_literal_type".toCharArray(),
|
cp__is_literal_type= "__is_literal_type".toCharArray(),
|
||||||
cp__is_standard_layout= "__is_standard_layout".toCharArray(),
|
cp__is_standard_layout= "__is_standard_layout".toCharArray(),
|
||||||
cp__is_trivial= "__is_trivial".toCharArray();
|
cp__is_trivial= "__is_trivial".toCharArray();
|
||||||
|
|
|
@ -44,4 +44,6 @@ public interface IGCCToken extends IToken {
|
||||||
/** @since 5.5 */ int tTT_is_literal_type= FIRST_RESERVED_IGCCToken + 22;
|
/** @since 5.5 */ int tTT_is_literal_type= FIRST_RESERVED_IGCCToken + 22;
|
||||||
/** @since 5.5 */ int tTT_is_standard_layout= FIRST_RESERVED_IGCCToken + 23;
|
/** @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 tTT_is_trivial= FIRST_RESERVED_IGCCToken + 24;
|
||||||
|
|
||||||
|
/** @since 5.5 */ int t__int128 = FIRST_RESERVED_IGCCToken + 25;
|
||||||
}
|
}
|
||||||
|
|
|
@ -2591,6 +2591,7 @@ public abstract class AbstractGNUSourceCodeParser implements ISourceCodeParser {
|
||||||
case IToken.t_short:
|
case IToken.t_short:
|
||||||
case IToken.t_int:
|
case IToken.t_int:
|
||||||
case IToken.t_long:
|
case IToken.t_long:
|
||||||
|
case IGCCToken.t__int128:
|
||||||
case IToken.t_float:
|
case IToken.t_float:
|
||||||
case IToken.t_double:
|
case IToken.t_double:
|
||||||
case IToken.t__Bool:
|
case IToken.t__Bool:
|
||||||
|
|
|
@ -58,10 +58,12 @@ public class SizeofCalculator {
|
||||||
public final SizeAndAlignment size_2;
|
public final SizeAndAlignment size_2;
|
||||||
public final SizeAndAlignment size_4;
|
public final SizeAndAlignment size_4;
|
||||||
public final SizeAndAlignment size_8;
|
public final SizeAndAlignment size_8;
|
||||||
|
public final SizeAndAlignment size_16;
|
||||||
public final SizeAndAlignment sizeof_pointer;
|
public final SizeAndAlignment sizeof_pointer;
|
||||||
public final SizeAndAlignment sizeof_int;
|
public final SizeAndAlignment sizeof_int;
|
||||||
public final SizeAndAlignment sizeof_long;
|
public final SizeAndAlignment sizeof_long;
|
||||||
public final SizeAndAlignment sizeof_long_long;
|
public final SizeAndAlignment sizeof_long_long;
|
||||||
|
public final SizeAndAlignment sizeof_int128;
|
||||||
public final SizeAndAlignment sizeof_short;
|
public final SizeAndAlignment sizeof_short;
|
||||||
public final SizeAndAlignment sizeof_bool;
|
public final SizeAndAlignment sizeof_bool;
|
||||||
public final SizeAndAlignment sizeof_wchar_t;
|
public final SizeAndAlignment sizeof_wchar_t;
|
||||||
|
@ -118,10 +120,12 @@ public class SizeofCalculator {
|
||||||
size_2 = new SizeAndAlignment(2, Math.min(2, maxAlignment));
|
size_2 = new SizeAndAlignment(2, Math.min(2, maxAlignment));
|
||||||
size_4 = new SizeAndAlignment(4, Math.min(4, maxAlignment));
|
size_4 = new SizeAndAlignment(4, Math.min(4, maxAlignment));
|
||||||
size_8 = new SizeAndAlignment(8, Math.min(8, 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_pointer = getSize(sizeofMacros, "__SIZEOF_POINTER__", maxAlignment); //$NON-NLS-1$
|
||||||
sizeof_int = getSize(sizeofMacros, "__SIZEOF_INT__", 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 = getSize(sizeofMacros, "__SIZEOF_LONG__", maxAlignment); //$NON-NLS-1$
|
||||||
sizeof_long_long = getSize(sizeofMacros, "__SIZEOF_LONG_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_short = getSize(sizeofMacros, "__SIZEOF_SHORT__", maxAlignment); //$NON-NLS-1$
|
||||||
sizeof_bool = getSize(sizeofMacros, "__SIZEOF_BOOL__", 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$
|
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_2 = new SizeAndAlignment(2, 2);
|
||||||
size_4 = new SizeAndAlignment(4, 4);
|
size_4 = new SizeAndAlignment(4, 4);
|
||||||
size_8 = new SizeAndAlignment(8, 8);
|
size_8 = new SizeAndAlignment(8, 8);
|
||||||
|
size_16 = new SizeAndAlignment(16, 16);
|
||||||
sizeof_pointer = null;
|
sizeof_pointer = null;
|
||||||
sizeof_int = null;
|
sizeof_int = null;
|
||||||
sizeof_long = null;
|
sizeof_long = null;
|
||||||
sizeof_long_long = null;
|
sizeof_long_long = null;
|
||||||
|
sizeof_int128 = size_16;
|
||||||
sizeof_short = null;
|
sizeof_short = null;
|
||||||
sizeof_bool = null;
|
sizeof_bool = null;
|
||||||
sizeof_wchar_t = null;
|
sizeof_wchar_t = null;
|
||||||
|
@ -201,9 +207,10 @@ public class SizeofCalculator {
|
||||||
case eInt:
|
case eInt:
|
||||||
return type.isShort() ? sizeof_short : type.isLong() ? sizeof_long :
|
return type.isShort() ? sizeof_short : type.isLong() ? sizeof_long :
|
||||||
type.isLongLong() ? sizeof_long_long : sizeof_int;
|
type.isLongLong() ? sizeof_long_long : sizeof_int;
|
||||||
case eFloat: {
|
case eInt128:
|
||||||
|
return sizeof_int128;
|
||||||
|
case eFloat:
|
||||||
return type.isComplex() ? sizeof_complex_float : sizeof_float;
|
return type.isComplex() ? sizeof_complex_float : sizeof_float;
|
||||||
}
|
|
||||||
case eDouble:
|
case eDouble:
|
||||||
return type.isComplex() ?
|
return type.isComplex() ?
|
||||||
(type.isLong() ? sizeof_long_double : sizeof_double) :
|
(type.isLong() ? sizeof_long_double : sizeof_double) :
|
||||||
|
@ -215,7 +222,7 @@ public class SizeofCalculator {
|
||||||
case eChar32:
|
case eChar32:
|
||||||
return size_4;
|
return size_4;
|
||||||
case eNullPtr:
|
case eNullPtr:
|
||||||
return sizeAndAlignmentOfPointer();
|
return sizeof_pointer;
|
||||||
default:
|
default:
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
|
@ -112,6 +112,8 @@ public class CASTSimpleDeclSpecifier extends CASTBaseDeclSpecifier implements IC
|
||||||
return t_float;
|
return t_float;
|
||||||
case eInt:
|
case eInt:
|
||||||
return t_int;
|
return t_int;
|
||||||
|
case eInt128:
|
||||||
|
return t_int128;
|
||||||
case eUnspecified:
|
case eUnspecified:
|
||||||
return t_unspecified;
|
return t_unspecified;
|
||||||
case eVoid:
|
case eVoid:
|
||||||
|
|
|
@ -71,6 +71,8 @@ public class CBasicType implements ICBasicType, ISerializableType {
|
||||||
return Kind.eFloat;
|
return Kind.eFloat;
|
||||||
case IASTSimpleDeclSpecifier.t_int:
|
case IASTSimpleDeclSpecifier.t_int:
|
||||||
return Kind.eInt;
|
return Kind.eInt;
|
||||||
|
case IASTSimpleDeclSpecifier.t_int128:
|
||||||
|
return Kind.eInt128;
|
||||||
case IASTSimpleDeclSpecifier.t_void:
|
case IASTSimpleDeclSpecifier.t_void:
|
||||||
return Kind.eVoid;
|
return Kind.eVoid;
|
||||||
default:
|
default:
|
||||||
|
|
|
@ -1002,6 +1002,13 @@ public class GNUCSourceParser extends AbstractGNUSourceCodeParser {
|
||||||
encounteredRawType= true;
|
encounteredRawType= true;
|
||||||
endOffset= consume().getEndOffset();
|
endOffset= consume().getEndOffset();
|
||||||
break;
|
break;
|
||||||
|
case IGCCToken.t__int128:
|
||||||
|
if (encounteredTypename)
|
||||||
|
break declSpecifiers;
|
||||||
|
simpleType = IASTSimpleDeclSpecifier.t_int128;
|
||||||
|
encounteredRawType= true;
|
||||||
|
endOffset= consume().getEndOffset();
|
||||||
|
break;
|
||||||
case IToken.t_long:
|
case IToken.t_long:
|
||||||
if (encounteredTypename)
|
if (encounteredTypename)
|
||||||
break declSpecifiers;
|
break declSpecifiers;
|
||||||
|
|
|
@ -92,6 +92,8 @@ public class CPPASTSimpleDeclSpecifier extends CPPASTBaseDeclSpecifier
|
||||||
return t_float;
|
return t_float;
|
||||||
case eInt:
|
case eInt:
|
||||||
return t_int;
|
return t_int;
|
||||||
|
case eInt128:
|
||||||
|
return t_int128;
|
||||||
case eUnspecified:
|
case eUnspecified:
|
||||||
return t_unspecified;
|
return t_unspecified;
|
||||||
case eVoid:
|
case eVoid:
|
||||||
|
|
|
@ -102,6 +102,8 @@ public class CPPBasicType implements ICPPBasicType, ISerializableType {
|
||||||
return Kind.eFloat;
|
return Kind.eFloat;
|
||||||
case IASTSimpleDeclSpecifier.t_int:
|
case IASTSimpleDeclSpecifier.t_int:
|
||||||
return Kind.eInt;
|
return Kind.eInt;
|
||||||
|
case IASTSimpleDeclSpecifier.t_int128:
|
||||||
|
return Kind.eInt128;
|
||||||
case IASTSimpleDeclSpecifier.t_void:
|
case IASTSimpleDeclSpecifier.t_void:
|
||||||
return Kind.eVoid;
|
return Kind.eVoid;
|
||||||
default:
|
default:
|
||||||
|
|
|
@ -2830,6 +2830,13 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser {
|
||||||
encounteredRawType= true;
|
encounteredRawType= true;
|
||||||
endOffset= consume().getEndOffset();
|
endOffset= consume().getEndOffset();
|
||||||
break;
|
break;
|
||||||
|
case IGCCToken.t__int128:
|
||||||
|
if (encounteredTypename)
|
||||||
|
break declSpecifiers;
|
||||||
|
simpleType = IASTSimpleDeclSpecifier.t_int128;
|
||||||
|
encounteredRawType= true;
|
||||||
|
endOffset= consume().getEndOffset();
|
||||||
|
break;
|
||||||
case IToken.t_float:
|
case IToken.t_float:
|
||||||
if (encounteredTypename)
|
if (encounteredTypename)
|
||||||
break declSpecifiers;
|
break declSpecifiers;
|
||||||
|
|
|
@ -202,8 +202,9 @@ public class TemplateArgumentDeduction {
|
||||||
IType type2= arg.getTypeOfNonTypeValue();
|
IType type2= arg.getTypeOfNonTypeValue();
|
||||||
// Template-argument deduced from an array bound may be of any integral
|
// Template-argument deduced from an array bound may be of any integral
|
||||||
// type.
|
// type.
|
||||||
if (type2 instanceof TypeOfValueDeducedFromArraySize && isIntegerType(type1)) {
|
if (type2 instanceof TypeOfValueDeducedFromArraySize && isIntegralType(type1)) {
|
||||||
arg = new CPPTemplateNonTypeArgument(arg.getNonTypeValue(), type1);
|
IValue value = isBooleanType(type1) ? Value.create(true) : arg.getNonTypeValue();
|
||||||
|
arg = new CPPTemplateNonTypeArgument(value, type1);
|
||||||
deduct.fDeducedArgs.put(tpar, arg);
|
deduct.fDeducedArgs.put(tpar, arg);
|
||||||
} else if (!type1.isSameType(type2)) {
|
} else if (!type1.isSameType(type2)) {
|
||||||
return false;
|
return false;
|
||||||
|
@ -218,9 +219,28 @@ public class TemplateArgumentDeduction {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static boolean isIntegerType(IType type) {
|
// 3.9.1 - 7
|
||||||
|
private static boolean isIntegralType(IType type) {
|
||||||
type = SemanticUtil.getNestedType(type, SemanticUtil.TDEF);
|
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,
|
private static boolean deduceFromFunctionArg(IType par, IType arg, ValueCategory valueCat,
|
||||||
|
|
|
@ -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.ICPPASTElaboratedTypeSpecifier;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTNamedTypeSpecifier;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTNamedTypeSpecifier;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTSimpleDeclSpecifier;
|
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.core.parser.Keywords;
|
||||||
import org.eclipse.cdt.internal.core.dom.rewrite.commenthandler.NodeCommentMap;
|
import org.eclipse.cdt.internal.core.dom.rewrite.commenthandler.NodeCommentMap;
|
||||||
|
|
||||||
|
@ -79,6 +80,8 @@ public class DeclSpecWriter extends NodeWriter {
|
||||||
return Keywords.CHAR;
|
return Keywords.CHAR;
|
||||||
case IASTSimpleDeclSpecifier.t_int:
|
case IASTSimpleDeclSpecifier.t_int:
|
||||||
return Keywords.INT;
|
return Keywords.INT;
|
||||||
|
case IASTSimpleDeclSpecifier.t_int128:
|
||||||
|
return GCCKeywords.__INT128;
|
||||||
|
|
||||||
case IASTSimpleDeclSpecifier.t_float:
|
case IASTSimpleDeclSpecifier.t_float:
|
||||||
return Keywords.FLOAT;
|
return Keywords.FLOAT;
|
||||||
|
|
Loading…
Add table
Reference in a new issue