mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-22 06:02:11 +02:00
Bug 315435 Fix the regression test failures in cdt70
This commit is contained in:
parent
c2d90006b5
commit
0890f7c49e
25 changed files with 274 additions and 68 deletions
|
@ -1,5 +1,5 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2006, 2009 IBM Corporation and others.
|
||||
* Copyright (c) 2006, 2010 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
|
||||
|
@ -24,7 +24,7 @@ import org.eclipse.cdt.core.dom.ast.IASTExpressionList;
|
|||
import org.eclipse.cdt.core.dom.ast.IASTExpressionStatement;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTFunctionCallExpression;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTFunctionDefinition;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTInitializerExpression;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTEqualsInitializer;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTLiteralExpression;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTPreprocessorMacroDefinition;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTPreprocessorStatement;
|
||||
|
@ -172,14 +172,14 @@ public class LRDigraphTrigraphTests extends TestCase {
|
|||
IASTSimpleDeclaration decl1 = (IASTSimpleDeclaration)((IASTDeclarationStatement)statements[0]).getDeclaration();
|
||||
IASTDeclarator declarator1 = decl1.getDeclarators()[0];
|
||||
assertEquals("xy", declarator1.getName().toString());
|
||||
IASTLiteralExpression expr1 = (IASTLiteralExpression)((IASTInitializerExpression)declarator1.getInitializer()).getExpression();
|
||||
IASTLiteralExpression expr1 = (IASTLiteralExpression)((IASTEqualsInitializer)declarator1.getInitializer()).getInitializerClause();
|
||||
assertEquals(IASTLiteralExpression.lk_string_literal, expr1.getKind());
|
||||
assertEquals("\"its all good\"", expr1.toString());
|
||||
|
||||
IASTSimpleDeclaration decl2 = (IASTSimpleDeclaration)((IASTDeclarationStatement)statements[1]).getDeclaration();
|
||||
IASTDeclarator declarator2 = decl2.getDeclarators()[0];
|
||||
assertEquals("ab", declarator2.getName().toString());
|
||||
IASTLiteralExpression expr2 = (IASTLiteralExpression)((IASTInitializerExpression)declarator2.getInitializer()).getExpression();
|
||||
IASTLiteralExpression expr2 = (IASTLiteralExpression)((IASTEqualsInitializer)declarator2.getInitializer()).getInitializerClause();
|
||||
assertEquals(IASTLiteralExpression.lk_string_literal, expr2.getKind());
|
||||
assertEquals("\"its still good\"", expr2.toString());
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2006, 2009 IBM Corporation and others.
|
||||
* Copyright (c) 2006, 2010 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
|
||||
|
@ -24,9 +24,12 @@ import org.eclipse.cdt.core.dom.ast.IBinding;
|
|||
import org.eclipse.cdt.core.dom.ast.IProblemBinding;
|
||||
import org.eclipse.cdt.core.model.ILanguage;
|
||||
import org.eclipse.cdt.core.parser.CodeReader;
|
||||
import org.eclipse.cdt.core.parser.FileContent;
|
||||
import org.eclipse.cdt.core.parser.IScannerInfo;
|
||||
import org.eclipse.cdt.core.parser.IncludeFileContentProvider;
|
||||
import org.eclipse.cdt.core.parser.ParserUtil;
|
||||
import org.eclipse.cdt.core.parser.ScannerInfo;
|
||||
import org.eclipse.cdt.core.parser.tests.ast2.AST2BaseTest;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.c.CVisitor;
|
||||
import org.eclipse.core.runtime.CoreException;
|
||||
|
||||
|
@ -127,14 +130,15 @@ public class ParseHelper {
|
|||
|
||||
|
||||
public static IASTTranslationUnit parse(char[] code, ILanguage lang, Options options) {
|
||||
CodeReader codeReader = new CodeReader(code);
|
||||
return parse(codeReader, lang, new ScannerInfo(), null, options);
|
||||
|
||||
return parse(FileContent.create(AST2BaseTest.TEST_CODE, code), lang, new ScannerInfo(), null, options);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* TODO thats WAY too many parameters, need to use a parameter object, need to refactor the
|
||||
* DOM parser test suite so that its a lot cleaner.
|
||||
* @Deprecated
|
||||
*/
|
||||
public static IASTTranslationUnit parse(CodeReader codeReader, ILanguage language, IScannerInfo scanInfo,
|
||||
ICodeReaderFactory fileCreator, Options options) {
|
||||
|
@ -186,12 +190,66 @@ public class ParseHelper {
|
|||
return tu;
|
||||
}
|
||||
|
||||
/**
|
||||
* TODO thats WAY too many parameters, need to use a parameter object, need to refactor the
|
||||
* DOM parser test suite so that its a lot cleaner.
|
||||
*/
|
||||
public static IASTTranslationUnit parse(FileContent fileContent, ILanguage language, IScannerInfo scanInfo,
|
||||
IncludeFileContentProvider fileContentProvider, Options options) {
|
||||
testsRun++;
|
||||
|
||||
public static IASTTranslationUnit commentParse(String code, ILanguage language) {
|
||||
CodeReader codeReader = new CodeReader(code.toCharArray());
|
||||
IASTTranslationUnit tu;
|
||||
try {
|
||||
tu = language.getASTTranslationUnit(codeReader, new ScannerInfo(), null, null, ILanguage.OPTION_ADD_COMMENTS, ParserUtil.getParserLogService());
|
||||
int languageOptions = 0;
|
||||
if(options.skipTrivialInitializers)
|
||||
languageOptions |= ILanguage.OPTION_SKIP_TRIVIAL_EXPRESSIONS_IN_AGGREGATE_INITIALIZERS;
|
||||
|
||||
tu = language.getASTTranslationUnit(fileContent, scanInfo, fileContentProvider, null, languageOptions, ParserUtil.getParserLogService());
|
||||
} catch (CoreException e) {
|
||||
throw new AssertionFailedError(e.toString());
|
||||
}
|
||||
|
||||
// should parse correctly first before we look at the bindings
|
||||
if(options.checkSyntaxProblems) {
|
||||
|
||||
// this should work for C++ also, CVisitor.getProblems() and CPPVisitor.getProblems() are exactly the same code!
|
||||
if (CVisitor.getProblems(tu).length != 0) {
|
||||
throw new AssertionFailedError(" CVisitor has AST Problems " );
|
||||
}
|
||||
}
|
||||
|
||||
if(options.checkPreprocessorProblems) {
|
||||
if (tu.getPreprocessorProblems().length != 0) {
|
||||
throw new AssertionFailedError(language.getName() + " TranslationUnit has Preprocessor Problems " );
|
||||
}
|
||||
}
|
||||
|
||||
// resolve all bindings
|
||||
if (options.checkBindings) {
|
||||
NameResolver res = new NameResolver();
|
||||
tu.accept( res );
|
||||
if(res.problemBindings.size() != options.expectedProblemBindings)
|
||||
throw new AssertionFailedError("Expected " + options.expectedProblemBindings + " problem(s), encountered " + res.problemBindings.size());
|
||||
|
||||
if(options.problems != null) {
|
||||
for(int i = 0; i < options.problems.length; i++) {
|
||||
String expected = options.problems[i];
|
||||
String actual = res.problemBindings.get(i);
|
||||
if(!expected.equals(actual))
|
||||
throw new AssertionFailedError(String.format("Problem binding not equal, expected: %s, got: %s", expected, actual));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return tu;
|
||||
}
|
||||
|
||||
|
||||
public static IASTTranslationUnit commentParse(String code, ILanguage language) {
|
||||
|
||||
IASTTranslationUnit tu;
|
||||
try {
|
||||
tu = language.getASTTranslationUnit(FileContent.create(AST2BaseTest.TEST_CODE, code.toCharArray()), new ScannerInfo(), null, null, ILanguage.OPTION_ADD_COMMENTS, ParserUtil.getParserLogService());
|
||||
} catch (CoreException e) {
|
||||
throw new AssertionFailedError(e.toString());
|
||||
}
|
||||
|
@ -204,9 +262,9 @@ public class ParseHelper {
|
|||
|
||||
|
||||
public static IASTCompletionNode getCompletionNode(String code, ILanguage language, int offset) {
|
||||
CodeReader reader = new CodeReader(code.toCharArray());
|
||||
|
||||
try {
|
||||
return language.getCompletionNode(reader, new ScannerInfo(), null, null, ParserUtil.getParserLogService(), offset);
|
||||
return language.getCompletionNode(FileContent.create(AST2BaseTest.TEST_CODE, code.toCharArray()), new ScannerInfo(), null, null, ParserUtil.getParserLogService(), offset);
|
||||
} catch (CoreException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
|
|
|
@ -894,6 +894,8 @@ initializer
|
|||
::= assignment_expression
|
||||
/. $Build consumeInitializer(); $EndBuild ./
|
||||
| initializer_list
|
||||
--CDT_70_FIX_FROM_50-#4
|
||||
/. $Build consumeInitializer(); $EndBuild ./
|
||||
|
||||
|
||||
initializer_list
|
||||
|
|
|
@ -1293,7 +1293,8 @@ initializer_clause
|
|||
::= assignment_expression
|
||||
/. $Build consumeInitializer(); $EndBuild ./
|
||||
| initializer_list
|
||||
|
||||
--CDT_70_FIX_FROM_50-#4
|
||||
/. $Build consumeInitializer(); $EndBuild ./
|
||||
|
||||
initializer_list
|
||||
::= start_initializer_list '{' <openscope-ast> initializer_seq ',' '}' end_initializer_list
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2006, 2009 IBM Corporation and others.
|
||||
* Copyright (c) 2006, 2010 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
|
||||
|
@ -35,6 +35,7 @@ import org.eclipse.cdt.core.dom.ast.IASTDeclarator;
|
|||
import org.eclipse.cdt.core.dom.ast.IASTDefaultStatement;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTDoStatement;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTEnumerationSpecifier;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTEqualsInitializer;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTExpression;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTExpressionList;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTExpressionStatement;
|
||||
|
@ -44,7 +45,7 @@ import org.eclipse.cdt.core.dom.ast.IASTFunctionDeclarator;
|
|||
import org.eclipse.cdt.core.dom.ast.IASTGotoStatement;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTIdExpression;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTInitializer;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTInitializerExpression;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTInitializerClause;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTInitializerList;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTLabelStatement;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTLiteralExpression;
|
||||
|
@ -128,7 +129,7 @@ public abstract class BuildASTParserAction extends AbstractParserAction {
|
|||
|
||||
|
||||
public void initializeTranslationUnit(IScanner scanner, IBuiltinBindingsProvider builtinBindingsProvider, IIndex index) {
|
||||
tu = nodeFactory.newTranslationUnit();
|
||||
tu = nodeFactory.newTranslationUnit(scanner);
|
||||
tu.setIndex(index);
|
||||
|
||||
// add built-in names to the scope
|
||||
|
@ -1006,13 +1007,17 @@ public abstract class BuildASTParserAction extends AbstractParserAction {
|
|||
* initializer ::= assignment_expression
|
||||
*/
|
||||
public void consumeInitializer() {
|
||||
IASTExpression expr = (IASTExpression) astStack.pop();
|
||||
if(discardInitializer(expr)) {
|
||||
//CDT_70_FIX_FROM_50-#4
|
||||
IASTInitializerClause initClause = (IASTInitializerClause) astStack.pop();
|
||||
if(initClause instanceof IASTExpression){
|
||||
if(discardInitializer((IASTExpression)initClause)) {
|
||||
astStack.push(null);
|
||||
return;
|
||||
}
|
||||
|
||||
IASTInitializerExpression initializer = nodeFactory.newInitializerExpression(expr);
|
||||
}
|
||||
//CDT_70_FIX_FROM_50-#2
|
||||
//IASTInitializerExpression initializer = nodeFactory.newInitializerExpression(expr);
|
||||
IASTEqualsInitializer initializer = nodeFactory.newEqualsInitializer(initClause);
|
||||
setOffsetAndLength(initializer);
|
||||
astStack.push(initializer);
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2006, 2009 IBM Corporation and others.
|
||||
* Copyright (c) 2006, 2010 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
|
||||
|
@ -28,11 +28,14 @@ import org.eclipse.cdt.core.dom.ast.IASTDeclSpecifier;
|
|||
import org.eclipse.cdt.core.dom.ast.IASTDeclaration;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTDeclarator;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTElaboratedTypeSpecifier;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTEqualsInitializer;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTExpression;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTExpressionList;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTForStatement;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTFunctionDeclarator;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTIdExpression;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTIfStatement;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTInitializerClause;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTInitializerExpression;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTLiteralExpression;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTName;
|
||||
|
@ -48,6 +51,7 @@ import org.eclipse.cdt.core.dom.ast.IASTSwitchStatement;
|
|||
import org.eclipse.cdt.core.dom.ast.IASTTypeId;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTUnaryExpression;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTWhileStatement;
|
||||
import org.eclipse.cdt.core.dom.ast.IBasicType.Kind;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTAmbiguousTemplateArgument;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTCatchHandler;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTCompositeTypeSpecifier;
|
||||
|
@ -97,6 +101,7 @@ import org.eclipse.cdt.core.dom.lrparser.action.ParserUtil;
|
|||
import org.eclipse.cdt.core.dom.lrparser.action.ScopedStack;
|
||||
import org.eclipse.cdt.core.dom.lrparser.action.TokenMap;
|
||||
import org.eclipse.cdt.internal.core.dom.lrparser.cpp.CPPParsersym;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.ASTNode;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.IASTAmbiguityParent;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.IASTAmbiguousExpression;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.IASTAmbiguousStatement;
|
||||
|
@ -104,6 +109,7 @@ import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTAmbiguousDeclarator;
|
|||
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTAmbiguousExpression;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTAmbiguousStatement;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTAmbiguousTemplateArgument;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTConstructorInitializer;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.OverloadableOperator;
|
||||
|
||||
/**
|
||||
|
@ -296,9 +302,17 @@ public class CPPBuildASTParserAction extends BuildASTParserAction {
|
|||
public void consumeExpressionSimpleTypeConstructor() {
|
||||
IASTExpression expression = (IASTExpression) astStack.pop();
|
||||
IToken token = (IToken) astStack.pop();
|
||||
////CDT_70_FIX_FROM_50-#3
|
||||
//int type = asICPPASTSimpleTypeConstructorExpressionType(token);
|
||||
ICPPASTConstructorInitializer init=null;
|
||||
if(expression!=null){
|
||||
init = new CPPASTConstructorInitializer();
|
||||
init.setExpression(expression);
|
||||
|
||||
int type = asICPPASTSimpleTypeConstructorExpressionType(token);
|
||||
ICPPASTSimpleTypeConstructorExpression typeConstructor = nodeFactory.newSimpleTypeConstructorExpression(type, expression);
|
||||
((ASTNode)init).setOffsetAndLength(((ASTNode)expression).getOffset(),((ASTNode)expression).getLength());
|
||||
}
|
||||
ICPPASTDeclSpecifier declspec = transformIntoSimpleTypeSpecifier(token);
|
||||
ICPPASTSimpleTypeConstructorExpression typeConstructor = nodeFactory.newSimpleTypeConstructorExpression(declspec, init);
|
||||
|
||||
setOffsetAndLength(typeConstructor);
|
||||
astStack.push(typeConstructor);
|
||||
|
@ -327,6 +341,35 @@ public class CPPBuildASTParserAction extends BuildASTParserAction {
|
|||
}
|
||||
}
|
||||
|
||||
private ICPPASTDeclSpecifier transformIntoSimpleTypeSpecifier(IToken token){
|
||||
ICPPASTSimpleDeclSpecifier declspec= nodeFactory.newSimpleDeclSpecifier();
|
||||
switch(baseKind(token)) {
|
||||
case TK_char : declspec.setType(Kind.eChar); break;
|
||||
case TK_wchar_t : declspec.setType(Kind.eWChar); break;
|
||||
case TK_bool : declspec.setType(Kind.eBoolean);break;
|
||||
case TK_short : declspec.setShort(true); break;
|
||||
case TK_int : declspec.setType(Kind.eInt); break;
|
||||
case TK_long : declspec.setLong(true); break;
|
||||
case TK_signed : declspec.setSigned(true); break;
|
||||
case TK_unsigned : declspec.setUnsigned(true); break;
|
||||
case TK_float : declspec.setType(Kind.eFloat); break;
|
||||
case TK_double : declspec.setType(Kind.eDouble); break;
|
||||
case TK_void : declspec.setType(Kind.eVoid); break;
|
||||
|
||||
default:
|
||||
assert false : "type parsed wrong"; //$NON-NLS-1$
|
||||
declspec.setType(Kind.eUnspecified);
|
||||
break;
|
||||
}
|
||||
((ASTNode) declspec).setOffset(token.getStartOffset());
|
||||
int ruleLength = token.getEndOffset() - token.getStartOffset();
|
||||
((ASTNode) declspec).setLength(ruleLength < 0 ? 0 : ruleLength);
|
||||
|
||||
return declspec;
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* postfix_expression
|
||||
|
@ -362,8 +405,9 @@ public class CPPBuildASTParserAction extends BuildASTParserAction {
|
|||
IASTExpression expr = (IASTExpression) astStack.pop();
|
||||
IASTDeclarator declarator = (IASTDeclarator) astStack.pop();
|
||||
IASTDeclSpecifier declSpec = (IASTDeclSpecifier) astStack.pop();
|
||||
|
||||
IASTInitializerExpression initializer = nodeFactory.newInitializerExpression(expr);
|
||||
//CDT_70_FIX_FROM_50-#2
|
||||
//IASTInitializerExpression initializer = nodeFactory.newInitializerExpression(expr);
|
||||
IASTEqualsInitializer initializer = nodeFactory.newEqualsInitializer(expr);
|
||||
ParserUtil.setOffsetAndLength(initializer, offset(expr), length(expr));
|
||||
declarator.setInitializer(initializer);
|
||||
|
||||
|
@ -1029,7 +1073,8 @@ public class CPPBuildASTParserAction extends BuildASTParserAction {
|
|||
|
||||
case TK_signed: n.setSigned(true); return;
|
||||
case TK_unsigned: n.setUnsigned(true); return;
|
||||
case TK_long: n.setLong(true); return;
|
||||
//if it is a longlong, donot set long, CDT_70_FIX_FROM_50-#8
|
||||
case TK_long: if(!n.isLongLong()) n.setLong(true); return;
|
||||
case TK_short: n.setShort(true); return;
|
||||
}
|
||||
}
|
||||
|
@ -1474,8 +1519,16 @@ public class CPPBuildASTParserAction extends BuildASTParserAction {
|
|||
* ::= '(' expression_list ')'
|
||||
*/
|
||||
public void consumeInitializerConstructor() {
|
||||
IASTExpression expression = (IASTExpression) astStack.pop();
|
||||
ICPPASTConstructorInitializer initializer = nodeFactory.newConstructorInitializer(expression);
|
||||
//CDT_70_FIX_FROM_50-#5
|
||||
Object o = astStack.pop();
|
||||
IASTInitializerClause[] initClauseList =null;
|
||||
if(o instanceof IASTExpressionList){
|
||||
initClauseList = ((IASTExpressionList) o).getExpressions();
|
||||
}else if(o instanceof IASTInitializerClause){
|
||||
initClauseList = new IASTInitializerClause[]{(IASTInitializerClause)o};
|
||||
}
|
||||
|
||||
ICPPASTConstructorInitializer initializer = nodeFactory.newConstructorInitializer(initClauseList);
|
||||
setOffsetAndLength(initializer);
|
||||
astStack.push(initializer);
|
||||
}
|
||||
|
@ -1566,8 +1619,10 @@ public class CPPBuildASTParserAction extends BuildASTParserAction {
|
|||
List<Object> handlers = isTryBlockDeclarator ? astStack.closeScope() : Collections.emptyList();
|
||||
IASTCompoundStatement body = (IASTCompoundStatement) astStack.pop();
|
||||
List<Object> initializers = astStack.closeScope();
|
||||
IASTFunctionDeclarator declarator = (IASTFunctionDeclarator) astStack.pop();
|
||||
IASTDeclSpecifier declSpec = (IASTDeclSpecifier) astStack.pop(); // may be null
|
||||
Object o = astStack.pop();
|
||||
IASTFunctionDeclarator declarator = (IASTFunctionDeclarator) o;
|
||||
Object o2 = astStack.pop();
|
||||
IASTDeclSpecifier declSpec = (IASTDeclSpecifier) o2; // may be null
|
||||
|
||||
if(declSpec == null) { // can happen if implicit int is used
|
||||
declSpec = nodeFactory.newSimpleDeclSpecifier();
|
||||
|
@ -1620,12 +1675,15 @@ public class CPPBuildASTParserAction extends BuildASTParserAction {
|
|||
*/
|
||||
|
||||
public void consumeMemberDeclaratorWithInitializer() {
|
||||
IASTInitializerExpression initializer = (IASTInitializerExpression) astStack.pop();
|
||||
|
||||
//CDT_70_FIX_FROM_50-#2
|
||||
//IASTInitializerExpression initializer = (IASTInitializerExpression) astStack.pop();
|
||||
IASTEqualsInitializer initializer = (IASTEqualsInitializer) astStack.pop();
|
||||
IASTDeclarator declarator = (IASTDeclarator) astStack.peek();
|
||||
setOffsetAndLength(declarator);
|
||||
|
||||
if(declarator instanceof ICPPASTFunctionDeclarator) {
|
||||
IASTExpression expr = initializer.getExpression();
|
||||
IASTExpression expr = (IASTExpression)initializer.getInitializerClause();
|
||||
if(expr instanceof IASTLiteralExpression && "0".equals(expr.toString())) { //$NON-NLS-1$
|
||||
((ICPPASTFunctionDeclarator)declarator).setPureVirtual(true);
|
||||
return;
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2009 IBM Corporation and others.
|
||||
* Copyright (c) 2009, 2010 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
|
||||
|
@ -68,8 +68,9 @@ public class GPPBuildASTParserAction extends CPPBuildASTParserAction {
|
|||
|
||||
// There's an expression somewhere on the stack, find it
|
||||
IASTExpression expr = findFirstAndRemove(topScope, IASTExpression.class);
|
||||
IGPPASTSimpleDeclSpecifier declSpec = nodeFactory.newSimpleDeclSpecifierGPP();
|
||||
declSpec.setTypeofExpression(expr);
|
||||
//CDT_70_FIX_FROM_50-#7
|
||||
ICPPASTSimpleDeclSpecifier declSpec = nodeFactory.newSimpleDeclSpecifier();
|
||||
declSpec.setDeclTypeExpression(expr);
|
||||
|
||||
// now apply the rest of the specifiers
|
||||
for(Object token : topScope) {
|
||||
|
@ -102,15 +103,15 @@ public class GPPBuildASTParserAction extends CPPBuildASTParserAction {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
ICPPASTSimpleDeclSpecifier declSpec;
|
||||
//CDT_70_FIX_FROM_50-#7
|
||||
ICPPASTSimpleDeclSpecifier declSpec = nodeFactory.newSimpleDeclSpecifier();
|
||||
if(isComplex || isImaginary || numLong > 1) {
|
||||
IGPPASTSimpleDeclSpecifier gppDeclSpec = nodeFactory.newSimpleDeclSpecifierGPP();
|
||||
gppDeclSpec.setComplex(isComplex);
|
||||
gppDeclSpec.setImaginary(isImaginary);
|
||||
gppDeclSpec.setLongLong(numLong > 1);
|
||||
gppDeclSpec.setLong(numLong == 1);
|
||||
declSpec = gppDeclSpec;
|
||||
// IGPPASTSimpleDeclSpecifier gppDeclSpec = nodeFactory.newSimpleDeclSpecifierGPP();
|
||||
declSpec.setComplex(isComplex);
|
||||
declSpec.setImaginary(isImaginary);
|
||||
declSpec.setLongLong(numLong > 1);
|
||||
declSpec.setLong(numLong == 1);
|
||||
//declSpec = gppDeclSpec;
|
||||
}
|
||||
else {
|
||||
declSpec = nodeFactory.newSimpleDeclSpecifier();
|
||||
|
|
|
@ -1167,6 +1167,12 @@ public C99ExpressionParser(ITokenStream stream, Map<String,String> properties) {
|
|||
case 282: { action. consumeInitializer(); break;
|
||||
}
|
||||
|
||||
//
|
||||
// Rule 283: initializer ::= initializer_list
|
||||
//
|
||||
case 283: { action. consumeInitializer(); break;
|
||||
}
|
||||
|
||||
//
|
||||
// Rule 284: initializer_list ::= start_initializer_list { <openscope-ast> initializer_seq comma_opt } end_initializer_list
|
||||
//
|
||||
|
|
|
@ -1161,6 +1161,12 @@ public C99NoCastExpressionParser(ITokenStream stream, Map<String,String> propert
|
|||
case 281: { action. consumeInitializer(); break;
|
||||
}
|
||||
|
||||
//
|
||||
// Rule 282: initializer ::= initializer_list
|
||||
//
|
||||
case 282: { action. consumeInitializer(); break;
|
||||
}
|
||||
|
||||
//
|
||||
// Rule 283: initializer_list ::= start_initializer_list { <openscope-ast> initializer_seq comma_opt } end_initializer_list
|
||||
//
|
||||
|
|
|
@ -1144,6 +1144,12 @@ public String getName() {
|
|||
case 282: { action. consumeInitializer(); break;
|
||||
}
|
||||
|
||||
//
|
||||
// Rule 283: initializer ::= initializer_list
|
||||
//
|
||||
case 283: { action. consumeInitializer(); break;
|
||||
}
|
||||
|
||||
//
|
||||
// Rule 284: initializer_list ::= start_initializer_list { <openscope-ast> initializer_seq comma_opt } end_initializer_list
|
||||
//
|
||||
|
|
|
@ -1161,6 +1161,12 @@ public C99SizeofExpressionParser(ITokenStream stream, Map<String,String> propert
|
|||
case 281: { action. consumeInitializer(); break;
|
||||
}
|
||||
|
||||
//
|
||||
// Rule 282: initializer ::= initializer_list
|
||||
//
|
||||
case 282: { action. consumeInitializer(); break;
|
||||
}
|
||||
|
||||
//
|
||||
// Rule 283: initializer_list ::= start_initializer_list { <openscope-ast> initializer_seq comma_opt } end_initializer_list
|
||||
//
|
||||
|
|
|
@ -1564,6 +1564,12 @@ public CPPExpressionParser(ITokenStream stream, Map<String,String> properties) {
|
|||
case 382: { action. consumeInitializer(); break;
|
||||
}
|
||||
|
||||
//
|
||||
// Rule 383: initializer_clause ::= initializer_list
|
||||
//
|
||||
case 383: { action. consumeInitializer(); break;
|
||||
}
|
||||
|
||||
//
|
||||
// Rule 384: initializer_list ::= start_initializer_list { <openscope-ast> initializer_seq , } end_initializer_list
|
||||
//
|
||||
|
|
|
@ -1558,6 +1558,12 @@ public CPPNoCastExpressionParser(ITokenStream stream, Map<String,String> propert
|
|||
case 381: { action. consumeInitializer(); break;
|
||||
}
|
||||
|
||||
//
|
||||
// Rule 382: initializer_clause ::= initializer_list
|
||||
//
|
||||
case 382: { action. consumeInitializer(); break;
|
||||
}
|
||||
|
||||
//
|
||||
// Rule 383: initializer_list ::= start_initializer_list { <openscope-ast> initializer_seq , } end_initializer_list
|
||||
//
|
||||
|
|
|
@ -1558,6 +1558,12 @@ public CPPNoFunctionDeclaratorParser(ITokenStream stream, Map<String,String> pro
|
|||
case 380: { action. consumeInitializer(); break;
|
||||
}
|
||||
|
||||
//
|
||||
// Rule 381: initializer_clause ::= initializer_list
|
||||
//
|
||||
case 381: { action. consumeInitializer(); break;
|
||||
}
|
||||
|
||||
//
|
||||
// Rule 382: initializer_list ::= start_initializer_list { <openscope-ast> initializer_seq , } end_initializer_list
|
||||
//
|
||||
|
|
|
@ -1541,6 +1541,12 @@ public String getName() {
|
|||
case 382: { action. consumeInitializer(); break;
|
||||
}
|
||||
|
||||
//
|
||||
// Rule 383: initializer_clause ::= initializer_list
|
||||
//
|
||||
case 383: { action. consumeInitializer(); break;
|
||||
}
|
||||
|
||||
//
|
||||
// Rule 384: initializer_list ::= start_initializer_list { <openscope-ast> initializer_seq , } end_initializer_list
|
||||
//
|
||||
|
|
|
@ -1552,6 +1552,12 @@ public CPPSizeofExpressionParser(ITokenStream stream, Map<String,String> propert
|
|||
case 380: { action. consumeInitializer(); break;
|
||||
}
|
||||
|
||||
//
|
||||
// Rule 381: initializer_clause ::= initializer_list
|
||||
//
|
||||
case 381: { action. consumeInitializer(); break;
|
||||
}
|
||||
|
||||
//
|
||||
// Rule 382: initializer_list ::= start_initializer_list { <openscope-ast> initializer_seq , } end_initializer_list
|
||||
//
|
||||
|
|
|
@ -1566,6 +1566,12 @@ public CPPTemplateTypeParameterParser(ITokenStream stream, Map<String,String> pr
|
|||
case 382: { action. consumeInitializer(); break;
|
||||
}
|
||||
|
||||
//
|
||||
// Rule 383: initializer_clause ::= initializer_list
|
||||
//
|
||||
case 383: { action. consumeInitializer(); break;
|
||||
}
|
||||
|
||||
//
|
||||
// Rule 384: initializer_list ::= start_initializer_list { <openscope-ast> initializer_seq , } end_initializer_list
|
||||
//
|
||||
|
|
|
@ -1155,6 +1155,12 @@ private GNUBuildASTParserAction gnuAction;
|
|||
case 282: { action. consumeInitializer(); break;
|
||||
}
|
||||
|
||||
//
|
||||
// Rule 283: initializer ::= initializer_list
|
||||
//
|
||||
case 283: { action. consumeInitializer(); break;
|
||||
}
|
||||
|
||||
//
|
||||
// Rule 284: initializer_list ::= start_initializer_list { <openscope-ast> initializer_seq comma_opt } end_initializer_list
|
||||
//
|
||||
|
|
|
@ -1172,6 +1172,12 @@ private GNUBuildASTParserAction gnuAction;
|
|||
case 281: { action. consumeInitializer(); break;
|
||||
}
|
||||
|
||||
//
|
||||
// Rule 282: initializer ::= initializer_list
|
||||
//
|
||||
case 282: { action. consumeInitializer(); break;
|
||||
}
|
||||
|
||||
//
|
||||
// Rule 283: initializer_list ::= start_initializer_list { <openscope-ast> initializer_seq comma_opt } end_initializer_list
|
||||
//
|
||||
|
|
|
@ -1547,6 +1547,12 @@ private GNUBuildASTParserAction gnuAction;
|
|||
case 381: { action. consumeInitializer(); break;
|
||||
}
|
||||
|
||||
//
|
||||
// Rule 382: initializer_clause ::= initializer_list
|
||||
//
|
||||
case 382: { action. consumeInitializer(); break;
|
||||
}
|
||||
|
||||
//
|
||||
// Rule 383: initializer_list ::= start_initializer_list { <openscope-ast> initializer_seq , } end_initializer_list
|
||||
//
|
||||
|
|
|
@ -1558,6 +1558,12 @@ private GNUBuildASTParserAction gnuAction;
|
|||
case 379: { action. consumeInitializer(); break;
|
||||
}
|
||||
|
||||
//
|
||||
// Rule 380: initializer_clause ::= initializer_list
|
||||
//
|
||||
case 380: { action. consumeInitializer(); break;
|
||||
}
|
||||
|
||||
//
|
||||
// Rule 381: initializer_list ::= start_initializer_list { <openscope-ast> initializer_seq , } end_initializer_list
|
||||
//
|
||||
|
|
|
@ -275,28 +275,6 @@ public class XlcExtensionsTest extends XlcTestBase {
|
|||
parse(code, getCPPLanguage(), true); // xlc supports this in C++
|
||||
}
|
||||
|
||||
public void testStaticAssertions() {
|
||||
String code =
|
||||
" const unsigned int EIGHT= 8; \n"+
|
||||
" __static_assert(sizeof(long) >= EIGHT, \"no 64-bit support\"); \n" +
|
||||
|
||||
" namespace ns { \n"+
|
||||
" __static_assert(sizeof(long) >= 4, \"no 32-bit support\"); \n" +
|
||||
" } \n" +
|
||||
|
||||
" template <typename T> class basic_string { \n" +
|
||||
" __static_assert(T::value, \"bla\"); \n" +
|
||||
" }; \n" +
|
||||
|
||||
" void do_something() { \n" +
|
||||
" struct VMPage { \n" +
|
||||
" }; \n" +
|
||||
" __static_assert(sizeof(VMPage) == 1, \"bla\"); \n" +
|
||||
" }";
|
||||
|
||||
parse(code, getCPPLanguage(), true); // xlc supports this in C++
|
||||
}
|
||||
|
||||
public void testV11Attributes() {
|
||||
String code =
|
||||
"#define __inline__ __inline__ __attribute__((gnu_inline)) \n" +
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2009 IBM Corporation and others.
|
||||
* Copyright (c) 2009, 2010 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
|
||||
|
@ -16,11 +16,18 @@ import org.eclipse.cdt.core.lrparser.tests.LRCPPTests;
|
|||
import org.eclipse.cdt.core.lrparser.xlc.XlcCLanguage;
|
||||
import org.eclipse.cdt.core.lrparser.xlc.XlcCPPLanguage;
|
||||
import org.eclipse.cdt.core.model.ILanguage;
|
||||
import org.eclipse.cdt.core.parser.ParserLanguage;
|
||||
|
||||
public class XlcLRCPPTests extends LRCPPTests {
|
||||
public static TestSuite suite() {
|
||||
return suite(XlcLRCPPTests.class);
|
||||
}
|
||||
//CDT_70_FIX_FROM_50-#9
|
||||
public void testStaticAssertions_294730() throws Exception {
|
||||
String code= getAboveComment();
|
||||
code = code.replaceAll("static_assert", "__static_assert");
|
||||
parseAndCheckBindings(code, ParserLanguage.CPP);
|
||||
}
|
||||
|
||||
protected ILanguage getCLanguage() {
|
||||
return XlcCLanguage.getDefault();
|
||||
|
|
|
@ -1159,6 +1159,12 @@ private GNUBuildASTParserAction gnuAction;
|
|||
case 282: { action. consumeInitializer(); break;
|
||||
}
|
||||
|
||||
//
|
||||
// Rule 283: initializer ::= initializer_list
|
||||
//
|
||||
case 283: { action. consumeInitializer(); break;
|
||||
}
|
||||
|
||||
//
|
||||
// Rule 284: initializer_list ::= start_initializer_list { <openscope-ast> initializer_seq comma_opt } end_initializer_list
|
||||
//
|
||||
|
|
|
@ -1551,6 +1551,12 @@ private GNUBuildASTParserAction gnuAction;
|
|||
case 381: { action. consumeInitializer(); break;
|
||||
}
|
||||
|
||||
//
|
||||
// Rule 382: initializer_clause ::= initializer_list
|
||||
//
|
||||
case 382: { action. consumeInitializer(); break;
|
||||
}
|
||||
|
||||
//
|
||||
// Rule 383: initializer_list ::= start_initializer_list { <openscope-ast> initializer_seq , } end_initializer_list
|
||||
//
|
||||
|
|
Loading…
Add table
Reference in a new issue