mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-29 19:45:01 +02:00
Fixed compiler warnings.
This commit is contained in:
parent
813cfa454b
commit
c667cb6ab9
7 changed files with 1990 additions and 2241 deletions
|
@ -73,31 +73,20 @@ public class AST2SelectionParseBaseTest extends FileBasePluginTest {
|
||||||
return tu.getNodeSelector(null).findNode(offset, length);
|
return tu.getNodeSelector(null).findNode(offset, length);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @param string
|
|
||||||
* @param c
|
|
||||||
* @return
|
|
||||||
* @throws ParserException
|
|
||||||
*/
|
|
||||||
protected IASTTranslationUnit parse(String code, ParserLanguage lang, boolean useGNUExtensions, boolean expectNoProblems) throws ParserException {
|
protected IASTTranslationUnit parse(String code, ParserLanguage lang, boolean useGNUExtensions, boolean expectNoProblems) throws ParserException {
|
||||||
FileContent codeReader = FileContent.create("<test-code>", code.toCharArray());
|
FileContent codeReader = FileContent.create("<test-code>", code.toCharArray());
|
||||||
ScannerInfo scannerInfo = new ScannerInfo();
|
ScannerInfo scannerInfo = new ScannerInfo();
|
||||||
IScanner scanner= AST2BaseTest.createScanner(codeReader, lang, ParserMode.COMPLETE_PARSE, scannerInfo);
|
IScanner scanner= AST2BaseTest.createScanner(codeReader, lang, ParserMode.COMPLETE_PARSE, scannerInfo);
|
||||||
|
|
||||||
ISourceCodeParser parser2 = null;
|
ISourceCodeParser parser2 = null;
|
||||||
if( lang == ParserLanguage.CPP )
|
if (lang == ParserLanguage.CPP) {
|
||||||
{
|
|
||||||
ICPPParserExtensionConfiguration config = null;
|
ICPPParserExtensionConfiguration config = null;
|
||||||
if (useGNUExtensions)
|
if (useGNUExtensions)
|
||||||
config = new GPPParserExtensionConfiguration();
|
config = new GPPParserExtensionConfiguration();
|
||||||
else
|
else
|
||||||
config = new ANSICPPParserExtensionConfiguration();
|
config = new ANSICPPParserExtensionConfiguration();
|
||||||
parser2 = new GNUCPPSourceParser(scanner, ParserMode.COMPLETE_PARSE,
|
parser2 = new GNUCPPSourceParser(scanner, ParserMode.COMPLETE_PARSE, NULL_LOG, config);
|
||||||
NULL_LOG,
|
} else {
|
||||||
config );
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
ICParserExtensionConfiguration config = null;
|
ICParserExtensionConfiguration config = null;
|
||||||
|
|
||||||
if (useGNUExtensions)
|
if (useGNUExtensions)
|
||||||
|
@ -105,8 +94,7 @@ public class AST2SelectionParseBaseTest extends FileBasePluginTest {
|
||||||
else
|
else
|
||||||
config = new ANSICParserExtensionConfiguration();
|
config = new ANSICParserExtensionConfiguration();
|
||||||
|
|
||||||
parser2 = new GNUCSourceParser( scanner, ParserMode.COMPLETE_PARSE,
|
parser2 = new GNUCSourceParser(scanner, ParserMode.COMPLETE_PARSE, NULL_LOG, config);
|
||||||
NULL_LOG, config );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
IASTTranslationUnit tu = parser2.parse();
|
IASTTranslationUnit tu = parser2.parse();
|
||||||
|
@ -114,25 +102,20 @@ public class AST2SelectionParseBaseTest extends FileBasePluginTest {
|
||||||
if (parser2.encounteredError() && expectNoProblems)
|
if (parser2.encounteredError() && expectNoProblems)
|
||||||
throw new ParserException("FAILURE"); //$NON-NLS-1$
|
throw new ParserException("FAILURE"); //$NON-NLS-1$
|
||||||
|
|
||||||
if( lang == ParserLanguage.C && expectNoProblems )
|
if (lang == ParserLanguage.C && expectNoProblems) {
|
||||||
{
|
|
||||||
assertEquals(CVisitor.getProblems(tu).length, 0);
|
assertEquals(CVisitor.getProblems(tu).length, 0);
|
||||||
assertEquals(tu.getPreprocessorProblems().length, 0);
|
assertEquals(tu.getPreprocessorProblems().length, 0);
|
||||||
}
|
} else if (lang == ParserLanguage.CPP && expectNoProblems) {
|
||||||
else if ( lang == ParserLanguage.CPP && expectNoProblems )
|
|
||||||
{
|
|
||||||
assertEquals(CPPVisitor.getProblems(tu).length, 0);
|
assertEquals(CPPVisitor.getProblems(tu).length, 0);
|
||||||
assertEquals(tu.getPreprocessorProblems().length, 0);
|
assertEquals(tu.getPreprocessorProblems().length, 0);
|
||||||
}
|
}
|
||||||
if (expectNoProblems)
|
if (expectNoProblems)
|
||||||
assertEquals(0, tu.getPreprocessorProblems().length);
|
assertEquals(0, tu.getPreprocessorProblems().length);
|
||||||
|
|
||||||
|
|
||||||
return tu;
|
return tu;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected IASTTranslationUnit parse(IFile file, ParserLanguage lang, boolean useGNUExtensions, boolean expectNoProblems) throws ParserException {
|
protected IASTTranslationUnit parse(IFile file, ParserLanguage lang, boolean useGNUExtensions, boolean expectNoProblems) throws ParserException {
|
||||||
|
|
||||||
IASTTranslationUnit tu= null;
|
IASTTranslationUnit tu= null;
|
||||||
try {
|
try {
|
||||||
tu = CDOM.getInstance().getASTService().getTranslationUnit(file);
|
tu = CDOM.getInstance().getASTService().getTranslationUnit(file);
|
||||||
|
@ -140,21 +123,16 @@ public class AST2SelectionParseBaseTest extends FileBasePluginTest {
|
||||||
assertFalse(true); // shouldn't happen
|
assertFalse(true); // shouldn't happen
|
||||||
}
|
}
|
||||||
|
|
||||||
if( lang == ParserLanguage.C && expectNoProblems )
|
if (lang == ParserLanguage.C && expectNoProblems) {
|
||||||
{
|
|
||||||
assertEquals(CVisitor.getProblems(tu).length, 0);
|
assertEquals(CVisitor.getProblems(tu).length, 0);
|
||||||
assertEquals(tu.getPreprocessorProblems().length, 0);
|
assertEquals(tu.getPreprocessorProblems().length, 0);
|
||||||
}
|
} else if (lang == ParserLanguage.CPP && expectNoProblems) {
|
||||||
else if ( lang == ParserLanguage.CPP && expectNoProblems )
|
|
||||||
{
|
|
||||||
assertEquals(CPPVisitor.getProblems(tu).length, 0);
|
assertEquals(CPPVisitor.getProblems(tu).length, 0);
|
||||||
assertEquals(tu.getPreprocessorProblems().length, 0);
|
assertEquals(tu.getPreprocessorProblems().length, 0);
|
||||||
}
|
}
|
||||||
if (expectNoProblems)
|
if (expectNoProblems)
|
||||||
assertEquals(0, tu.getPreprocessorProblems().length);
|
assertEquals(0, tu.getPreprocessorProblems().length);
|
||||||
|
|
||||||
|
|
||||||
return tu;
|
return tu;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -6327,11 +6327,6 @@ public class AST2Tests extends AST2BaseTest {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @param declarations
|
|
||||||
* @param index
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
private IBasicType getTypeForDeclaration(IASTDeclaration[] declarations, int index) {
|
private IBasicType getTypeForDeclaration(IASTDeclaration[] declarations, int index) {
|
||||||
IASTInitializer init = ((IASTSimpleDeclaration) declarations[index]).getDeclarators()[0].getInitializer();
|
IASTInitializer init = ((IASTSimpleDeclaration) declarations[index]).getDeclarators()[0].getInitializer();
|
||||||
return (IBasicType)((IASTExpression)((IASTEqualsInitializer) init).getInitializerClause()).getExpressionType();
|
return (IBasicType)((IASTExpression)((IASTEqualsInitializer) init).getInitializerClause()).getExpressionType();
|
||||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -151,15 +151,10 @@ public class DOMLocationInclusionTests extends AST2FileBasePluginTest {
|
||||||
public String getParserDialect() {
|
public String getParserDialect() {
|
||||||
return dialect;
|
return dialect;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static final String[] EMPTY_STRING_ARRAY = new String[0];
|
private static final String[] EMPTY_STRING_ARRAY = new String[0];
|
||||||
|
|
||||||
/**
|
|
||||||
* @param name
|
|
||||||
* @param className
|
|
||||||
*/
|
|
||||||
public DOMLocationInclusionTests(String name) {
|
public DOMLocationInclusionTests(String name) {
|
||||||
super(name, DOMLocationInclusionTests.class);
|
super(name, DOMLocationInclusionTests.class);
|
||||||
}
|
}
|
||||||
|
@ -178,13 +173,6 @@ public class DOMLocationInclusionTests extends AST2FileBasePluginTest {
|
||||||
new ParserConfiguration(s, code));
|
new ParserConfiguration(s, code));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @param pathEndsWith
|
|
||||||
* TODO
|
|
||||||
* @param offset
|
|
||||||
* @param length
|
|
||||||
* @param declarator
|
|
||||||
*/
|
|
||||||
protected void assertSoleFileLocation(IASTNode n, String pathEndsWith, int offset, int length) {
|
protected void assertSoleFileLocation(IASTNode n, String pathEndsWith, int offset, int length) {
|
||||||
IASTNodeLocation[] locations = n.getNodeLocations();
|
IASTNodeLocation[] locations = n.getNodeLocations();
|
||||||
assertEquals(locations.length, 1);
|
assertEquals(locations.length, 1);
|
||||||
|
|
|
@ -178,11 +178,6 @@ public class DOMLocationTests extends AST2BaseTest {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @param declarator
|
|
||||||
* @param offset
|
|
||||||
* @param length
|
|
||||||
*/
|
|
||||||
private void assertSoleLocation(IASTNode n, int offset, int length) {
|
private void assertSoleLocation(IASTNode n, int offset, int length) {
|
||||||
assertEquals(length, ((ASTNode)n).getLength());
|
assertEquals(length, ((ASTNode)n).getLength());
|
||||||
IASTNodeLocation[] locations = n.getNodeLocations();
|
IASTNodeLocation[] locations = n.getNodeLocations();
|
||||||
|
|
|
@ -48,11 +48,9 @@ public class DOMSearchUtil {
|
||||||
public static final int DECLARATIONS_DEFINITIONS = 3;
|
public static final int DECLARATIONS_DEFINITIONS = 3;
|
||||||
public static final int REFERENCES = 4;
|
public static final int REFERENCES = 4;
|
||||||
public static final int ALL_OCCURRENCES = 5;
|
public static final int ALL_OCCURRENCES = 5;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This retrieves the ParserLanguage from an IFile.
|
* Retrieves the ParserLanguage from an file.
|
||||||
*
|
|
||||||
* @param file
|
|
||||||
* @return
|
|
||||||
*/
|
*/
|
||||||
public static ParserLanguage getLanguageFromFile(IFile file) {
|
public static ParserLanguage getLanguageFromFile(IFile file) {
|
||||||
IProject project = file.getProject();
|
IProject project = file.getProject();
|
||||||
|
@ -115,13 +113,8 @@ public class DOMSearchUtil {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the ParserLanguage corresponding to the IPath and IProject. Returns ParserLanguage.CPP if the file type is a header.
|
* Returns the ParserLanguage corresponding to the IPath and IProject. Returns ParserLanguage.CPP if the file type is a header.
|
||||||
*
|
|
||||||
* @param path
|
|
||||||
* @param project
|
|
||||||
* @return
|
|
||||||
*/
|
*/
|
||||||
public static ParserLanguage getLanguage( IPath path, IProject project )
|
public static ParserLanguage getLanguage(IPath path, IProject project) {
|
||||||
{
|
|
||||||
//FIXME: ALAIN, for headers should we assume CPP ??
|
//FIXME: ALAIN, for headers should we assume CPP ??
|
||||||
// The problem is that it really depends on how the header was included.
|
// The problem is that it really depends on how the header was included.
|
||||||
String id = null;
|
String id = null;
|
||||||
|
@ -149,7 +142,7 @@ public class DOMSearchUtil {
|
||||||
/**
|
/**
|
||||||
* This is used to get the names from the TU that the IASTName searchName belongs to.
|
* This is used to get the names from the TU that the IASTName searchName belongs to.
|
||||||
*
|
*
|
||||||
* @param searchName the IASTName whose references/delcarations are to be retrieved
|
* @param searchName the IASTName whose references/declarations are to be retrieved
|
||||||
* @param limitTo used to specify whether to get declarations, references, or both, one of:
|
* @param limitTo used to specify whether to get declarations, references, or both, one of:
|
||||||
* (CSearchPattern.DECLARATION | CSearchPattern.REFERENCES | CSearchPattern.ALL_OCCURRENCES)
|
* (CSearchPattern.DECLARATION | CSearchPattern.REFERENCES | CSearchPattern.ALL_OCCURRENCES)
|
||||||
* @return IASTName[] declarations, references, or both depending on limitTo that correspond to the IASTName searchName searched for
|
* @return IASTName[] declarations, references, or both depending on limitTo that correspond to the IASTName searchName searched for
|
||||||
|
@ -189,7 +182,8 @@ public class DOMSearchUtil {
|
||||||
binding = ((ICPPClassScope)binding.getScope()).getClassType();
|
binding = ((ICPPClassScope)binding.getScope()).getClassType();
|
||||||
names = getNames(tu, binding, limitTo);
|
names = getNames(tu, binding, limitTo);
|
||||||
}
|
}
|
||||||
} catch (DOMException e) {}
|
} catch (DOMException e) {
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -215,5 +209,4 @@ public class DOMSearchUtil {
|
||||||
|
|
||||||
return names;
|
return names;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -44,24 +44,16 @@ import org.eclipse.cdt.internal.core.parser.ParserException;
|
||||||
* @author jcamelon
|
* @author jcamelon
|
||||||
*/
|
*/
|
||||||
public class QuickParser2Tests extends TestCase {
|
public class QuickParser2Tests extends TestCase {
|
||||||
|
|
||||||
private static final NullLogService NULL_LOG = new NullLogService();
|
private static final NullLogService NULL_LOG = new NullLogService();
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
public QuickParser2Tests() {
|
public QuickParser2Tests() {
|
||||||
super();
|
super();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @param name
|
|
||||||
*/
|
|
||||||
public QuickParser2Tests(String name) {
|
public QuickParser2Tests(String name) {
|
||||||
super(name);
|
super(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void setUp() throws Exception {
|
protected void setUp() throws Exception {
|
||||||
CPPASTNameBase.sAllowRecursionBindings= false;
|
CPPASTNameBase.sAllowRecursionBindings= false;
|
||||||
|
@ -69,7 +61,7 @@ public class QuickParser2Tests extends TestCase {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test code: int x = 5; Purpose: to test the simple decaration in it's
|
* Test code: int x = 5; Purpose: to test the simple declaration in it's
|
||||||
* simplest form.
|
* simplest form.
|
||||||
*/
|
*/
|
||||||
public void testIntGlobal() throws Exception {
|
public void testIntGlobal() throws Exception {
|
||||||
|
@ -160,8 +152,7 @@ public class QuickParser2Tests extends TestCase {
|
||||||
public void testSimpleClassMembers() throws Exception {
|
public void testSimpleClassMembers() throws Exception {
|
||||||
// Parse and get the translaton unit
|
// Parse and get the translaton unit
|
||||||
Writer code = new StringWriter();
|
Writer code = new StringWriter();
|
||||||
code
|
code.write("class A : public B, private C, virtual protected D { public: int x, y; float a,b,c; };");
|
||||||
.write("class A : public B, private C, virtual protected D { public: int x, y; float a,b,c; };");
|
|
||||||
parse(code.toString());
|
parse(code.toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -529,7 +520,6 @@ public class QuickParser2Tests extends TestCase {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testBug36769A() throws Exception {
|
public void testBug36769A() throws Exception {
|
||||||
|
|
||||||
parse("template <class A, B> cls<A, C>::operator otherType() const {}\n");
|
parse("template <class A, B> cls<A, C>::operator otherType() const {}\n");
|
||||||
parse("template <class A, B> cls<A, C>::cls() {}\n");
|
parse("template <class A, B> cls<A, C>::cls() {}\n");
|
||||||
parse("template <class A, B> cls<A, C>::~cls() {}\n");
|
parse("template <class A, B> cls<A, C>::~cls() {}\n");
|
||||||
|
@ -539,7 +529,6 @@ public class QuickParser2Tests extends TestCase {
|
||||||
Writer code = new StringWriter();
|
Writer code = new StringWriter();
|
||||||
code.write("unsigned long a = 0UL;\n");
|
code.write("unsigned long a = 0UL;\n");
|
||||||
code.write("unsigned long a2 = 0L; \n");
|
code.write("unsigned long a2 = 0L; \n");
|
||||||
|
|
||||||
parse(code.toString());
|
parse(code.toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -590,8 +579,7 @@ public class QuickParser2Tests extends TestCase {
|
||||||
Writer code = new StringWriter();
|
Writer code = new StringWriter();
|
||||||
code.write("void mad_decoder_init(struct mad_decoder *, void *,\n");
|
code.write("void mad_decoder_init(struct mad_decoder *, void *,\n");
|
||||||
code.write(" enum mad_flow (*)(void *, struct mad_stream *),\n");
|
code.write(" enum mad_flow (*)(void *, struct mad_stream *),\n");
|
||||||
code
|
code.write(" enum mad_flow (*)(void *, struct mad_header const *),\n");
|
||||||
.write(" enum mad_flow (*)(void *, struct mad_header const *),\n");
|
|
||||||
code.write(" enum mad_flow (*)(void *,\n");
|
code.write(" enum mad_flow (*)(void *,\n");
|
||||||
code.write(" struct mad_stream const *,\n");
|
code.write(" struct mad_stream const *,\n");
|
||||||
code.write(" struct mad_frame *),\n");
|
code.write(" struct mad_frame *),\n");
|
||||||
|
@ -605,15 +593,12 @@ public class QuickParser2Tests extends TestCase {
|
||||||
code.write(");\n");
|
code.write(");\n");
|
||||||
|
|
||||||
parse(code.toString());
|
parse(code.toString());
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testBug36852() throws Exception {
|
public void testBug36852() throws Exception {
|
||||||
Writer code = new StringWriter();
|
Writer code = new StringWriter();
|
||||||
code
|
code.write("int CBT::senseToAllRect(double id_standardQuot = DOSE, double id_minToleranz =15.0,\n");
|
||||||
.write("int CBT::senseToAllRect( double id_standardQuot = DOSE, double id_minToleranz =15.0,\n");
|
code.write("double id_maxToleranz = 15.0, unsigned int iui_minY = 0, \n");
|
||||||
code
|
|
||||||
.write("double id_maxToleranz = 15.0, unsigned int iui_minY = 0, \n");
|
|
||||||
code.write("unsigned int iui_maxY = HEIGHT);\n");
|
code.write("unsigned int iui_maxY = HEIGHT);\n");
|
||||||
parse(code.toString());
|
parse(code.toString());
|
||||||
}
|
}
|
||||||
|
@ -623,14 +608,12 @@ public class QuickParser2Tests extends TestCase {
|
||||||
code.write("template\n");
|
code.write("template\n");
|
||||||
code.write("<\n");
|
code.write("<\n");
|
||||||
code.write("class AbstractFact,\n");
|
code.write("class AbstractFact,\n");
|
||||||
code
|
code.write("template <class, class> class Creator = OpNewFactoryUnit,\n");
|
||||||
.write("template <class, class> class Creator = OpNewFactoryUnit,\n");
|
|
||||||
code.write("class TList = typename AbstractFact::ProductList\n");
|
code.write("class TList = typename AbstractFact::ProductList\n");
|
||||||
code.write(">\n");
|
code.write(">\n");
|
||||||
code.write("class ConcreteFactory\n");
|
code.write("class ConcreteFactory\n");
|
||||||
code.write(": public GenLinearHierarchy<\n");
|
code.write(": public GenLinearHierarchy<\n");
|
||||||
code
|
code.write("typename TL::Reverse<TList>::Result, Creator, AbstractFact>\n");
|
||||||
.write("typename TL::Reverse<TList>::Result, Creator, AbstractFact>\n");
|
|
||||||
code.write("{\n");
|
code.write("{\n");
|
||||||
code.write("public:\n");
|
code.write("public:\n");
|
||||||
code.write("typedef typename AbstractFact::ProductList ProductList;\n");
|
code.write("typedef typename AbstractFact::ProductList ProductList;\n");
|
||||||
|
@ -691,7 +674,7 @@ public class QuickParser2Tests extends TestCase {
|
||||||
* Test code: "class A { int floor(double input), someInt; };"
|
* Test code: "class A { int floor(double input), someInt; };"
|
||||||
*/
|
*/
|
||||||
public void testMultipleDeclarators() throws Exception {
|
public void testMultipleDeclarators() throws Exception {
|
||||||
// Parse and get the translaton unit
|
// Parse and get the translation unit
|
||||||
parse("class A { int floor(double input), someInt; };");
|
parse("class A { int floor(double input), someInt; };");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -868,8 +851,7 @@ public class QuickParser2Tests extends TestCase {
|
||||||
public void testBug36692() throws Exception {
|
public void testBug36692() throws Exception {
|
||||||
Writer code = new StringWriter();
|
Writer code = new StringWriter();
|
||||||
code.write("template <typename T, typename Destroyer>\n");
|
code.write("template <typename T, typename Destroyer>\n");
|
||||||
code
|
code.write("void SetLongevity(T* pDynObject, unsigned int longevity,\n");
|
||||||
.write("void SetLongevity(T* pDynObject, unsigned int longevity,\n");
|
|
||||||
code.write("Destroyer d = Private::Deleter<T>::Delete){}\n");
|
code.write("Destroyer d = Private::Deleter<T>::Delete){}\n");
|
||||||
parse(code.toString());
|
parse(code.toString());
|
||||||
}
|
}
|
||||||
|
@ -1039,9 +1021,7 @@ public class QuickParser2Tests extends TestCase {
|
||||||
code.write("#ifndef glue\n");
|
code.write("#ifndef glue\n");
|
||||||
code.write("#error glue not defined!\n");
|
code.write("#error glue not defined!\n");
|
||||||
code.write("#endif\n");
|
code.write("#endif\n");
|
||||||
|
|
||||||
code.write("%:define str(x) %:x /* #define str(x) #x */\n");
|
code.write("%:define str(x) %:x /* #define str(x) #x */\n");
|
||||||
|
|
||||||
code.write("int main (int argc, char *argv<::>) /* argv[] */\n");
|
code.write("int main (int argc, char *argv<::>) /* argv[] */\n");
|
||||||
code.write("glue (<, %) /* { */\n");
|
code.write("glue (<, %) /* { */\n");
|
||||||
code.write(" /* di_str[] = */\n");
|
code.write(" /* di_str[] = */\n");
|
||||||
|
@ -1063,17 +1043,14 @@ public class QuickParser2Tests extends TestCase {
|
||||||
code.write("??=include <stdio.h>\n");
|
code.write("??=include <stdio.h>\n");
|
||||||
code.write("??=define TWELVE 1??/\n");
|
code.write("??=define TWELVE 1??/\n");
|
||||||
code.write("2\n");
|
code.write("2\n");
|
||||||
|
|
||||||
code.write("static const char str??(??) = \"0123456789??/n\";\n");
|
code.write("static const char str??(??) = \"0123456789??/n\";\n");
|
||||||
|
|
||||||
code.write("int\n");
|
code.write("int\n");
|
||||||
code.write("main(void)\n");
|
code.write("main(void)\n");
|
||||||
code.write("??<\n");
|
code.write("??<\n");
|
||||||
code.write(" unsigned char x = 5;\n");
|
code.write(" unsigned char x = 5;\n");
|
||||||
code.write(" if (sizeof str != TWELVE)\n");
|
code.write(" if (sizeof str != TWELVE)\n");
|
||||||
code.write(" abort ();\n");
|
code.write(" abort ();\n");
|
||||||
code
|
code.write(" /* Test ^=, the only multi-character token to come from trigraphs. */\n");
|
||||||
.write(" /* Test ^=, the only multi-character token to come from trigraphs. */\n");
|
|
||||||
code.write(" x ??'= 3;\n");
|
code.write(" x ??'= 3;\n");
|
||||||
code.write(" if (x != 6)\n");
|
code.write(" if (x != 6)\n");
|
||||||
code.write(" abort ();\n");
|
code.write(" abort ();\n");
|
||||||
|
@ -1143,7 +1120,7 @@ public class QuickParser2Tests extends TestCase {
|
||||||
code.write("template <class T, class U> struct SuperSubclass {\n");
|
code.write("template <class T, class U> struct SuperSubclass {\n");
|
||||||
code.write("enum { value = (::Loki::Conversion<const volatile U*, const volatile T*>::exists && \n");
|
code.write("enum { value = (::Loki::Conversion<const volatile U*, const volatile T*>::exists && \n");
|
||||||
code.write("!::Loki::Conversion<const volatile T*, const volatile void*>::sameType) }; };");
|
code.write("!::Loki::Conversion<const volatile T*, const volatile void*>::sameType) }; };");
|
||||||
} catch (IOException ioe) {
|
} catch (IOException e) {
|
||||||
}
|
}
|
||||||
parse(code.toString());
|
parse(code.toString());
|
||||||
}
|
}
|
||||||
|
@ -1210,7 +1187,7 @@ public class QuickParser2Tests extends TestCase {
|
||||||
code.write(" catch (...)\n");
|
code.write(" catch (...)\n");
|
||||||
code.write(" { if (c != 3) r |= 1; }\n");
|
code.write(" { if (c != 3) r |= 1; }\n");
|
||||||
code.write("};\n");
|
code.write("};\n");
|
||||||
} catch (IOException ioe) {
|
} catch (IOException e) {
|
||||||
}
|
}
|
||||||
parse(code.toString());
|
parse(code.toString());
|
||||||
}
|
}
|
||||||
|
@ -1354,15 +1331,8 @@ public class QuickParser2Tests extends TestCase {
|
||||||
parse("struct file_operations driver_fops = { open: device_open, release: device_release };", true, ParserLanguage.C, true);
|
parse("struct file_operations driver_fops = { open: device_open, release: device_release };", true, ParserLanguage.C, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @param string
|
|
||||||
* @param b
|
|
||||||
* @param c
|
|
||||||
* @param d
|
|
||||||
*/
|
|
||||||
protected void parse(String code, boolean expectedToPass,
|
protected void parse(String code, boolean expectedToPass,
|
||||||
ParserLanguage lang, boolean gcc) throws Exception {
|
ParserLanguage lang, boolean gcc) throws Exception {
|
||||||
|
|
||||||
FileContent codeReader = FileContent.create("<test-code>", code.toCharArray());
|
FileContent codeReader = FileContent.create("<test-code>", code.toCharArray());
|
||||||
IScannerInfo scannerInfo = new ScannerInfo();
|
IScannerInfo scannerInfo = new ScannerInfo();
|
||||||
IScanner scanner= AST2BaseTest.createScanner(codeReader, lang, ParserMode.COMPLETE_PARSE, scannerInfo);
|
IScanner scanner= AST2BaseTest.createScanner(codeReader, lang, ParserMode.COMPLETE_PARSE, scannerInfo);
|
||||||
|
@ -1373,8 +1343,7 @@ public class QuickParser2Tests extends TestCase {
|
||||||
config = new GPPParserExtensionConfiguration();
|
config = new GPPParserExtensionConfiguration();
|
||||||
else
|
else
|
||||||
config = new ANSICPPParserExtensionConfiguration();
|
config = new ANSICPPParserExtensionConfiguration();
|
||||||
parser2 = new GNUCPPSourceParser(scanner, ParserMode.QUICK_PARSE,
|
parser2 = new GNUCPPSourceParser(scanner, ParserMode.QUICK_PARSE, NULL_LOG, config);
|
||||||
NULL_LOG, config);
|
|
||||||
} else {
|
} else {
|
||||||
ICParserExtensionConfiguration config = null;
|
ICParserExtensionConfiguration config = null;
|
||||||
if (gcc)
|
if (gcc)
|
||||||
|
@ -1382,21 +1351,16 @@ public class QuickParser2Tests extends TestCase {
|
||||||
else
|
else
|
||||||
config = new ANSICParserExtensionConfiguration();
|
config = new ANSICParserExtensionConfiguration();
|
||||||
|
|
||||||
parser2 = new GNUCSourceParser(scanner, ParserMode.QUICK_PARSE,
|
parser2 = new GNUCSourceParser(scanner, ParserMode.QUICK_PARSE, NULL_LOG, config);
|
||||||
NULL_LOG, config);
|
|
||||||
}
|
}
|
||||||
IASTTranslationUnit tu = parser2.parse();
|
IASTTranslationUnit tu = parser2.parse();
|
||||||
if (parser2.encounteredError() && expectedToPass)
|
if (parser2.encounteredError() && expectedToPass)
|
||||||
throw new ParserException("FAILURE");
|
throw new ParserException("FAILURE");
|
||||||
if (expectedToPass)
|
if (expectedToPass) {
|
||||||
{
|
if (lang == ParserLanguage.C) {
|
||||||
if( lang == ParserLanguage.C )
|
|
||||||
{
|
|
||||||
IASTProblem[] problems = CVisitor.getProblems(tu);
|
IASTProblem[] problems = CVisitor.getProblems(tu);
|
||||||
assertEquals(problems.length, 0);
|
assertEquals(problems.length, 0);
|
||||||
}
|
} else if (lang == ParserLanguage.CPP) {
|
||||||
else if ( lang == ParserLanguage.CPP )
|
|
||||||
{
|
|
||||||
IASTProblem[] problems = CPPVisitor.getProblems(tu);
|
IASTProblem[] problems = CPPVisitor.getProblems(tu);
|
||||||
assertEquals(problems.length, 0);
|
assertEquals(problems.length, 0);
|
||||||
}
|
}
|
||||||
|
@ -1409,8 +1373,7 @@ public class QuickParser2Tests extends TestCase {
|
||||||
|
|
||||||
public void testBug61431() throws Exception {
|
public void testBug61431() throws Exception {
|
||||||
for (int i = 0; i < 2; ++i) {
|
for (int i = 0; i < 2; ++i) {
|
||||||
ParserLanguage language = (i == 0) ? ParserLanguage.C
|
ParserLanguage language = (i == 0) ? ParserLanguage.C : ParserLanguage.CPP;
|
||||||
: ParserLanguage.CPP;
|
|
||||||
parse("int k[][] = { {0, {1}, {2,3}};", false, language);
|
parse("int k[][] = { {0, {1}, {2,3}};", false, language);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1510,8 +1473,7 @@ public class QuickParser2Tests extends TestCase {
|
||||||
Writer code = new StringWriter();
|
Writer code = new StringWriter();
|
||||||
code.write("__complex__ double x; // complex double\n");
|
code.write("__complex__ double x; // complex double\n");
|
||||||
code.write("__complex__ short int a; // complex short int\n");
|
code.write("__complex__ short int a; // complex short int\n");
|
||||||
code
|
code.write("__complex__ float y = 2.5fi; // 2.5 imaginary float literal\n");
|
||||||
.write("__complex__ float y = 2.5fi; // 2.5 imaginary float literal\n");
|
|
||||||
code.write("__complex__ int a = 3i; // imaginary intege r literal\n");
|
code.write("__complex__ int a = 3i; // imaginary intege r literal\n");
|
||||||
code.write("double v = __real__ x; // real part of expression\n");
|
code.write("double v = __real__ x; // real part of expression\n");
|
||||||
code.write("double w = __imag__ x; // imaginary part of expression\n");
|
code.write("double w = __imag__ x; // imaginary part of expression\n");
|
||||||
|
@ -1562,5 +1524,4 @@ public class QuickParser2Tests extends TestCase {
|
||||||
public void testBug39701C() throws Exception {
|
public void testBug39701C() throws Exception {
|
||||||
parse("static template class Foo<int>;", true, ParserLanguage.CPP, true);
|
parse("static template class Foo<int>;", true, ParserLanguage.CPP, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue