1
0
Fork 0
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:
Sergey Prigogin 2012-08-12 16:31:54 -07:00
parent 2fc1fe1a7d
commit 4167f6cefd
6 changed files with 92 additions and 30 deletions

View file

@ -120,7 +120,7 @@ public interface IASTTypeIdExpression extends IASTExpression {
* Built-in type trait of g++. * Built-in type trait of g++.
* @since 5.3 * @since 5.3
*/ */
public static final int op_is_polymorphic=17; public static final int op_is_polymorphic= 17;
/** /**
* Built-in type trait of g++. * Built-in type trait of g++.
@ -128,6 +128,24 @@ public interface IASTTypeIdExpression extends IASTExpression {
*/ */
public static final int op_is_union= 18; 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 * @deprecated constants should be declared here, to avoid using the same constant in different
* interfaces. * interfaces.

View file

@ -1,16 +1,16 @@
/******************************************************************************* /*******************************************************************************
* Copyright (c) 2004, 2009 IBM Corporation and others. * Copyright (c) 2004, 2009 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0 * are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at * which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html * http://www.eclipse.org/legal/epl-v10.html
* *
* Contributors: * Contributors:
* IBM - Initial API and implementation * IBM - Initial API and implementation
* Ed Swartz (Nokia) * Ed Swartz (Nokia)
* Anton Leherbauer (Wind River Systems) * Anton Leherbauer (Wind River Systems)
* Markus Schorn (Wind River Systems) * Markus Schorn (Wind River Systems)
* Sergey Prigogin (Google) * Sergey Prigogin (Google)
*******************************************************************************/ *******************************************************************************/
package org.eclipse.cdt.core.dom.parser.cpp; package org.eclipse.cdt.core.dom.parser.cpp;
@ -27,16 +27,16 @@ import org.eclipse.cdt.core.parser.Keywords;
* Configures the preprocessor for c++-sources as accepted by g++. * Configures the preprocessor for c++-sources as accepted by g++.
*/ */
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 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 int version(int major, int minor) { private static int version(int major, int minor) {
return (major << 16) + minor; return (major << 16) + minor;
} }
public static GPPScannerExtensionConfiguration getInstance() { public static GPPScannerExtensionConfiguration getInstance() {
return CONFIG; return CONFIG;
} }
@ -51,6 +51,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_6) {
return CONFIG_4_6;
}
if (version >= VERSION_4_3) { if (version >= VERSION_4_3) {
return CONFIG_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_polymorphic, IGCCToken.tTT_is_polymorphic);
addKeyword(GCCKeywords.cp__is_union, IGCCToken.tTT_is_union); 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) /* (non-Javadoc)

View file

@ -1,14 +1,15 @@
/******************************************************************************* /*******************************************************************************
* 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 * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0 * are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at * which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html * http://www.eclipse.org/legal/epl-v10.html
* *
* Contributors: * Contributors:
* John Camelon (IBM Rational Software) - Initial API and implementation * John Camelon (IBM Rational Software) - Initial API and implementation
* Ed Swartz (Nokia) * Ed Swartz (Nokia)
* Markus Schorn (Wind River Systems) * Markus Schorn (Wind River Systems)
* Sergey Prigogin (Google)
*******************************************************************************/ *******************************************************************************/
package org.eclipse.cdt.core.parser; package org.eclipse.cdt.core.parser;
@ -23,7 +24,7 @@ public class GCCKeywords {
public static final String __ATTRIBUTE__ = "__attribute__"; public static final String __ATTRIBUTE__ = "__attribute__";
public static final String __DECLSPEC = "__declspec"; public static final String __DECLSPEC = "__declspec";
public static final char [] public static final char[]
cpTYPEOF = TYPEOF.toCharArray(), cpTYPEOF = TYPEOF.toCharArray(),
cp__ALIGNOF__ = __ALIGNOF__.toCharArray(), cp__ALIGNOF__ = __ALIGNOF__.toCharArray(),
cp__ATTRIBUTE__ = __ATTRIBUTE__.toCharArray(), cp__ATTRIBUTE__ = __ATTRIBUTE__.toCharArray(),
@ -48,7 +49,7 @@ public class GCCKeywords {
/** /**
* @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(),
cp__has_nothrow_constructor= "__has_nothrow_constructor".toCharArray(), cp__has_nothrow_constructor= "__has_nothrow_constructor".toCharArray(),
@ -65,4 +66,12 @@ public class GCCKeywords {
cp__is_pod= "__is_pod".toCharArray(), cp__is_pod= "__is_pod".toCharArray(),
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
*/
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();
} }

View file

@ -6,11 +6,11 @@
* http://www.eclipse.org/legal/epl-v10.html * http://www.eclipse.org/legal/epl-v10.html
* *
* Contributors: * Contributors:
* John Camelon (IBM Rational Software) - Initial API and implementation * John Camelon (IBM Rational Software) - Initial API and implementation
* Ed Swartz (Nokia) * Ed Swartz (Nokia)
* Markus Schorn (Wind River Systems) * Markus Schorn (Wind River Systems)
* Sergey Prigogin (Google)
*******************************************************************************/ *******************************************************************************/
package org.eclipse.cdt.core.parser; 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_pod= FIRST_RESERVED_IGCCToken + 19;
/** @since 5.3 */ int tTT_is_polymorphic= FIRST_RESERVED_IGCCToken + 20; /** @since 5.3 */ int tTT_is_polymorphic= FIRST_RESERVED_IGCCToken + 20;
/** @since 5.3 */ int tTT_is_union= FIRST_RESERVED_IGCCToken + 21; /** @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;
} }

View file

@ -1302,8 +1302,11 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser {
case IGCCToken.tTT_is_class: case IGCCToken.tTT_is_class:
case IGCCToken.tTT_is_empty: case IGCCToken.tTT_is_empty:
case IGCCToken.tTT_is_enum: case IGCCToken.tTT_is_enum:
case IGCCToken.tTT_is_literal_type:
case IGCCToken.tTT_is_pod: case IGCCToken.tTT_is_pod:
case IGCCToken.tTT_is_polymorphic: case IGCCToken.tTT_is_polymorphic:
case IGCCToken.tTT_is_standard_layout:
case IGCCToken.tTT_is_trivial:
case IGCCToken.tTT_is_union: case IGCCToken.tTT_is_union:
return parseTypeTrait(); return parseTypeTrait();
@ -1376,15 +1379,21 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser {
case IGCCToken.tTT_is_class: case IGCCToken.tTT_is_class:
return IASTTypeIdExpression.op_is_class; return IASTTypeIdExpression.op_is_class;
case IGCCToken.tTT_is_empty: case IGCCToken.tTT_is_empty:
return IASTTypeIdExpression.op_is_abstract; return IASTTypeIdExpression.op_is_empty;
case IGCCToken.tTT_is_enum: 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: case IGCCToken.tTT_is_pod:
return IASTTypeIdExpression.op_is_abstract; return IASTTypeIdExpression.op_is_pod;
case IGCCToken.tTT_is_polymorphic: 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: case IGCCToken.tTT_is_union:
return IASTTypeIdExpression.op_is_abstract; return IASTTypeIdExpression.op_is_union;
} }
assert false; assert false;
return 0; return 0;

View file

@ -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_class;
import static org.eclipse.cdt.core.dom.ast.IASTTypeIdExpression.op_is_empty; 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_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_pod;
import static org.eclipse.cdt.core.dom.ast.IASTTypeIdExpression.op_is_polymorphic; 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_is_union;
import static org.eclipse.cdt.core.dom.ast.IASTTypeIdExpression.op_sizeof; import static org.eclipse.cdt.core.dom.ast.IASTTypeIdExpression.op_sizeof;
import static org.eclipse.cdt.core.dom.ast.IASTTypeIdExpression.op_typeid; 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_class:
case op_is_empty: case op_is_empty:
case op_is_enum: case op_is_enum:
case op_is_literal_type:
case op_is_pod: case op_is_pod:
case op_is_polymorphic: case op_is_polymorphic:
case op_is_standard_layout:
case op_is_trivial:
case op_is_union: case op_is_union:
return CPPTemplates.isDependentType(fOrigType); return CPPTemplates.isDependentType(fOrigType);
@ -137,8 +143,11 @@ public class EvalUnaryTypeID extends CPPEvaluation {
case op_is_class: case op_is_class:
case op_is_empty: case op_is_empty:
case op_is_enum: case op_is_enum:
case op_is_literal_type:
case op_is_pod: case op_is_pod:
case op_is_polymorphic: case op_is_polymorphic:
case op_is_standard_layout:
case op_is_trivial:
case op_is_union: case op_is_union:
return CPPBasicType.BOOLEAN; return CPPBasicType.BOOLEAN;
case op_typeof: case op_typeof:
@ -187,10 +196,16 @@ public class EvalUnaryTypeID extends CPPEvaluation {
return Value.UNKNOWN; // TODO(sprigogin): Implement return Value.UNKNOWN; // TODO(sprigogin): Implement
case op_is_enum: case op_is_enum:
return Value.create(fOrigType instanceof IEnumeration); return Value.create(fOrigType instanceof IEnumeration);
case op_is_literal_type:
return Value.UNKNOWN; // TODO(sprigogin): Implement
case op_is_pod: case op_is_pod:
return Value.UNKNOWN; // TODO(sprigogin): Implement return Value.UNKNOWN; // TODO(sprigogin): Implement
case op_is_polymorphic: case op_is_polymorphic:
return Value.UNKNOWN; // TODO(sprigogin): Implement 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: case op_is_union:
return Value.create(fOrigType instanceof ICompositeType && ((ICompositeType) fOrigType).getKey() == ICompositeType.k_union); return Value.create(fOrigType instanceof ICompositeType && ((ICompositeType) fOrigType).getKey() == ICompositeType.k_union);
case op_typeof: case op_typeof: