1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-04-23 22:52:11 +02:00

Bug 332829. Parsing support for constexpr keyword. Also added few

new C++11 keywords.
This commit is contained in:
Sergey Prigogin 2012-05-16 13:27:59 -07:00
parent a37a37d4c1
commit e553255384
17 changed files with 166 additions and 104 deletions

View file

@ -1184,6 +1184,24 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest {
assertInstance(d, IASTProblemDeclaration.class);
}
// constexpr int square(int x);
// constexpr int bufsz = 1024;
// struct pixel {
// int x;
// int y;
// constexpr pixel(int);
// };
// constexpr pixel::pixel(int a)
// : x(square(a)), y(square(a))
// { }
// constexpr int square(int x) {
// return x * x;
// }
// constexpr pixel large(4);
public void test7_1_5s1() throws Exception {
parse(getAboveComment(), ParserLanguage.CPP, true, 0);
}
// int foo() {
// const int ci = 3; // cvqualified (initialized as required)
// ci = 4; // illformed: attempt to modify const

View file

@ -510,7 +510,16 @@ public class ASTSignatureUtil {
}
if (declSpec instanceof ICPPASTDeclSpecifier) {
if (((ICPPASTDeclSpecifier) declSpec).isExplicit()) {
ICPPASTDeclSpecifier cppDeclSpec = (ICPPASTDeclSpecifier) declSpec;
if (cppDeclSpec.isConstexpr()) {
if (needSpace) {
result.append(SPACE);
needSpace = false;
}
result.append(Keywords.CONSTEXPR);
needSpace = true;
}
if (cppDeclSpec.isExplicit()) {
if (needSpace) {
result.append(SPACE);
needSpace = false;
@ -518,7 +527,7 @@ public class ASTSignatureUtil {
result.append(Keywords.EXPLICIT);
needSpace = true;
}
if (((ICPPASTDeclSpecifier) declSpec).isFriend()) {
if (cppDeclSpec.isFriend()) {
if (needSpace) {
result.append(SPACE);
needSpace = false;
@ -526,7 +535,7 @@ public class ASTSignatureUtil {
result.append(Keywords.FRIEND);
needSpace = true;
}
if (((ICPPASTDeclSpecifier) declSpec).isVirtual()) {
if (cppDeclSpec.isVirtual()) {
if (needSpace) {
result.append(SPACE);
needSpace = false;

View file

@ -63,6 +63,22 @@ public interface ICPPASTDeclSpecifier extends IASTDeclSpecifier {
*/
public void setExplicit(boolean value);
/**
* Is this a constexpr
*
* @return boolean
* @since 5.4
*/
public boolean isConstexpr();
/**
* Sets this to be constexpr.
*
* @param value the new value
* @since 5.4
*/
public void setConstexpr(boolean value);
/**
* @since 5.1
*/

View file

@ -114,7 +114,8 @@ public interface IToken {
/** @deprecated use {@link #tBITCOMPLEMENT} */ @Deprecated int tCOMPL= tBITCOMPLEMENT;
/** @deprecated use {@link #tBITCOMPLEMENT} */ @Deprecated int t_compl = 66;
int t_const = 67;
/** @since 5.4 */ int t_constexpr = 5400;
int t_const_cast = 69;
int t_continue = 70;
/** @since 5.2 */
@ -141,7 +142,8 @@ public interface IToken {
int t_mutable = 90;
int t_namespace = 91;
int t_new = 92;
/** @since 5.4 */ int t_nullptr = 5400;
/** @since 5.4 */ int t_noexcept = 5401;
/** @since 5.4 */ int t_nullptr = 5402;
/** @deprecated use {@link #tNOT} */ @Deprecated int t_not = 93;
/** @deprecated use {@link #tNOTEQUAL} */ @Deprecated int t_not_eq = 94;
int t_operator = 95;
@ -164,6 +166,7 @@ public interface IToken {
int t_switch = 110;
int t_template = 111;
int t_this = 112;
/** @since 5.4 */ int t_thread_local = 5403;
int t_throw = 113;
int t_true = 114;
int t_try = 115;

View file

@ -6,9 +6,9 @@
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* John Camelon (IBM Rational Software) - Initial API and implementation
* Anton Leherbauer (Wind River Systems)
* Markus Schorn (Wind River Systems)
* John Camelon (IBM Rational Software) - Initial API and implementation
* Anton Leherbauer (Wind River Systems)
* Markus Schorn (Wind River Systems)
*******************************************************************************/
package org.eclipse.cdt.core.parser;
@ -20,9 +20,10 @@ import org.eclipse.cdt.core.parser.util.CharArrayIntMap;
*/
@SuppressWarnings("nls")
public class Keywords {
public static final String CAST = "cast";
public static final String ALIGNOF = "alignof";
public static final String CAST = "cast";
/** @since 5.4 */
public static final String ALIGNAS = "alignas";
public static final String ALIGNOF = "alignof";
public static final String TYPEOF = "typeof";
public static final String _BOOL = "_Bool";
@ -46,6 +47,8 @@ public class Keywords {
public static final String CLASS = "class";
public static final String COMPL = "compl";
public static final String CONST = "const";
/** @since 5.4 */
public static final String CONSTEXPR = "constexpr";
public static final String CONST_CAST = "const_cast";
public static final String CONTINUE = "continue";
/** @since 5.2 */
@ -75,7 +78,9 @@ public class Keywords {
/** @since 5.4 */
public static final String NULLPTR = "nullptr";
public static final String NEW = "new";
public static final String NOT = "not";
/** @since 5.4 */
public static final String NOEXCEPT = "noexcept";
public static final String NOT = "not";
public static final String NOT_EQ = "not_eq";
public static final String OPERATOR = "operator";
public static final String OR = "or";
@ -98,6 +103,8 @@ public class Keywords {
public static final String SWITCH = "switch";
public static final String TEMPLATE = "template";
public static final String THIS = "this";
/** @since 5.4 */
public static final String THREAD_LOCAL = "thread_local";
public static final String THROW = "throw";
public static final String TRUE = "true";
public static final String TRY = "try";
@ -119,6 +126,8 @@ public class Keywords {
public static final char[] c_BOOL = "_Bool".toCharArray();
public static final char[] c_COMPLEX = "_Complex".toCharArray();
public static final char[] c_IMAGINARY = "_Imaginary".toCharArray();
/** @since 5.4 */
public static final char[] cALIGNAS = "alignas".toCharArray();
/** @since 5.3 */
public static final char[] cALIGNOF = "alignof".toCharArray();
public static final char[] cAND = "and".toCharArray();
@ -139,6 +148,8 @@ public class Keywords {
public static final char[] cCLASS = "class".toCharArray();
public static final char[] cCOMPL = "compl".toCharArray();
public static final char[] cCONST = "const".toCharArray();
/** @since 5.4 */
public static final char[] cCONSTEXPR = "constexpr".toCharArray();
public static final char[] cCONST_CAST = "const_cast".toCharArray();
public static final char[] cCONTINUE = "continue".toCharArray();
public static final char[] cDEFAULT = "default".toCharArray();
@ -167,6 +178,8 @@ public class Keywords {
public static final char[] cNEW = "new".toCharArray();
/** @since 5.4 */
public static final char[] cNULLPTR = NULLPTR.toCharArray();
/** @since 5.4 */
public static final char[] cNOEXCEPT = "noexcept".toCharArray();
public static final char[] cNOT = "not".toCharArray();
public static final char[] cNOT_EQ = "not_eq".toCharArray();
public static final char[] cOPERATOR = "operator".toCharArray();
@ -192,6 +205,8 @@ public class Keywords {
public static final char[] cSWITCH = "switch".toCharArray();
public static final char[] cTEMPLATE = "template".toCharArray();
public static final char[] cTHIS = "this".toCharArray();
/** @since 5.4 */
public static final char[] cTHREAD_LOCAL = "thread_local".toCharArray();
public static final char[] cTHROW = "throw".toCharArray();
public static final char[] cTRUE = "true".toCharArray();
public static final char[] cTRY = "try".toCharArray();
@ -301,7 +316,6 @@ public class Keywords {
addCpp(kw);
}
private static void addCommon(CharArrayIntMap words) {
words.put(Keywords._Pragma, IToken.t_PRAGMA);
words.put(Keywords.cAUTO, IToken.t_auto);
@ -354,6 +368,7 @@ public class Keywords {
cppkeywords.put(Keywords.cCHAR16_T, IToken.t_char16_t);
cppkeywords.put(Keywords.cCHAR32_T, IToken.t_char32_t);
cppkeywords.put(Keywords.cCLASS, IToken.t_class);
cppkeywords.put(Keywords.cCONSTEXPR, IToken.t_constexpr);
cppkeywords.put(Keywords.cCONST_CAST, IToken.t_const_cast);
cppkeywords.put(Keywords.cDECLTYPE, IToken.t_decltype);
cppkeywords.put(Keywords.cDELETE, IToken.t_delete);
@ -365,6 +380,7 @@ public class Keywords {
cppkeywords.put(Keywords.cMUTABLE, IToken.t_mutable);
cppkeywords.put(Keywords.cNAMESPACE, IToken.t_namespace);
cppkeywords.put(Keywords.cNEW, IToken.t_new);
cppkeywords.put(Keywords.cNOEXCEPT, IToken.t_noexcept);
cppkeywords.put(Keywords.cNULLPTR, IToken.t_nullptr);
cppkeywords.put(Keywords.cOPERATOR, IToken.t_operator);
cppkeywords.put(Keywords.cPRIVATE, IToken.t_private);
@ -375,6 +391,7 @@ public class Keywords {
cppkeywords.put(Keywords.cSTATIC_CAST, IToken.t_static_cast);
cppkeywords.put(Keywords.cTEMPLATE, IToken.t_template);
cppkeywords.put(Keywords.cTHIS, IToken.t_this);
cppkeywords.put(Keywords.cTHREAD_LOCAL, IToken.t_thread_local);
cppkeywords.put(Keywords.cTHROW, IToken.t_throw);
cppkeywords.put(Keywords.cTRUE, IToken.t_true);
cppkeywords.put(Keywords.cTRY, IToken.t_try);

View file

@ -22,6 +22,7 @@ public abstract class CPPASTBaseDeclSpecifier extends ASTNode implements ICPPAST
private boolean friend;
private boolean inline;
private boolean isConst;
private boolean isConstexpr;
private boolean isVolatile;
private boolean isRestrict;
private int sc;
@ -55,6 +56,17 @@ public abstract class CPPASTBaseDeclSpecifier extends ASTNode implements ICPPAST
isConst = value;
}
@Override
public boolean isConstexpr() {
return isConstexpr;
}
@Override
public void setConstexpr(boolean value) {
assertNotFrozen();
isConstexpr = value;
}
@Override
public boolean isVolatile() {
return isVolatile;
@ -116,18 +128,19 @@ public abstract class CPPASTBaseDeclSpecifier extends ASTNode implements ICPPAST
this.explicit = value;
}
protected void copyBaseDeclSpec(CPPASTBaseDeclSpecifier other) {
other.friend = friend;
other.inline = inline;
other.isConst = isConst;
other.isVolatile = isVolatile;
other.isRestrict= isRestrict;
other.virtual = virtual;
other.explicit = explicit;
other.sc = sc;
other.setOffsetAndLength(this);
}
protected <T extends CPPASTBaseDeclSpecifier> T copy(T copy, CopyStyle style) {
copy.friend = friend;
copy.inline = inline;
copy.isConst = isConst;
copy.isConstexpr = isConstexpr;
copy.isVolatile = isVolatile;
copy.isRestrict= isRestrict;
copy.virtual = virtual;
copy.explicit = explicit;
copy.sc = sc;
return super.copy(copy, style);
}
/**
* Provided for debugging purposes, only.
*/

View file

@ -61,16 +61,11 @@ public class CPPASTCompositeTypeSpecifier extends CPPASTBaseDeclSpecifier
public CPPASTCompositeTypeSpecifier copy(CopyStyle style) {
CPPASTCompositeTypeSpecifier copy =
new CPPASTCompositeTypeSpecifier(fKey, fName == null ? null : fName.copy(style));
copyBaseDeclSpec(copy);
for (IASTDeclaration member : getMembers())
copy.addMemberDeclaration(member == null ? null : member.copy(style));
for (ICPPASTBaseSpecifier baseSpecifier : getBaseSpecifiers())
copy.addBaseSpecifier(baseSpecifier == null ? null : baseSpecifier.copy(style));
if (style == CopyStyle.withLocations) {
copy.setCopyLocation(this);
}
return copy;
return super.copy(copy, style);
}
@Override

View file

@ -45,13 +45,9 @@ public class CPPASTElaboratedTypeSpecifier extends CPPASTBaseDeclSpecifier
@Override
public CPPASTElaboratedTypeSpecifier copy(CopyStyle style) {
CPPASTElaboratedTypeSpecifier copy = new CPPASTElaboratedTypeSpecifier(kind, name == null
? null : name.copy(style));
copyBaseDeclSpec(copy);
if (style == CopyStyle.withLocations) {
copy.setCopyLocation(this);
}
return copy;
CPPASTElaboratedTypeSpecifier copy =
new CPPASTElaboratedTypeSpecifier(kind, name == null ? null : name.copy(style));
return super.copy(copy, style);
}
@Override

View file

@ -55,13 +55,10 @@ public class CPPASTEnumerationSpecifier extends CPPASTBaseDeclSpecifier
new CPPASTEnumerationSpecifier(fIsScoped, fName == null ? null : fName.copy(style),
fBaseType == null ? null : fBaseType.copy(style));
copy.fIsOpaque = fIsOpaque;
for (IASTEnumerator enumerator : getEnumerators())
for (IASTEnumerator enumerator : getEnumerators()) {
copy.addEnumerator(enumerator == null ? null : enumerator.copy(style));
copyBaseDeclSpec(copy);
if (style == CopyStyle.withLocations) {
copy.setCopyLocation(this);
}
return copy;
return super.copy(copy, style);
}
@Override

View file

@ -47,12 +47,8 @@ public class CPPASTNamedTypeSpecifier extends CPPASTBaseDeclSpecifier
public CPPASTNamedTypeSpecifier copy(CopyStyle style) {
CPPASTNamedTypeSpecifier copy =
new CPPASTNamedTypeSpecifier(name == null ? null : name.copy(style));
copyBaseDeclSpec(copy);
copy.typename = typename;
if (style == CopyStyle.withLocations) {
copy.setCopyLocation(this);
}
return copy;
return super.copy(copy, style);
}
@Override

View file

@ -37,27 +37,22 @@ public class CPPASTSimpleDeclSpecifier extends CPPASTBaseDeclSpecifier
@Override
public CPPASTSimpleDeclSpecifier copy(CopyStyle style) {
CPPASTSimpleDeclSpecifier copy = new CPPASTSimpleDeclSpecifier();
copySimpleDeclSpec(copy, style);
if (style == CopyStyle.withLocations) {
copy.setCopyLocation(this);
}
return copy;
return copy(new CPPASTSimpleDeclSpecifier(), style);
}
protected void copySimpleDeclSpec(CPPASTSimpleDeclSpecifier other, CopyStyle style) {
copyBaseDeclSpec(other);
other.type = type;
other.isSigned = isSigned;
other.isUnsigned = isUnsigned;
other.isShort = isShort;
other.isLong = isLong;
other.isLonglong= isLonglong;
other.isComplex= isComplex;
other.isImaginary= isImaginary;
protected <T extends CPPASTSimpleDeclSpecifier> T copy(T copy, CopyStyle style) {
copy.type = type;
copy.isSigned = isSigned;
copy.isUnsigned = isUnsigned;
copy.isShort = isShort;
copy.isLong = isLong;
copy.isLonglong= isLonglong;
copy.isComplex= isComplex;
copy.isImaginary= isImaginary;
if (fDeclTypeExpression != null) {
other.setDeclTypeExpression(fDeclTypeExpression.copy(style));
copy.setDeclTypeExpression(fDeclTypeExpression.copy(style));
}
return super.copy(copy, style);
}
/**

View file

@ -2593,9 +2593,9 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser {
}
private final static int INLINE=0x1, CONST=0x2, RESTRICT=0x4, VOLATILE=0x8,
SHORT=0x10, UNSIGNED= 0x20, SIGNED=0x40, COMPLEX=0x80, IMAGINARY=0x100,
VIRTUAL=0x200, EXPLICIT=0x400, FRIEND=0x800;
private final static int INLINE= 0x1, CONST= 0x2, CONSTEXPR= 0x4, RESTRICT= 0x8, VOLATILE= 0x10,
SHORT= 0x20, UNSIGNED= 0x40, SIGNED= 0x80, COMPLEX= 0x100, IMAGINARY= 0x200,
VIRTUAL= 0x400, EXPLICIT= 0x800, FRIEND= 0x1000;
private static final int FORBID_IN_EMPTY_DECLSPEC =
CONST | RESTRICT | VOLATILE | SHORT | UNSIGNED | SIGNED | COMPLEX | IMAGINARY | FRIEND;
@ -2605,14 +2605,14 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser {
* the ANSI C++ specification.
* declSpecifier :
* "register" | "static" | "extern" | "mutable" |
* "inline" | "virtual" | "explicit" |
* "typedef" | "friend" |
* "const" | "volatile" |
* "inline" | "virtual" | "explicit" |
* "typedef" | "friend" | "constexpr" |
* "const" | "volatile" |
* "short" | "long" | "signed" | "unsigned" | "int" |
* "char" | "wchar_t" | "bool" | "float" | "double" | "void" |
* "auto" |
* ("typename")? name |
* { "class" | "struct" | "union" } classSpecifier |
* ("typename")? name |
* { "class" | "struct" | "union" } classSpecifier |
* {"enum"} enumSpecifier
*/
@Override
@ -2707,6 +2707,10 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser {
options |= FRIEND;
endOffset= consume().getEndOffset();
break;
case IToken.t_constexpr:
options |= CONSTEXPR;
endOffset= consume().getEndOffset();
break;
// type specifier
case IToken.t_const:
options |= CONST;
@ -3007,6 +3011,7 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser {
private void configureDeclSpec(ICPPASTDeclSpecifier declSpec, int storageClass, int options) {
declSpec.setStorageClass(storageClass);
declSpec.setConst((options & CONST) != 0);
declSpec.setConstexpr((options & CONSTEXPR) != 0);
declSpec.setVolatile((options & VOLATILE) != 0);
declSpec.setInline((options & INLINE) != 0);
declSpec.setFriend((options & FRIEND) != 0);

View file

@ -6,8 +6,8 @@
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* John Camelon (IBM) - Initial API and implementation
* Markus Schorn (Wind River Systems)
* John Camelon (IBM) - Initial API and implementation
* Markus Schorn (Wind River Systems)
*******************************************************************************/
package org.eclipse.cdt.internal.core.dom.parser.cpp;
@ -18,8 +18,8 @@ import org.eclipse.cdt.core.dom.ast.gnu.cpp.IGPPASTSimpleDeclSpecifier;
* @deprecated Replaced by {@link CPPASTSimpleDeclSpecifier}
*/
@Deprecated
public class GPPASTSimpleDeclSpecifier extends CPPASTSimpleDeclSpecifier implements
IGPPASTSimpleDeclSpecifier {
public class GPPASTSimpleDeclSpecifier extends CPPASTSimpleDeclSpecifier
implements IGPPASTSimpleDeclSpecifier {
public GPPASTSimpleDeclSpecifier() {
}
@ -36,12 +36,7 @@ public class GPPASTSimpleDeclSpecifier extends CPPASTSimpleDeclSpecifier impleme
@Override
public GPPASTSimpleDeclSpecifier copy(CopyStyle style) {
GPPASTSimpleDeclSpecifier copy = new GPPASTSimpleDeclSpecifier();
copySimpleDeclSpec(copy, style);
if (style == CopyStyle.withLocations) {
copy.setCopyLocation(this);
}
return copy;
return copy(new GPPASTSimpleDeclSpecifier(), style);
}
@Override

View file

@ -54,11 +54,12 @@ public class DeclSpecWriter extends NodeWriter {
private static final String STRUCT = "struct"; //$NON-NLS-1$
private static final String CLASS = "class"; //$NON-NLS-1$
private static final String FRIEND = "friend "; //$NON-NLS-1$
private static final String CONSTEXPR = "constexpr "; //$NON-NLS-1$
private static final String EXPLICIT = "explicit "; //$NON-NLS-1$
private static final String VIRTUAL = "virtual "; //$NON-NLS-1$
private static final String UNION_SPACE = "union "; //$NON-NLS-1$
private static final String STRUCT_SPACE = "struct "; //$NON-NLS-1$
private static final String ENUM = "enum "; //$NON-NLS-1$
private static final String ENUM_SPACE = "enum "; //$NON-NLS-1$
private static final String _BOOL = "_Bool"; //$NON-NLS-1$
public DeclSpecWriter(Scribe scribe, ASTWriterVisitor visitor, NodeCommentMap commentMap) {
@ -168,7 +169,7 @@ public class DeclSpecWriter extends NodeWriter {
private String getElabTypeString(int kind) {
switch (kind) {
case IASTElaboratedTypeSpecifier.k_enum:
return ENUM;
return ENUM_SPACE;
case IASTElaboratedTypeSpecifier.k_struct:
return STRUCT_SPACE;
case IASTElaboratedTypeSpecifier.k_union:
@ -185,6 +186,9 @@ public class DeclSpecWriter extends NodeWriter {
if (cppDelcSpec.isVirtual()) {
scribe.print(VIRTUAL);
}
if (cppDelcSpec.isConstexpr()) {
scribe.print(CONSTEXPR);
}
if (cppDelcSpec.isExplicit()) {
scribe.print(EXPLICIT);
}
@ -209,7 +213,7 @@ public class DeclSpecWriter extends NodeWriter {
}
private void writeEnumSpec(IASTEnumerationSpecifier enumSpec) {
scribe.print(ENUM);
scribe.print(ENUM_SPACE);
enumSpec.getName().accept(visitor);
scribe.print('{');
scribe.printSpace();

View file

@ -393,6 +393,7 @@ public class KeywordSets {
ALL_CPP.add(Keywords.CLASS);
ALL_CPP.add(Keywords.COMPL);
ALL_CPP.add(Keywords.CONST);
ALL_CPP.add(Keywords.CONSTEXPR);
ALL_CPP.add(Keywords.CONST_CAST);
ALL_CPP.add(Keywords.CONTINUE);
ALL_CPP.add(Keywords.DECLTYPE);
@ -418,6 +419,7 @@ public class KeywordSets {
ALL_CPP.add(Keywords.MUTABLE);
ALL_CPP.add(Keywords.NAMESPACE);
ALL_CPP.add(Keywords.NEW);
ALL_CPP.add(Keywords.NOEXCEPT);
ALL_CPP.add(Keywords.NOT);
ALL_CPP.add(Keywords.NOT_EQ);
ALL_CPP.add(Keywords.NULLPTR);
@ -440,6 +442,7 @@ public class KeywordSets {
ALL_CPP.add(Keywords.SWITCH);
ALL_CPP.add(Keywords.TEMPLATE);
ALL_CPP.add(Keywords.THIS);
ALL_CPP.add(Keywords.THREAD_LOCAL);
ALL_CPP.add(Keywords.THROW);
ALL_CPP.add(Keywords.TRUE);
ALL_CPP.add(Keywords.TRY);
@ -480,6 +483,7 @@ public class KeywordSets {
KEYWORDS_CPP.add(Keywords.CLASS);
KEYWORDS_CPP.add(Keywords.COMPL);
KEYWORDS_CPP.add(Keywords.CONST);
KEYWORDS_CPP.add(Keywords.CONSTEXPR);
KEYWORDS_CPP.add(Keywords.CONST_CAST);
KEYWORDS_CPP.add(Keywords.CONTINUE);
KEYWORDS_CPP.add(Keywords.DECLTYPE);
@ -501,6 +505,7 @@ public class KeywordSets {
KEYWORDS_CPP.add(Keywords.MUTABLE);
KEYWORDS_CPP.add(Keywords.NAMESPACE);
KEYWORDS_CPP.add(Keywords.NEW);
KEYWORDS_CPP.add(Keywords.NOEXCEPT);
KEYWORDS_CPP.add(Keywords.NOT);
KEYWORDS_CPP.add(Keywords.NOT_EQ);
KEYWORDS_CPP.add(Keywords.NULLPTR);
@ -522,6 +527,7 @@ public class KeywordSets {
KEYWORDS_CPP.add(Keywords.SWITCH);
KEYWORDS_CPP.add(Keywords.TEMPLATE);
KEYWORDS_CPP.add(Keywords.THIS);
KEYWORDS_CPP.add(Keywords.THREAD_LOCAL);
KEYWORDS_CPP.add(Keywords.THROW);
KEYWORDS_CPP.add(Keywords.TRUE);
KEYWORDS_CPP.add(Keywords.TRY);

View file

@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2008, 2010 Institute for Software, HSR Hochschule fuer Technik
* Copyright (c) 2008, 2012 Institute for Software, HSR Hochschule fuer Technik
* Rapperswil, University of applied sciences and others
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
@ -16,7 +16,6 @@ import java.util.Arrays;
import java.util.List;
import java.util.Map;
import org.eclipse.core.runtime.Assert;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.cdt.core.dom.ast.IASTASMDeclaration;
@ -106,8 +105,7 @@ public class TrailNodeEqualityChecker implements EqualityChecker<IASTNode> {
} else if (node instanceof IASTName) {
return isNameEqual(trailNode, node);
} else {
Assert.isLegal(false, "Unexpected node type " + node.getClass().getSimpleName() + //$NON-NLS-1$
", this code shoud not be reached"); //$NON-NLS-1$
CUIPlugin.logError("Unexpected node type " + node.getClass().getSimpleName()); //$NON-NLS-1$
return true;
}
}
@ -140,10 +138,11 @@ public class TrailNodeEqualityChecker implements EqualityChecker<IASTNode> {
ICPPASTNamedTypeSpecifier decl = (ICPPASTNamedTypeSpecifier) node;
return isDeclSpecifierEqual(trailDecl, decl)
&& isSameNamedTypeSpecifierName(trailDecl, decl)
&& trailDecl.isTypename() == decl.isTypename()
&& trailDecl.isExplicit() == decl.isExplicit()
&& trailDecl.isFriend() == decl.isFriend()
&& trailDecl.isVirtual() == decl.isVirtual();
&& trailDecl.isTypename() == decl.isTypename()
&& trailDecl.isConstexpr() == decl.isConstexpr()
&& trailDecl.isExplicit() == decl.isExplicit()
&& trailDecl.isFriend() == decl.isFriend()
&& trailDecl.isVirtual() == decl.isVirtual();
} else if (trailNode instanceof IASTNamedTypeSpecifier) {
IASTNamedTypeSpecifier trailDecl = (IASTNamedTypeSpecifier) trailNode;
IASTNamedTypeSpecifier decl = (IASTNamedTypeSpecifier) node;
@ -163,9 +162,10 @@ public class TrailNodeEqualityChecker implements EqualityChecker<IASTNode> {
ICPPASTDeclSpecifier trailDecl = (ICPPASTDeclSpecifier) trailNode;
ICPPASTDeclSpecifier decl = (ICPPASTDeclSpecifier) node;
return isDeclSpecifierEqual(trailDecl, decl)
&& trailDecl.isExplicit() == decl.isExplicit()
&& trailDecl.isFriend() == decl.isFriend()
&& trailDecl.isVirtual() == decl.isVirtual();
&& trailDecl.isConstexpr() == decl.isConstexpr()
&& trailDecl.isExplicit() == decl.isExplicit()
&& trailDecl.isFriend() == decl.isFriend()
&& trailDecl.isVirtual() == decl.isVirtual();
} else if (trailNode instanceof ICASTDeclSpecifier) {
ICASTDeclSpecifier trailDecl = (ICASTDeclSpecifier) trailNode;
ICASTDeclSpecifier decl = (ICASTDeclSpecifier) node;
@ -176,7 +176,7 @@ public class TrailNodeEqualityChecker implements EqualityChecker<IASTNode> {
IASTDeclSpecifier decl = (IASTDeclSpecifier) node;
return isDeclSpecifierEqual(trailDecl, decl);
} else {
//is same
// The same.
return true;
}
}
@ -315,7 +315,8 @@ public class TrailNodeEqualityChecker implements EqualityChecker<IASTNode> {
if (trailDeclSpeci instanceof ICPPASTDeclSpecifier) {
ICPPASTDeclSpecifier trailCppDecl= (ICPPASTDeclSpecifier) trailDeclSpeci;
ICPPASTDeclSpecifier cppDecl= (ICPPASTDeclSpecifier) declSpeci;
if (trailCppDecl.isExplicit() != cppDecl.isExplicit()
if (trailCppDecl.isConstexpr() != cppDecl.isConstexpr()
|| trailCppDecl.isExplicit() != cppDecl.isExplicit()
|| trailCppDecl.isFriend() != cppDecl.isFriend()
|| trailCppDecl.isVirtual() != cppDecl.isVirtual()) {
return false;

View file

@ -30,12 +30,8 @@ public class XlcCPPASTVectorTypeSpecifier extends CPPASTSimpleDeclSpecifier impl
@Override
public XlcCPPASTVectorTypeSpecifier copy(CopyStyle style) {
XlcCPPASTVectorTypeSpecifier copy = new XlcCPPASTVectorTypeSpecifier();
copySimpleDeclSpec(copy, style);
copy.isPixel = isPixel;
if(style == CopyStyle.withLocations) {
copy.setCopyLocation(this);
}
return copy;
return copy(copy, style);
}
public boolean isPixel() {