mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-29 19:45:01 +02:00
Bug 342683: Support for built-in type-traits.
This commit is contained in:
parent
7f65962244
commit
b0574975ec
5 changed files with 200 additions and 8 deletions
|
@ -1,12 +1,12 @@
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
* Copyright (c) 2004, 2010 IBM Corporation and others.
|
* Copyright (c) 2004, 2011 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 Rational Software - Initial API and implementation
|
* John Camelon (IBM Rational Software) - Initial API and implementation
|
||||||
* Markus Schorn (Wind River Systems)
|
* Markus Schorn (Wind River Systems)
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.cdt.core.parser.tests.ast2;
|
package org.eclipse.cdt.core.parser.tests.ast2;
|
||||||
|
@ -31,10 +31,6 @@ import org.eclipse.cdt.internal.core.dom.parser.c.CFunction;
|
||||||
import org.eclipse.cdt.internal.core.model.ASTStringUtil;
|
import org.eclipse.cdt.internal.core.model.ASTStringUtil;
|
||||||
import org.eclipse.cdt.internal.core.parser.ParserException;
|
import org.eclipse.cdt.internal.core.parser.ParserException;
|
||||||
|
|
||||||
/**
|
|
||||||
* @author jcamelon
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
public class GCCCompleteParseExtensionsTest extends AST2BaseTest {
|
public class GCCCompleteParseExtensionsTest extends AST2BaseTest {
|
||||||
|
|
||||||
public GCCCompleteParseExtensionsTest() {
|
public GCCCompleteParseExtensionsTest() {
|
||||||
|
@ -410,4 +406,27 @@ public class GCCCompleteParseExtensionsTest extends AST2BaseTest {
|
||||||
String code= getAboveComment();
|
String code= getAboveComment();
|
||||||
parseGPP(code);
|
parseGPP(code);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// void test(){
|
||||||
|
// bool b;
|
||||||
|
// b= __has_nothrow_assign (int);
|
||||||
|
// b= __has_nothrow_copy (int);
|
||||||
|
// b= __has_nothrow_constructor (int);
|
||||||
|
// b= __has_trivial_assign (int);
|
||||||
|
// b= __has_trivial_copy (int);
|
||||||
|
// b= __has_trivial_constructor (int);
|
||||||
|
// b= __has_trivial_destructor (int);
|
||||||
|
// b= __has_virtual_destructor (int);
|
||||||
|
// b= __is_abstract (int);
|
||||||
|
// b= __is_base_of (char, int);
|
||||||
|
// b= __is_class (int);
|
||||||
|
// b= __is_empty (int);
|
||||||
|
// b= __is_enum (int);
|
||||||
|
// b= __is_pod (int);
|
||||||
|
// b= __is_polymorphic (int);
|
||||||
|
// b= __is_union (int);
|
||||||
|
// }
|
||||||
|
public void testTypetraits_Bug342683() throws Exception {
|
||||||
|
parseGPP(getAboveComment());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,59 @@
|
||||||
|
/*******************************************************************************
|
||||||
|
* Copyright (c) 2011 Wind River Systems, Inc. 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:
|
||||||
|
* Markus Schorn (Wind River Systems) - Initial API and implementation
|
||||||
|
*******************************************************************************/
|
||||||
|
package org.eclipse.cdt.core.dom.ast;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @noextend This interface is not intended to be extended by clients.
|
||||||
|
* @noimplement This interface is not intended to be implemented by clients.
|
||||||
|
* @since 5.3
|
||||||
|
*/
|
||||||
|
public interface IASTBinaryTypeIdExpression extends IASTExpression {
|
||||||
|
public static final ASTNodeProperty OPERAND1 = new ASTNodeProperty("IASTBinaryTypeIdExpression.OPERAND1 [IASTTypeId]"); //$NON-NLS-1$
|
||||||
|
public static final ASTNodeProperty OPERAND2 = new ASTNodeProperty("IASTBinaryTypeIdExpression.OPERAND2 [IASTTypeId]"); //$NON-NLS-1$
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Built-in type trait of g++.
|
||||||
|
*/
|
||||||
|
public static enum Operator {__is_base_of}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the operator for the expression.
|
||||||
|
*/
|
||||||
|
public Operator getOperator();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the first operand.
|
||||||
|
*/
|
||||||
|
public IASTTypeId getOperand1();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the second operand, or <code>null</code> if it was not provided (content assist).
|
||||||
|
*/
|
||||||
|
public IASTTypeId getOperand2();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the operator for the expression.
|
||||||
|
*/
|
||||||
|
public void setOperator(Operator value);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the first operand.
|
||||||
|
*/
|
||||||
|
public void setOperand1(IASTTypeId typeId);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the second operand.
|
||||||
|
*/
|
||||||
|
public void setOperand2(IASTTypeId typeId);
|
||||||
|
|
||||||
|
public IASTBinaryTypeIdExpression copy();
|
||||||
|
public IASTBinaryTypeIdExpression copy(CopyStyle style);
|
||||||
|
}
|
|
@ -39,6 +39,96 @@ public interface IASTTypeIdExpression extends IASTExpression {
|
||||||
*/
|
*/
|
||||||
public static final int op_typeof = 3;
|
public static final int op_typeof = 3;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Built-in type trait of g++.
|
||||||
|
* @since 5.3
|
||||||
|
*/
|
||||||
|
public static final int op_has_nothrow_assign= 4;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Built-in type trait of g++.
|
||||||
|
* @since 5.3
|
||||||
|
*/
|
||||||
|
public static final int op_has_nothrow_copy= 5;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Built-in type trait of g++.
|
||||||
|
* @since 5.3
|
||||||
|
*/
|
||||||
|
public static final int op_has_nothrow_constructor= 6;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Built-in type trait of g++.
|
||||||
|
* @since 5.3
|
||||||
|
*/
|
||||||
|
public static final int op_has_trivial_assign= 7;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Built-in type trait of g++.
|
||||||
|
* @since 5.3
|
||||||
|
*/
|
||||||
|
public static final int op_has_trivial_copy= 8;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Built-in type trait of g++.
|
||||||
|
* @since 5.3
|
||||||
|
*/
|
||||||
|
public static final int op_has_trivial_constructor= 9;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Built-in type trait of g++.
|
||||||
|
* @since 5.3
|
||||||
|
*/
|
||||||
|
public static final int op_has_trivial_destructor= 10;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Built-in type trait of g++.
|
||||||
|
* @since 5.3
|
||||||
|
*/
|
||||||
|
public static final int op_has_virtual_destructor= 11;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Built-in type trait of g++.
|
||||||
|
* @since 5.3
|
||||||
|
*/
|
||||||
|
public static final int op_is_abstract= 12;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Built-in type trait of g++.
|
||||||
|
* @since 5.3
|
||||||
|
*/
|
||||||
|
public static final int op_is_class= 13;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Built-in type trait of g++.
|
||||||
|
* @since 5.3
|
||||||
|
*/
|
||||||
|
public static final int op_is_empty= 14;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Built-in type trait of g++.
|
||||||
|
* @since 5.3
|
||||||
|
*/
|
||||||
|
public static final int op_is_enum= 15;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Built-in type trait of g++.
|
||||||
|
* @since 5.3
|
||||||
|
*/
|
||||||
|
public static final int op_is_pod= 16;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Built-in type trait of g++.
|
||||||
|
* @since 5.3
|
||||||
|
*/
|
||||||
|
public static final int op_is_polymorphic=17;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Built-in type trait of g++.
|
||||||
|
* @since 5.3
|
||||||
|
*/
|
||||||
|
public static final int op_is_union= 18;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @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.
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
* Copyright (c) 2006, 2010 IBM Corporation and others.
|
* Copyright (c) 2006, 2011 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
|
||||||
|
@ -11,6 +11,7 @@
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.cdt.core.dom.ast.cpp;
|
package org.eclipse.cdt.core.dom.ast.cpp;
|
||||||
|
|
||||||
|
import org.eclipse.cdt.core.dom.ast.IASTBinaryTypeIdExpression;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTDeclSpecifier;
|
import org.eclipse.cdt.core.dom.ast.IASTDeclSpecifier;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTDeclaration;
|
import org.eclipse.cdt.core.dom.ast.IASTDeclaration;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTDeclarator;
|
import org.eclipse.cdt.core.dom.ast.IASTDeclarator;
|
||||||
|
@ -58,6 +59,11 @@ public interface ICPPNodeFactory extends INodeFactory {
|
||||||
*/
|
*/
|
||||||
public ICPPASTBinaryExpression newBinaryExpression(int op, IASTExpression expr1, IASTInitializerClause expr2);
|
public ICPPASTBinaryExpression newBinaryExpression(int op, IASTExpression expr1, IASTInitializerClause expr2);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @since 5.3
|
||||||
|
*/
|
||||||
|
public IASTExpression newBinaryTypeIdExpression(IASTBinaryTypeIdExpression.Operator op, IASTTypeId type1, IASTTypeId type2);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @since 5.3
|
* @since 5.3
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
* Copyright (c) 2004, 2010 IBM Corporation and others.
|
* Copyright (c) 2004, 2011 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
|
||||||
|
@ -70,6 +70,24 @@ public abstract class GNUScannerExtensionConfiguration extends AbstractScannerEx
|
||||||
addKeyword(GCCKeywords.cp__TYPEOF, IGCCToken.t_typeof);
|
addKeyword(GCCKeywords.cp__TYPEOF, IGCCToken.t_typeof);
|
||||||
addKeyword(GCCKeywords.cp__TYPEOF__, IGCCToken.t_typeof);
|
addKeyword(GCCKeywords.cp__TYPEOF__, IGCCToken.t_typeof);
|
||||||
addKeyword(GCCKeywords.cpTYPEOF, IGCCToken.t_typeof );
|
addKeyword(GCCKeywords.cpTYPEOF, IGCCToken.t_typeof );
|
||||||
|
|
||||||
|
// Type-traits
|
||||||
|
addKeyword(GCCKeywords.cp__has_nothrow_assign, IGCCToken.tTT_has_nothrow_assign);
|
||||||
|
addKeyword(GCCKeywords.cp__has_nothrow_constructor, IGCCToken.tTT_has_nothrow_constructor);
|
||||||
|
addKeyword(GCCKeywords.cp__has_nothrow_copy, IGCCToken.tTT_has_nothrow_copy);
|
||||||
|
addKeyword(GCCKeywords.cp__has_trivial_assign, IGCCToken.tTT_has_trivial_assign);
|
||||||
|
addKeyword(GCCKeywords.cp__has_trivial_constructor, IGCCToken.tTT_has_trivial_constructor);
|
||||||
|
addKeyword(GCCKeywords.cp__has_trivial_copy, IGCCToken.tTT_has_trivial_copy);
|
||||||
|
addKeyword(GCCKeywords.cp__has_trivial_destructor, IGCCToken.tTT_has_trivial_destructor);
|
||||||
|
addKeyword(GCCKeywords.cp__has_virtual_destructor, IGCCToken.tTT_has_virtual_destructor);
|
||||||
|
addKeyword(GCCKeywords.cp__is_abstract, IGCCToken.tTT_is_abstract);
|
||||||
|
addKeyword(GCCKeywords.cp__is_base_of, IGCCToken.tTT_is_base_of);
|
||||||
|
addKeyword(GCCKeywords.cp__is_class, IGCCToken.tTT_is_class);
|
||||||
|
addKeyword(GCCKeywords.cp__is_empty, IGCCToken.tTT_is_empty);
|
||||||
|
addKeyword(GCCKeywords.cp__is_enum, IGCCToken.tTT_is_enum);
|
||||||
|
addKeyword(GCCKeywords.cp__is_pod, IGCCToken.tTT_is_pod);
|
||||||
|
addKeyword(GCCKeywords.cp__is_polymorphic, IGCCToken.tTT_is_polymorphic);
|
||||||
|
addKeyword(GCCKeywords.cp__is_union, IGCCToken.tTT_is_union);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
Loading…
Add table
Reference in a new issue