mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-08-12 10:45:37 +02:00
QuickParser2Tests now all pass.
Commit it while you can.
This commit is contained in:
parent
5360159a8d
commit
34181fda51
5 changed files with 200 additions and 158 deletions
|
@ -18,6 +18,7 @@ import org.eclipse.cdt.core.model.tests.CModelElementsTests;
|
||||||
import org.eclipse.cdt.core.model.tests.StructuralCModelElementsTests;
|
import org.eclipse.cdt.core.model.tests.StructuralCModelElementsTests;
|
||||||
import org.eclipse.cdt.core.parser.tests.ast2.AST2Tests;
|
import org.eclipse.cdt.core.parser.tests.ast2.AST2Tests;
|
||||||
import org.eclipse.cdt.core.parser.tests.ast2.GCCTests;
|
import org.eclipse.cdt.core.parser.tests.ast2.GCCTests;
|
||||||
|
import org.eclipse.cdt.core.parser.tests.parser2.QuickParser2Tests;
|
||||||
import org.eclipse.cdt.core.parser.tests.scanner2.ObjectMapTest;
|
import org.eclipse.cdt.core.parser.tests.scanner2.ObjectMapTest;
|
||||||
import org.eclipse.cdt.core.parser.tests.scanner2.Scanner2Test;
|
import org.eclipse.cdt.core.parser.tests.scanner2.Scanner2Test;
|
||||||
|
|
||||||
|
@ -55,6 +56,7 @@ public class ParserTestSuite extends TestCase {
|
||||||
suite.addTest( GCCParserExtensionTestSuite.suite() );
|
suite.addTest( GCCParserExtensionTestSuite.suite() );
|
||||||
suite.addTestSuite( AST2Tests.class );
|
suite.addTestSuite( AST2Tests.class );
|
||||||
suite.addTestSuite( GCCTests.class );
|
suite.addTestSuite( GCCTests.class );
|
||||||
|
suite.addTestSuite( QuickParser2Tests.class );
|
||||||
return suite;
|
return suite;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -51,11 +51,14 @@ public class QuickParser2Tests extends TestCase {
|
||||||
public static class ProblemCollector implements IProblemRequestor {
|
public static class ProblemCollector implements IProblemRequestor {
|
||||||
|
|
||||||
List problems = new ArrayList();
|
List problems = new ArrayList();
|
||||||
/* (non-Javadoc)
|
|
||||||
|
/*
|
||||||
|
* (non-Javadoc)
|
||||||
|
*
|
||||||
* @see org.eclipse.cdt.internal.core.parser2.IProblemRequestor#acceptProblem(org.eclipse.cdt.core.parser.IProblem)
|
* @see org.eclipse.cdt.internal.core.parser2.IProblemRequestor#acceptProblem(org.eclipse.cdt.core.parser.IProblem)
|
||||||
*/
|
*/
|
||||||
public boolean acceptProblem(IProblem problem) {
|
public boolean acceptProblem(IProblem problem) {
|
||||||
problems.add( problem );
|
problems.add(problem);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -67,8 +70,11 @@ public class QuickParser2Tests extends TestCase {
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static final NullLogService NULL_LOG = new NullLogService();
|
private static final NullLogService NULL_LOG = new NullLogService();
|
||||||
|
|
||||||
private static final NullSourceElementRequestor NULL_REQUESTOR = new NullSourceElementRequestor();
|
private static final NullSourceElementRequestor NULL_REQUESTOR = new NullSourceElementRequestor();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
@ -113,19 +119,20 @@ public class QuickParser2Tests extends TestCase {
|
||||||
parse(code.toString());
|
parse(code.toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void parse( String code, boolean expectedToPass, ParserLanguage lang ) throws Exception
|
protected void parse(String code, boolean expectedToPass,
|
||||||
{
|
ParserLanguage lang) throws Exception {
|
||||||
parse( code, expectedToPass, lang, false );
|
parse(code, expectedToPass, lang, false);
|
||||||
}
|
}
|
||||||
protected void parse( String code, boolean expectedToPass ) throws Exception
|
|
||||||
{
|
protected void parse(String code, boolean expectedToPass) throws Exception {
|
||||||
parse( code, expectedToPass, ParserLanguage.CPP );
|
parse(code, expectedToPass, ParserLanguage.CPP);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param code
|
* @param code
|
||||||
*/
|
*/
|
||||||
protected void parse(String code) throws Exception {
|
protected void parse(String code) throws Exception {
|
||||||
parse( code, true, ParserLanguage.CPP );
|
parse(code, true, ParserLanguage.CPP);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testNamespaceDefinition() throws Exception {
|
public void testNamespaceDefinition() throws Exception {
|
||||||
|
@ -541,13 +548,10 @@ public class QuickParser2Tests extends TestCase {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testBug36769A() throws Exception {
|
public void testBug36769A() throws Exception {
|
||||||
Writer code = new StringWriter();
|
|
||||||
code
|
|
||||||
.write("template <class A, B> cls<A, C>::operator op &() const {}\n"); //$NON-NLS-1$
|
|
||||||
code.write("template <class A, B> cls<A, C>::cls() {}\n"); //$NON-NLS-1$
|
|
||||||
code.write("template <class A, B> cls<A, C>::~cls() {}\n"); //$NON-NLS-1$
|
|
||||||
|
|
||||||
parse(code.toString());
|
parse("template <class A, B> cls<A, C>::operator &() const {}\n"); //$NON-NLS-1$
|
||||||
|
parse("template <class A, B> cls<A, C>::cls() {}\n"); //$NON-NLS-1$
|
||||||
|
parse("template <class A, B> cls<A, C>::~cls() {}\n"); //$NON-NLS-1$
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testBug36714() throws Exception {
|
public void testBug36714() throws Exception {
|
||||||
|
@ -578,14 +582,11 @@ public class QuickParser2Tests extends TestCase {
|
||||||
|
|
||||||
public void testBug36699() throws Exception {
|
public void testBug36699() throws Exception {
|
||||||
Writer code = new StringWriter();
|
Writer code = new StringWriter();
|
||||||
code
|
code.write("template < template <class> class ThreadingModel = DEFAULT_THREADING,\n"); //$NON-NLS-1$
|
||||||
.write("template < template <class> class ThreadingModel = DEFAULT_THREADING,\n"); //$NON-NLS-1$
|
|
||||||
code.write("std::size_t chunkSize = DEFAULT_CHUNK_SIZE,\n"); //$NON-NLS-1$
|
code.write("std::size_t chunkSize = DEFAULT_CHUNK_SIZE,\n"); //$NON-NLS-1$
|
||||||
code
|
code.write("std::size_t maxSmallObjectSize = MAX_SMALL_OBJECT_SIZE >\n"); //$NON-NLS-1$
|
||||||
.write("std::size_t maxSmallObjectSize = MAX_SMALL_OBJECT_SIZE >\n"); //$NON-NLS-1$
|
|
||||||
code.write("class SmallObject : public ThreadingModel<\n"); //$NON-NLS-1$
|
code.write("class SmallObject : public ThreadingModel<\n"); //$NON-NLS-1$
|
||||||
code
|
code.write("SmallObject<ThreadingModel, chunkSize, maxSmallObjectSize> >\n"); //$NON-NLS-1$
|
||||||
.write("SmallObject<ThreadingModel, chunkSize, maxSmallObjectSize> >\n"); //$NON-NLS-1$
|
|
||||||
code.write("{};\n"); //$NON-NLS-1$
|
code.write("{};\n"); //$NON-NLS-1$
|
||||||
parse(code.toString());
|
parse(code.toString());
|
||||||
}
|
}
|
||||||
|
@ -692,8 +693,7 @@ public class QuickParser2Tests extends TestCase {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testTemplateSpecialization() throws Exception {
|
public void testTemplateSpecialization() throws Exception {
|
||||||
parse(
|
parse("template<> class stream<char> { /* ... */ };"); //$NON-NLS-1$
|
||||||
"template<> class stream<char> { /* ... */ };"); //$NON-NLS-1$
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testTemplateInstantiation() throws Exception {
|
public void testTemplateInstantiation() throws Exception {
|
||||||
|
@ -705,11 +705,11 @@ public class QuickParser2Tests extends TestCase {
|
||||||
*/
|
*/
|
||||||
public void testMultipleDeclarators() throws Exception {
|
public void testMultipleDeclarators() throws Exception {
|
||||||
// Parse and get the translaton unit
|
// Parse and get the translaton unit
|
||||||
parse( "class A { int floor( double input ), someInt; };"); //$NON-NLS-1$
|
parse("class A { int floor( double input ), someInt; };"); //$NON-NLS-1$
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testFunctionModifiers() throws Exception {
|
public void testFunctionModifiers() throws Exception {
|
||||||
parse( "class A {virtual void foo( void ) const throw ( yay, nay, we::dont::care ) = 0;};"); //$NON-NLS-1$
|
parse("class A {virtual void foo( void ) const throw ( yay, nay, we::dont::care ) = 0;};"); //$NON-NLS-1$
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testArrays() throws Exception {
|
public void testArrays() throws Exception {
|
||||||
|
@ -734,8 +734,7 @@ public class QuickParser2Tests extends TestCase {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testPointerOperators() throws Exception {
|
public void testPointerOperators() throws Exception {
|
||||||
parse(
|
parse("int * x = 0, & y, * const * volatile * z;"); //$NON-NLS-1$
|
||||||
"int * x = 0, & y, * const * volatile * z;"); //$NON-NLS-1$
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testBug26467() throws Exception {
|
public void testBug26467() throws Exception {
|
||||||
|
@ -753,7 +752,7 @@ public class QuickParser2Tests extends TestCase {
|
||||||
|
|
||||||
public void testConstructorChain() throws Exception {
|
public void testConstructorChain() throws Exception {
|
||||||
//TODO - requires CPPVisitor in order to reduce ambiguities
|
//TODO - requires CPPVisitor in order to reduce ambiguities
|
||||||
parse( "TrafficLight_Actor::TrafficLight_Actor( RTController * rtg_rts, RTActorRef * rtg_ref ) : RTActor( rtg_rts, rtg_ref ), myId( 0 ) {}"); //$NON-NLS-1$
|
parse("TrafficLight_Actor::TrafficLight_Actor( RTController * rtg_rts, RTActorRef * rtg_ref ) : RTActor( rtg_rts, rtg_ref ), myId( 0 ) {}"); //$NON-NLS-1$
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testBug36237() throws Exception {
|
public void testBug36237() throws Exception {
|
||||||
|
@ -777,11 +776,11 @@ public class QuickParser2Tests extends TestCase {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testTemplateDeclarationOfFunction() throws Exception {
|
public void testTemplateDeclarationOfFunction() throws Exception {
|
||||||
parse( "template<class A, typename B=C> A aTemplatedFunction( B bInstance );"); //$NON-NLS-1$
|
parse("template<class A, typename B=C> A aTemplatedFunction( B bInstance );"); //$NON-NLS-1$
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testTemplateDeclarationOfClass() throws Exception {
|
public void testTemplateDeclarationOfClass() throws Exception {
|
||||||
parse( "template<class T, typename Tibor = junk, class, typename, int x, float y,template <class Y> class, template<class A> class AClass> class myarray { /* ... */ };"); //$NON-NLS-1$
|
parse("template<class T, typename Tibor = junk, class, typename, int x, float y,template <class Y> class, template<class A> class AClass> class myarray { /* ... */ };"); //$NON-NLS-1$
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testBug35906() throws Exception {
|
public void testBug35906() throws Exception {
|
||||||
|
@ -812,7 +811,8 @@ public class QuickParser2Tests extends TestCase {
|
||||||
code.write("#define CMD_GET \"g\"\n"); //$NON-NLS-1$
|
code.write("#define CMD_GET \"g\"\n"); //$NON-NLS-1$
|
||||||
code.write("#define CMD_ACTION \"a\"\n"); //$NON-NLS-1$
|
code.write("#define CMD_ACTION \"a\"\n"); //$NON-NLS-1$
|
||||||
code.write("#define CMD_QUIT \"q\"\n"); //$NON-NLS-1$
|
code.write("#define CMD_QUIT \"q\"\n"); //$NON-NLS-1$
|
||||||
code.write("static const memevent_cmd_func memevent_cmd_funcs[sizeof memevent_cmds - 1] = {\n"); //$NON-NLS-1$
|
code
|
||||||
|
.write("static const memevent_cmd_func memevent_cmd_funcs[sizeof memevent_cmds - 1] = {\n"); //$NON-NLS-1$
|
||||||
code.write("memevent_get,\n"); //$NON-NLS-1$
|
code.write("memevent_get,\n"); //$NON-NLS-1$
|
||||||
code.write("memevent_action,\n"); //$NON-NLS-1$
|
code.write("memevent_action,\n"); //$NON-NLS-1$
|
||||||
code.write("memevent_quit,\n"); //$NON-NLS-1$
|
code.write("memevent_quit,\n"); //$NON-NLS-1$
|
||||||
|
@ -866,13 +866,11 @@ public class QuickParser2Tests extends TestCase {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testBug36708() throws Exception {
|
public void testBug36708() throws Exception {
|
||||||
parse(
|
parse("enum { isPointer = PointerTraits<T>::result };"); //$NON-NLS-1$
|
||||||
"enum { isPointer = PointerTraits<T>::result };"); //$NON-NLS-1$
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testBug36690() throws Exception {
|
public void testBug36690() throws Exception {
|
||||||
parse(
|
parse("Functor(const Functor& rhs) : spImpl_(Impl::Clone(rhs.spImpl_.get())){}"); //$NON-NLS-1$
|
||||||
"Functor(const Functor& rhs) : spImpl_(Impl::Clone(rhs.spImpl_.get())){}"); //$NON-NLS-1$
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testBug36703() throws Exception {
|
public void testBug36703() throws Exception {
|
||||||
|
@ -933,8 +931,7 @@ public class QuickParser2Tests extends TestCase {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testBug36600() throws Exception {
|
public void testBug36600() throws Exception {
|
||||||
parse(
|
parse("enum mad_flow (*input_func)(void *, struct mad_stream *);"); //$NON-NLS-1$
|
||||||
"enum mad_flow (*input_func)(void *, struct mad_stream *);"); //$NON-NLS-1$
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testBug36713() throws Exception {
|
public void testBug36713() throws Exception {
|
||||||
|
@ -1189,8 +1186,7 @@ public class QuickParser2Tests extends TestCase {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testBug43062() throws Exception {
|
public void testBug43062() throws Exception {
|
||||||
parse(
|
parse("class X { operator short (); operator int unsigned(); operator int signed(); };"); //$NON-NLS-1$
|
||||||
"class X { operator short (); operator int unsigned(); operator int signed(); };"); //$NON-NLS-1$
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testBug39531() throws Exception {
|
public void testBug39531() throws Exception {
|
||||||
|
@ -1253,8 +1249,7 @@ public class QuickParser2Tests extends TestCase {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testBug39536A() throws Exception {
|
public void testBug39536A() throws Exception {
|
||||||
parse(
|
parse("template<class E> class X { X<E>(); };"); //$NON-NLS-1$
|
||||||
"template<class E> class X { X<E>(); };"); //$NON-NLS-1$
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testBug39536B() throws Exception {
|
public void testBug39536B() throws Exception {
|
||||||
|
@ -1268,7 +1263,7 @@ public class QuickParser2Tests extends TestCase {
|
||||||
//Here starts C99-specific section
|
//Here starts C99-specific section
|
||||||
public void testBug39549() throws Exception {
|
public void testBug39549() throws Exception {
|
||||||
parse(
|
parse(
|
||||||
"struct X x = { .b = 40, .z = { sizeof(X), 42 }, .t[3] = 2, .t.f[3].x = A * B };", true, ParserLanguage.C); //$NON-NLS-1$
|
"struct X x = { .b = 40, .z = { sizeof(X), 42 }, .t[3] = 2, .t.f[3].x = A * B };", true, ParserLanguage.C); //$NON-NLS-1$
|
||||||
// with trailing commas
|
// with trailing commas
|
||||||
parse(
|
parse(
|
||||||
"struct X x = { .b = 40, .z = { sizeof(X), 42,}, .t[3] = 2, .t.f[3].x = A * B ,};", true, ParserLanguage.C); //$NON-NLS-1$
|
"struct X x = { .b = 40, .z = { sizeof(X), 42,}, .t[3] = 2, .t.f[3].x = A * B ,};", true, ParserLanguage.C); //$NON-NLS-1$
|
||||||
|
@ -1280,12 +1275,11 @@ public class QuickParser2Tests extends TestCase {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testBug39551B() throws Exception {
|
public void testBug39551B() throws Exception {
|
||||||
parse(
|
parse("_Imaginary double id = 99.99 * __I__;", true, ParserLanguage.C); //$NON-NLS-1$
|
||||||
"_Imaginary double id = 99.99 * __I__;", true, ParserLanguage.C); //$NON-NLS-1$
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testCBool() throws Exception {
|
public void testCBool() throws Exception {
|
||||||
parse( "_Bool x;", true, ParserLanguage.C); //$NON-NLS-1$
|
parse("_Bool x;", true, ParserLanguage.C); //$NON-NLS-1$
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testBug39678() throws Exception {
|
public void testBug39678() throws Exception {
|
||||||
|
@ -1305,14 +1299,17 @@ public class QuickParser2Tests extends TestCase {
|
||||||
// IASTMacro swap = (IASTMacro) macros.next();
|
// IASTMacro swap = (IASTMacro) macros.next();
|
||||||
// assertFalse( macros.hasNext() );
|
// assertFalse( macros.hasNext() );
|
||||||
// assertEquals( swap.getName(), "SWAP"); //$NON-NLS-1$
|
// assertEquals( swap.getName(), "SWAP"); //$NON-NLS-1$
|
||||||
// assertEquals( swap.getMacroType(), IMacroDescriptor.MacroType.FUNCTION_LIKE );
|
// assertEquals( swap.getMacroType(),
|
||||||
|
// IMacroDescriptor.MacroType.FUNCTION_LIKE );
|
||||||
// String [] params = swap.getParameters();
|
// String [] params = swap.getParameters();
|
||||||
// assertEquals( params.length, 2 );
|
// assertEquals( params.length, 2 );
|
||||||
// assertEquals( params[0], "x"); //$NON-NLS-1$
|
// assertEquals( params[0], "x"); //$NON-NLS-1$
|
||||||
// assertEquals( params[1], "y"); //$NON-NLS-1$
|
// assertEquals( params[1], "y"); //$NON-NLS-1$
|
||||||
// String completeSignature = swap.getCompleteSignature().trim();
|
// String completeSignature = swap.getCompleteSignature().trim();
|
||||||
// assertEquals( completeSignature, "#define SWAP(x,y) {x|=y;y|=x;x|=y;}"); //$NON-NLS-1$
|
// assertEquals( completeSignature, "#define SWAP(x,y) {x|=y;y|=x;x|=y;}");
|
||||||
// assertEquals( swap.getExpansionSignature().trim(),"{x|=y;y|=x;x|=y;}"); //$NON-NLS-1$
|
// //$NON-NLS-1$
|
||||||
|
// assertEquals( swap.getExpansionSignature().trim(),"{x|=y;y|=x;x|=y;}");
|
||||||
|
// //$NON-NLS-1$
|
||||||
// IToken [] tokens = swap.getTokenizedExpansion();
|
// IToken [] tokens = swap.getTokenizedExpansion();
|
||||||
// validateToken( tokens[0], IToken.tLBRACE);
|
// validateToken( tokens[0], IToken.tLBRACE);
|
||||||
// validateIdentifier( tokens[1], "x"); //$NON-NLS-1$
|
// validateIdentifier( tokens[1], "x"); //$NON-NLS-1$
|
||||||
|
@ -1335,7 +1332,7 @@ public class QuickParser2Tests extends TestCase {
|
||||||
// */
|
// */
|
||||||
// private void validateIdentifier(IToken token, String identifierName ) {
|
// private void validateIdentifier(IToken token, String identifierName ) {
|
||||||
// validateToken( token, IToken.tIDENTIFIER);
|
// validateToken( token, IToken.tIDENTIFIER);
|
||||||
// assertEquals( token.getImage(), identifierName );
|
// assertEquals( token.getImage(), identifierName );
|
||||||
// }
|
// }
|
||||||
// /**
|
// /**
|
||||||
// * @param token
|
// * @param token
|
||||||
|
@ -1376,7 +1373,8 @@ public class QuickParser2Tests extends TestCase {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testBug57652() throws Exception {
|
public void testBug57652() throws Exception {
|
||||||
parse( "struct file_operations driver_fops = { open: device_open, release: device_release };", true, ParserLanguage.C, true); //$NON-NLS-1$
|
parse(
|
||||||
|
"struct file_operations driver_fops = { open: device_open, release: device_release };", true, ParserLanguage.C, true); //$NON-NLS-1$
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1385,41 +1383,37 @@ public class QuickParser2Tests extends TestCase {
|
||||||
* @param c
|
* @param c
|
||||||
* @param d
|
* @param d
|
||||||
*/
|
*/
|
||||||
protected void parse(String code, boolean expectedToPass, ParserLanguage lang, boolean gcc ) throws Exception {
|
protected void parse(String code, boolean expectedToPass,
|
||||||
|
ParserLanguage lang, boolean gcc) throws Exception {
|
||||||
|
|
||||||
ProblemCollector collector = new ProblemCollector();
|
ProblemCollector collector = new ProblemCollector();
|
||||||
IScanner scanner = ParserFactory.createScanner(new CodeReader(code
|
IScanner scanner = ParserFactory.createScanner(new CodeReader(code
|
||||||
.toCharArray()), new ScannerInfo(), ParserMode.QUICK_PARSE,
|
.toCharArray()), new ScannerInfo(), ParserMode.QUICK_PARSE,
|
||||||
lang, NULL_REQUESTOR,
|
lang, NULL_REQUESTOR, NULL_LOG, Collections.EMPTY_LIST);
|
||||||
NULL_LOG, Collections.EMPTY_LIST);
|
|
||||||
ISourceCodeParser parser2 = null;
|
ISourceCodeParser parser2 = null;
|
||||||
if( lang == ParserLanguage.CPP )
|
if (lang == ParserLanguage.CPP) {
|
||||||
{
|
|
||||||
ICPPParserExtensionConfiguration config = null;
|
ICPPParserExtensionConfiguration config = null;
|
||||||
if( gcc )
|
if (gcc)
|
||||||
config = new GNUCPPParserExtensionConfiguration();
|
config = new GNUCPPParserExtensionConfiguration();
|
||||||
else
|
else
|
||||||
config = new ANSICPPParserExtensionConfiguration();
|
config = new ANSICPPParserExtensionConfiguration();
|
||||||
parser2 = new GNUCPPSourceParser(scanner, ParserMode.QUICK_PARSE, collector,
|
parser2 = new GNUCPPSourceParser(scanner, ParserMode.QUICK_PARSE,
|
||||||
NULL_LOG,
|
collector, NULL_LOG, config);
|
||||||
config );
|
} else {
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
ICParserExtensionConfiguration config = null;
|
ICParserExtensionConfiguration config = null;
|
||||||
if( gcc )
|
if (gcc)
|
||||||
config = new GCCParserExtensionConfiguration();
|
config = new GCCParserExtensionConfiguration();
|
||||||
else
|
else
|
||||||
config = new ANSICParserExtensionConfiguration();
|
config = new ANSICParserExtensionConfiguration();
|
||||||
|
|
||||||
parser2 = new GNUCSourceParser( scanner, ParserMode.QUICK_PARSE, collector,
|
parser2 = new GNUCSourceParser(scanner, ParserMode.QUICK_PARSE,
|
||||||
NULL_LOG, config );
|
collector, NULL_LOG, config);
|
||||||
}
|
}
|
||||||
IASTTranslationUnit tu = parser2.parse();
|
IASTTranslationUnit tu = parser2.parse();
|
||||||
if( parser2.encounteredError() && expectedToPass )
|
if (parser2.encounteredError() && expectedToPass)
|
||||||
throw new ParserException( "FAILURE"); //$NON-NLS-1$
|
throw new ParserException("FAILURE"); //$NON-NLS-1$
|
||||||
if( expectedToPass )
|
if (expectedToPass)
|
||||||
assertTrue( collector.hasNoProblems() );
|
assertTrue(collector.hasNoProblems());
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testBug60142() throws Exception {
|
public void testBug60142() throws Exception {
|
||||||
|
@ -1430,8 +1424,7 @@ public class QuickParser2Tests extends TestCase {
|
||||||
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(
|
parse("int k[][] = { {0, {1}, {2,3}};", false, language); //$NON-NLS-1$
|
||||||
"int k[][] = { {0, {1}, {2,3}};", false, language); //$NON-NLS-1$
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1468,82 +1461,76 @@ public class QuickParser2Tests extends TestCase {
|
||||||
writer
|
writer
|
||||||
.write("static char fmt_1002[] = \"(/,\\002At iterate\\002,i5,4x,\\002f= \\002,1p,d12\\\r\n"); //$NON-NLS-1$
|
.write("static char fmt_1002[] = \"(/,\\002At iterate\\002,i5,4x,\\002f= \\002,1p,d12\\\r\n"); //$NON-NLS-1$
|
||||||
writer.write(".5,4x,\\002|proj g|= \\002,1p,d12.5)\";"); //$NON-NLS-1$
|
writer.write(".5,4x,\\002|proj g|= \\002,1p,d12.5)\";"); //$NON-NLS-1$
|
||||||
parse(
|
parse(writer.toString(), true, ParserLanguage.C);
|
||||||
writer.toString(), true, ParserLanguage.C);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testBug39694() throws Exception
|
public void testBug39694() throws Exception {
|
||||||
{
|
|
||||||
parse("int ab$cd = 1;"); //$NON-NLS-1$
|
parse("int ab$cd = 1;"); //$NON-NLS-1$
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testBug39704A() throws Exception
|
public void testBug39704A() throws Exception {
|
||||||
{
|
|
||||||
parse("__declspec (dllimport) int foo;"); //$NON-NLS-1$
|
parse("__declspec (dllimport) int foo;"); //$NON-NLS-1$
|
||||||
}
|
}
|
||||||
public void testBug39704D() throws Exception
|
|
||||||
{
|
public void testBug39704D() throws Exception {
|
||||||
parse("__declspec(dllexport) int func1 (int a) {}"); //$NON-NLS-1$
|
parse("__declspec(dllexport) int func1 (int a) {}"); //$NON-NLS-1$
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testBug39695() throws Exception
|
public void testBug39695() throws Exception {
|
||||||
{
|
|
||||||
parse("int a = __alignof__ (int);", true, ParserLanguage.CPP, true); //$NON-NLS-1$
|
parse("int a = __alignof__ (int);", true, ParserLanguage.CPP, true); //$NON-NLS-1$
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testBug39684() throws Exception
|
public void testBug39684() throws Exception {
|
||||||
{
|
parse(
|
||||||
parse("typeof(foo(1)) bar () { return foo(1); }", true, ParserLanguage.CPP, true); //$NON-NLS-1$
|
"typeof(foo(1)) bar () { return foo(1); }", true, ParserLanguage.CPP, true); //$NON-NLS-1$
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testBug39703() throws Exception
|
public void testBug39703() throws Exception {
|
||||||
{
|
|
||||||
Writer code = new StringWriter();
|
Writer code = new StringWriter();
|
||||||
code.write("/* __extension__ enables GNU C mode for the duration of the declaration. */\n"); //$NON-NLS-1$
|
code
|
||||||
|
.write("/* __extension__ enables GNU C mode for the duration of the declaration. */\n"); //$NON-NLS-1$
|
||||||
code.write("__extension__ struct G {\n"); //$NON-NLS-1$
|
code.write("__extension__ struct G {\n"); //$NON-NLS-1$
|
||||||
code.write(" struct { char z; };\n"); //$NON-NLS-1$
|
code.write(" struct { char z; };\n"); //$NON-NLS-1$
|
||||||
code.write(" char g;\n"); //$NON-NLS-1$
|
code.write(" char g;\n"); //$NON-NLS-1$
|
||||||
code.write("};\n"); //$NON-NLS-1$
|
code.write("};\n"); //$NON-NLS-1$
|
||||||
parse(code.toString(), true, ParserLanguage.CPP, true);
|
parse(code.toString(), true, ParserLanguage.CPP, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testBug39698A() throws Exception
|
public void testBug39698A() throws Exception {
|
||||||
{
|
|
||||||
parse("int c = a <? b;", true, ParserLanguage.CPP, true); //$NON-NLS-1$
|
parse("int c = a <? b;", true, ParserLanguage.CPP, true); //$NON-NLS-1$
|
||||||
}
|
}
|
||||||
public void testBug39698B() throws Exception
|
|
||||||
{
|
public void testBug39698B() throws Exception {
|
||||||
parse("int c = a >? b;", true, ParserLanguage.CPP, true); //$NON-NLS-1$
|
parse("int c = a >? b;", true, ParserLanguage.CPP, true); //$NON-NLS-1$
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testBug39554() throws Exception
|
public void testBug39554() throws Exception {
|
||||||
{
|
parse("_Pragma(\"foobar\")", true, ParserLanguage.C); //$NON-NLS-1$
|
||||||
parse("_Pragma(\"foobar\")", true, ParserLanguage.C ); //$NON-NLS-1$
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public void testBug39704B() throws Exception
|
public void testBug39704B() throws Exception {
|
||||||
{
|
parse(
|
||||||
parse("extern int (* import) (void) __attribute__((dllimport));", true, ParserLanguage.CPP, true); //$NON-NLS-1$
|
"extern int (* import) (void) __attribute__((dllimport));", true, ParserLanguage.CPP, true); //$NON-NLS-1$
|
||||||
}
|
}
|
||||||
public void testBug39704C() throws Exception
|
|
||||||
{
|
public void testBug39704C() throws Exception {
|
||||||
parse("int func2 (void) __attribute__((dllexport));", true, ParserLanguage.CPP, true); //$NON-NLS-1$
|
parse(
|
||||||
|
"int func2 (void) __attribute__((dllexport));", true, ParserLanguage.CPP, true); //$NON-NLS-1$
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testBug39686() throws Exception
|
public void testBug39686() throws Exception {
|
||||||
{
|
|
||||||
Writer code = new StringWriter();
|
Writer code = new StringWriter();
|
||||||
code.write("__complex__ double x; // complex double\n"); //$NON-NLS-1$
|
code.write("__complex__ double x; // complex double\n"); //$NON-NLS-1$
|
||||||
code.write("__complex__ short int a; // complex short int\n"); //$NON-NLS-1$
|
code.write("__complex__ short int a; // complex short int\n"); //$NON-NLS-1$
|
||||||
code.write("__complex__ float y = 2.5fi; // 2.5 imaginary float literal\n"); //$NON-NLS-1$
|
code
|
||||||
|
.write("__complex__ float y = 2.5fi; // 2.5 imaginary float literal\n"); //$NON-NLS-1$
|
||||||
code.write("__complex__ int a = 3i; // imaginary intege r literal\n"); //$NON-NLS-1$
|
code.write("__complex__ int a = 3i; // imaginary intege r literal\n"); //$NON-NLS-1$
|
||||||
code.write("double v = __real__ x; // real part of expression\n"); //$NON-NLS-1$
|
code.write("double v = __real__ x; // real part of expression\n"); //$NON-NLS-1$
|
||||||
code.write("double w = __imag__ x; // imaginary part of expression\n"); //$NON-NLS-1$
|
code.write("double w = __imag__ x; // imaginary part of expression\n"); //$NON-NLS-1$
|
||||||
parse(code.toString(), true, ParserLanguage.C, true);
|
parse(code.toString(), true, ParserLanguage.C, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testBug39681() throws Exception
|
public void testBug39681() throws Exception {
|
||||||
{
|
|
||||||
Writer code = new StringWriter();
|
Writer code = new StringWriter();
|
||||||
code.write("double\n"); //$NON-NLS-1$
|
code.write("double\n"); //$NON-NLS-1$
|
||||||
code.write("foo (double a, double b)\n"); //$NON-NLS-1$
|
code.write("foo (double a, double b)\n"); //$NON-NLS-1$
|
||||||
|
@ -1553,42 +1540,40 @@ public class QuickParser2Tests extends TestCase {
|
||||||
code.write("}\n"); //$NON-NLS-1$
|
code.write("}\n"); //$NON-NLS-1$
|
||||||
parse(code.toString());
|
parse(code.toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testBug39677() throws Exception
|
public void testBug39677() throws Exception {
|
||||||
{
|
|
||||||
parse("B::B() : a(({ 1; })) {}", true, ParserLanguage.CPP, true); //$NON-NLS-1$
|
parse("B::B() : a(({ 1; })) {}", true, ParserLanguage.CPP, true); //$NON-NLS-1$
|
||||||
Writer writer = new StringWriter();
|
Writer writer = new StringWriter();
|
||||||
writer.write( "B::B() : a(( { int y = foo (); int z;\n" ); //$NON-NLS-1$
|
writer.write("B::B() : a(( { int y = foo (); int z;\n"); //$NON-NLS-1$
|
||||||
writer.write( "if (y > 0) z = y;\n" ); //$NON-NLS-1$
|
writer.write("if (y > 0) z = y;\n"); //$NON-NLS-1$
|
||||||
writer.write( "else z = - y;\n" );//$NON-NLS-1$
|
writer.write("else z = - y;\n");//$NON-NLS-1$
|
||||||
writer.write( "z; }))\n" );//$NON-NLS-1$
|
writer.write("z; }))\n");//$NON-NLS-1$
|
||||||
parse( writer.toString(), true, ParserLanguage.CPP, true );
|
parse(writer.toString(), true, ParserLanguage.CPP, true);
|
||||||
writer = new StringWriter();
|
writer = new StringWriter();
|
||||||
writer.write( "int x = ({ int y = foo (); int z;\n" ); //$NON-NLS-1$
|
writer.write("int x = ({ int y = foo (); int z;\n"); //$NON-NLS-1$
|
||||||
writer.write( "if (y > 0) z = y;\n" ); //$NON-NLS-1$
|
writer.write("if (y > 0) z = y;\n"); //$NON-NLS-1$
|
||||||
writer.write( "else z = - y;\n" );//$NON-NLS-1$
|
writer.write("else z = - y;\n");//$NON-NLS-1$
|
||||||
writer.write( "z; });\n" );//$NON-NLS-1$
|
writer.write("z; });\n");//$NON-NLS-1$
|
||||||
parse( writer.toString() , true, ParserLanguage.CPP, true);
|
parse(writer.toString(), true, ParserLanguage.CPP, true);
|
||||||
writer = new StringWriter();
|
writer = new StringWriter();
|
||||||
writer.write( "typeof({ int y = foo (); int z;\n" ); //$NON-NLS-1$
|
writer.write("typeof({ int y = foo (); int z;\n"); //$NON-NLS-1$
|
||||||
writer.write( "if (y > 0) z = y;\n" ); //$NON-NLS-1$
|
writer.write("if (y > 0) z = y;\n"); //$NON-NLS-1$
|
||||||
writer.write( "else z = - y;\n" );//$NON-NLS-1$
|
writer.write("else z = - y;\n");//$NON-NLS-1$
|
||||||
writer.write( "z; }) zoot;\n" );//$NON-NLS-1$
|
writer.write("z; }) zoot;\n");//$NON-NLS-1$
|
||||||
parse( writer.toString() , true, ParserLanguage.CPP, true);
|
parse(writer.toString(), true, ParserLanguage.CPP, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testBug39701A() throws Exception
|
public void testBug39701A() throws Exception {
|
||||||
{
|
parse(
|
||||||
parse("extern template int max (int, int);", true, ParserLanguage.CPP, true); //$NON-NLS-1$
|
"extern template int max (int, int);", true, ParserLanguage.CPP, true); //$NON-NLS-1$
|
||||||
}
|
}
|
||||||
public void testBug39701B() throws Exception
|
|
||||||
{
|
public void testBug39701B() throws Exception {
|
||||||
parse("inline template class Foo<int>;", true, ParserLanguage.CPP, true); //$NON-NLS-1$
|
parse("inline template class Foo<int>;", true, ParserLanguage.CPP, true); //$NON-NLS-1$
|
||||||
}
|
}
|
||||||
public void testBug39701C() throws Exception
|
|
||||||
{
|
public void testBug39701C() throws Exception {
|
||||||
parse("static template class Foo<int>;", true, ParserLanguage.CPP, true); //$NON-NLS-1$
|
parse("static template class Foo<int>;", true, ParserLanguage.CPP, true); //$NON-NLS-1$
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
|
@ -112,6 +112,8 @@ public class BasicTokenDuple implements ITokenDuple {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
ITokenDuple d = TokenFactory.createTokenDuple( startOfSegment, last );
|
||||||
|
r.add( d );
|
||||||
return (ITokenDuple[]) r.toArray( new ITokenDuple[ r.size() ]);
|
return (ITokenDuple[]) r.toArray( new ITokenDuple[ r.size() ]);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -132,4 +132,46 @@ public class TemplateTokenDuple extends BasicTokenDuple {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public ITokenDuple[] getSegments()
|
||||||
|
{
|
||||||
|
List r = new ArrayList();
|
||||||
|
IToken token = null;
|
||||||
|
IToken prev = null;
|
||||||
|
IToken last = getLastToken();
|
||||||
|
IToken startOfSegment = getFirstToken();
|
||||||
|
int count = 0;
|
||||||
|
for( ;; ){
|
||||||
|
if( token == last )
|
||||||
|
break;
|
||||||
|
prev = token;
|
||||||
|
token = ( token != null ) ? token.getNext() : getFirstToken();
|
||||||
|
if( token.getType() == IToken.tLT )
|
||||||
|
token = TokenFactory.consumeTemplateIdArguments( token, last );
|
||||||
|
if( token.getType() == IToken.tCOLONCOLON ){
|
||||||
|
List newArgs = null;
|
||||||
|
if( argLists[count] != null )
|
||||||
|
{
|
||||||
|
newArgs = new ArrayList( 1 );
|
||||||
|
newArgs.add( argLists[count]);
|
||||||
|
}
|
||||||
|
ITokenDuple d = TokenFactory.createTokenDuple( startOfSegment, prev, newArgs );
|
||||||
|
r.add( d );
|
||||||
|
startOfSegment = token.getNext();
|
||||||
|
++count;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
List newArgs = null;
|
||||||
|
if( argLists[count] != null )
|
||||||
|
{
|
||||||
|
newArgs = new ArrayList( 1 );
|
||||||
|
newArgs.add( argLists[count]);
|
||||||
|
}
|
||||||
|
ITokenDuple d = TokenFactory.createTokenDuple( startOfSegment, last, newArgs);
|
||||||
|
r.add( d );
|
||||||
|
return (ITokenDuple[]) r.toArray( new ITokenDuple[ r.size() ]);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -706,8 +706,19 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser {
|
||||||
case IToken.tLT:
|
case IToken.tLT:
|
||||||
case IToken.tLTEQUAL:
|
case IToken.tLTEQUAL:
|
||||||
case IToken.tGTEQUAL:
|
case IToken.tGTEQUAL:
|
||||||
|
IToken m = mark();
|
||||||
int t = consume().getType();
|
int t = consume().getType();
|
||||||
IASTExpression secondExpression = shiftExpression();
|
|
||||||
|
IASTExpression secondExpression = null;
|
||||||
|
try
|
||||||
|
{
|
||||||
|
secondExpression = shiftExpression();
|
||||||
|
}
|
||||||
|
catch( BacktrackException bte )
|
||||||
|
{
|
||||||
|
backup( m );
|
||||||
|
return firstExpression;
|
||||||
|
}
|
||||||
int expressionKind = 0;
|
int expressionKind = 0;
|
||||||
switch (t) {
|
switch (t) {
|
||||||
case IToken.tGT:
|
case IToken.tGT:
|
||||||
|
@ -874,7 +885,7 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser {
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
declSpecifier = declSpecifierSeq(false, false);
|
declSpecifier = declSpecifierSeq(false, false);
|
||||||
declarator = declarator( SimpleDeclarationStrategy.TRY_CONSTRUCTOR );
|
declarator = declarator( SimpleDeclarationStrategy.TRY_CONSTRUCTOR, true );
|
||||||
}
|
}
|
||||||
catch( BacktrackException bt )
|
catch( BacktrackException bt )
|
||||||
{
|
{
|
||||||
|
@ -2367,7 +2378,7 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser {
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
private IASTName createTemplateID(ITokenDuple duple) {
|
private IASTName createTemplateID(ITokenDuple duple) {
|
||||||
return new CASTName(); //TODO
|
return new CASTName(); //TODO - what is a template ID?
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -3145,7 +3156,7 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser {
|
||||||
*/
|
*/
|
||||||
protected IASTDeclarator initDeclarator(SimpleDeclarationStrategy strategy )
|
protected IASTDeclarator initDeclarator(SimpleDeclarationStrategy strategy )
|
||||||
throws EndOfFileException, BacktrackException {
|
throws EndOfFileException, BacktrackException {
|
||||||
IASTDeclarator d = declarator(strategy);
|
IASTDeclarator d = declarator(strategy, false);
|
||||||
|
|
||||||
IASTInitializer initializer = optionalCPPInitializer();
|
IASTInitializer initializer = optionalCPPInitializer();
|
||||||
if( initializer != null )
|
if( initializer != null )
|
||||||
|
@ -3269,14 +3280,14 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser {
|
||||||
* (oldKRParameterDeclaration)*
|
* (oldKRParameterDeclaration)*
|
||||||
*
|
*
|
||||||
* declaratorId : name
|
* declaratorId : name
|
||||||
|
* @param forTypeID TODO
|
||||||
* @param container
|
* @param container
|
||||||
* IParserCallback object that represents the owner declaration.
|
* IParserCallback object that represents the owner declaration.
|
||||||
*
|
|
||||||
* @return declarator that this parsing produced.
|
* @return declarator that this parsing produced.
|
||||||
* @throws BacktrackException
|
* @throws BacktrackException
|
||||||
* request a backtrack
|
* request a backtrack
|
||||||
*/
|
*/
|
||||||
protected IASTDeclarator declarator(SimpleDeclarationStrategy strategy) throws EndOfFileException,
|
protected IASTDeclarator declarator(SimpleDeclarationStrategy strategy, boolean forTypeID) throws EndOfFileException,
|
||||||
BacktrackException {
|
BacktrackException {
|
||||||
|
|
||||||
IToken la = LA(1);
|
IToken la = LA(1);
|
||||||
|
@ -3300,12 +3311,12 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser {
|
||||||
|
|
||||||
consumePointerOperators(pointerOps);
|
consumePointerOperators(pointerOps);
|
||||||
|
|
||||||
if (LT(1) == IToken.tLPAREN) {
|
if (!forTypeID && LT(1) == IToken.tLPAREN) {
|
||||||
IToken mark = mark();
|
IToken mark = mark();
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
consume();
|
consume();
|
||||||
innerDecl = declarator(strategy);
|
innerDecl = declarator(strategy, forTypeID);
|
||||||
consume(IToken.tRPAREN);
|
consume(IToken.tRPAREN);
|
||||||
}
|
}
|
||||||
catch( BacktrackException bte )
|
catch( BacktrackException bte )
|
||||||
|
@ -3652,7 +3663,7 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser {
|
||||||
throwBacktrack(mark.getOffset(), endOffset, mark
|
throwBacktrack(mark.getOffset(), endOffset, mark
|
||||||
.getLineNumber(), mark.getFilename());
|
.getLineNumber(), mark.getFilename());
|
||||||
}
|
}
|
||||||
return TokenFactory.createTokenDuple( start, end );
|
return TokenFactory.createTokenDuple( start, end, argumentList.getTemplateArgumentsList() );
|
||||||
}
|
}
|
||||||
int endOffset = (lastToken != null) ? lastToken
|
int endOffset = (lastToken != null) ? lastToken
|
||||||
.getEndOffset() : 0;
|
.getEndOffset() : 0;
|
||||||
|
|
Loading…
Add table
Reference in a new issue