mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-29 19:45:01 +02:00
GCC 4.6 type traits.
This commit is contained in:
parent
2fc1fe1a7d
commit
4167f6cefd
6 changed files with 92 additions and 30 deletions
|
@ -128,6 +128,24 @@ public interface IASTTypeIdExpression extends IASTExpression {
|
|||
*/
|
||||
public static final int op_is_union= 18;
|
||||
|
||||
/**
|
||||
* Built-in type trait of g++.
|
||||
* @since 5.5
|
||||
*/
|
||||
public static final int op_is_literal_type= 19;
|
||||
|
||||
/**
|
||||
* Built-in type trait of g++.
|
||||
* @since 5.5
|
||||
*/
|
||||
public static final int op_is_standard_layout= 20;
|
||||
|
||||
/**
|
||||
* Built-in type trait of g++.
|
||||
* @since 5.5
|
||||
*/
|
||||
public static final int op_is_trivial= 21;
|
||||
|
||||
/**
|
||||
* @deprecated constants should be declared here, to avoid using the same constant in different
|
||||
* interfaces.
|
||||
|
|
|
@ -27,16 +27,16 @@ import org.eclipse.cdt.core.parser.Keywords;
|
|||
* Configures the preprocessor for c++-sources as accepted by g++.
|
||||
*/
|
||||
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 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;
|
||||
}
|
||||
|
||||
|
||||
public static GPPScannerExtensionConfiguration getInstance() {
|
||||
return CONFIG;
|
||||
}
|
||||
|
@ -51,6 +51,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_6) {
|
||||
return CONFIG_4_6;
|
||||
}
|
||||
if (version >= VERSION_4_3) {
|
||||
return CONFIG_4_3;
|
||||
}
|
||||
|
@ -94,6 +97,11 @@ public class GPPScannerExtensionConfiguration extends GNUScannerExtensionConfigu
|
|||
addKeyword(GCCKeywords.cp__is_polymorphic, IGCCToken.tTT_is_polymorphic);
|
||||
addKeyword(GCCKeywords.cp__is_union, IGCCToken.tTT_is_union);
|
||||
}
|
||||
if (version >= VERSION_4_6) {
|
||||
addKeyword(GCCKeywords.cp__is_literal_type, IGCCToken.tTT_is_literal_type);
|
||||
addKeyword(GCCKeywords.cp__is_standard_layout, IGCCToken.tTT_is_standard_layout);
|
||||
addKeyword(GCCKeywords.cp__is_trivial, IGCCToken.tTT_is_trivial);
|
||||
}
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2002, 2011 IBM Corporation and others.
|
||||
* Copyright (c) 2002, 2012 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
|
||||
|
@ -9,6 +9,7 @@
|
|||
* John Camelon (IBM Rational Software) - Initial API and implementation
|
||||
* Ed Swartz (Nokia)
|
||||
* Markus Schorn (Wind River Systems)
|
||||
* Sergey Prigogin (Google)
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.core.parser;
|
||||
|
||||
|
@ -65,4 +66,12 @@ public class GCCKeywords {
|
|||
cp__is_pod= "__is_pod".toCharArray(),
|
||||
cp__is_polymorphic= "__is_polymorphic".toCharArray(),
|
||||
cp__is_union= "__is_union".toCharArray();
|
||||
|
||||
/**
|
||||
* @since 5.5
|
||||
*/
|
||||
public static final char[]
|
||||
cp__is_literal_type= "__is_literal_type".toCharArray(),
|
||||
cp__is_standard_layout= "__is_standard_layout".toCharArray(),
|
||||
cp__is_trivial= "__is_trivial".toCharArray();
|
||||
}
|
||||
|
|
|
@ -9,8 +9,8 @@
|
|||
* John Camelon (IBM Rational Software) - Initial API and implementation
|
||||
* Ed Swartz (Nokia)
|
||||
* Markus Schorn (Wind River Systems)
|
||||
* Sergey Prigogin (Google)
|
||||
*******************************************************************************/
|
||||
|
||||
package org.eclipse.cdt.core.parser;
|
||||
|
||||
/**
|
||||
|
@ -41,4 +41,7 @@ public interface IGCCToken extends IToken {
|
|||
/** @since 5.3 */ int tTT_is_pod= FIRST_RESERVED_IGCCToken + 19;
|
||||
/** @since 5.3 */ int tTT_is_polymorphic= FIRST_RESERVED_IGCCToken + 20;
|
||||
/** @since 5.3 */ int tTT_is_union= FIRST_RESERVED_IGCCToken + 21;
|
||||
/** @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_trivial= FIRST_RESERVED_IGCCToken + 24;
|
||||
}
|
||||
|
|
|
@ -1302,8 +1302,11 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser {
|
|||
case IGCCToken.tTT_is_class:
|
||||
case IGCCToken.tTT_is_empty:
|
||||
case IGCCToken.tTT_is_enum:
|
||||
case IGCCToken.tTT_is_literal_type:
|
||||
case IGCCToken.tTT_is_pod:
|
||||
case IGCCToken.tTT_is_polymorphic:
|
||||
case IGCCToken.tTT_is_standard_layout:
|
||||
case IGCCToken.tTT_is_trivial:
|
||||
case IGCCToken.tTT_is_union:
|
||||
return parseTypeTrait();
|
||||
|
||||
|
@ -1376,15 +1379,21 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser {
|
|||
case IGCCToken.tTT_is_class:
|
||||
return IASTTypeIdExpression.op_is_class;
|
||||
case IGCCToken.tTT_is_empty:
|
||||
return IASTTypeIdExpression.op_is_abstract;
|
||||
return IASTTypeIdExpression.op_is_empty;
|
||||
case IGCCToken.tTT_is_enum:
|
||||
return IASTTypeIdExpression.op_is_abstract;
|
||||
return IASTTypeIdExpression.op_is_enum;
|
||||
case IGCCToken.tTT_is_literal_type:
|
||||
return IASTTypeIdExpression.op_is_literal_type;
|
||||
case IGCCToken.tTT_is_pod:
|
||||
return IASTTypeIdExpression.op_is_abstract;
|
||||
return IASTTypeIdExpression.op_is_pod;
|
||||
case IGCCToken.tTT_is_polymorphic:
|
||||
return IASTTypeIdExpression.op_is_abstract;
|
||||
return IASTTypeIdExpression.op_is_polymorphic;
|
||||
case IGCCToken.tTT_is_standard_layout:
|
||||
return IASTTypeIdExpression.op_is_standard_layout;
|
||||
case IGCCToken.tTT_is_trivial:
|
||||
return IASTTypeIdExpression.op_is_trivial;
|
||||
case IGCCToken.tTT_is_union:
|
||||
return IASTTypeIdExpression.op_is_abstract;
|
||||
return IASTTypeIdExpression.op_is_union;
|
||||
}
|
||||
assert false;
|
||||
return 0;
|
||||
|
|
|
@ -25,8 +25,11 @@ import static org.eclipse.cdt.core.dom.ast.IASTTypeIdExpression.op_is_abstract;
|
|||
import static org.eclipse.cdt.core.dom.ast.IASTTypeIdExpression.op_is_class;
|
||||
import static org.eclipse.cdt.core.dom.ast.IASTTypeIdExpression.op_is_empty;
|
||||
import static org.eclipse.cdt.core.dom.ast.IASTTypeIdExpression.op_is_enum;
|
||||
import static org.eclipse.cdt.core.dom.ast.IASTTypeIdExpression.op_is_literal_type;
|
||||
import static org.eclipse.cdt.core.dom.ast.IASTTypeIdExpression.op_is_pod;
|
||||
import static org.eclipse.cdt.core.dom.ast.IASTTypeIdExpression.op_is_polymorphic;
|
||||
import static org.eclipse.cdt.core.dom.ast.IASTTypeIdExpression.op_is_standard_layout;
|
||||
import static org.eclipse.cdt.core.dom.ast.IASTTypeIdExpression.op_is_trivial;
|
||||
import static org.eclipse.cdt.core.dom.ast.IASTTypeIdExpression.op_is_union;
|
||||
import static org.eclipse.cdt.core.dom.ast.IASTTypeIdExpression.op_sizeof;
|
||||
import static org.eclipse.cdt.core.dom.ast.IASTTypeIdExpression.op_typeid;
|
||||
|
@ -100,8 +103,11 @@ public class EvalUnaryTypeID extends CPPEvaluation {
|
|||
case op_is_class:
|
||||
case op_is_empty:
|
||||
case op_is_enum:
|
||||
case op_is_literal_type:
|
||||
case op_is_pod:
|
||||
case op_is_polymorphic:
|
||||
case op_is_standard_layout:
|
||||
case op_is_trivial:
|
||||
case op_is_union:
|
||||
return CPPTemplates.isDependentType(fOrigType);
|
||||
|
||||
|
@ -137,8 +143,11 @@ public class EvalUnaryTypeID extends CPPEvaluation {
|
|||
case op_is_class:
|
||||
case op_is_empty:
|
||||
case op_is_enum:
|
||||
case op_is_literal_type:
|
||||
case op_is_pod:
|
||||
case op_is_polymorphic:
|
||||
case op_is_standard_layout:
|
||||
case op_is_trivial:
|
||||
case op_is_union:
|
||||
return CPPBasicType.BOOLEAN;
|
||||
case op_typeof:
|
||||
|
@ -187,10 +196,16 @@ public class EvalUnaryTypeID extends CPPEvaluation {
|
|||
return Value.UNKNOWN; // TODO(sprigogin): Implement
|
||||
case op_is_enum:
|
||||
return Value.create(fOrigType instanceof IEnumeration);
|
||||
case op_is_literal_type:
|
||||
return Value.UNKNOWN; // TODO(sprigogin): Implement
|
||||
case op_is_pod:
|
||||
return Value.UNKNOWN; // TODO(sprigogin): Implement
|
||||
case op_is_polymorphic:
|
||||
return Value.UNKNOWN; // TODO(sprigogin): Implement
|
||||
case op_is_standard_layout:
|
||||
return Value.UNKNOWN; // TODO(sprigogin): Implement
|
||||
case op_is_trivial:
|
||||
return Value.UNKNOWN; // TODO(sprigogin): Implement
|
||||
case op_is_union:
|
||||
return Value.create(fOrigType instanceof ICompositeType && ((ICompositeType) fOrigType).getKey() == ICompositeType.k_union);
|
||||
case op_typeof:
|
||||
|
|
Loading…
Add table
Reference in a new issue