1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-04-29 19:45:01 +02:00
Partial fix for Bug 36932 - RTS: Parser fails on "new" in ctor initializer
	Fixed Bug 36704 - Problem parsing Loki's Reference Typelist.h 
	Fixed Bug 36699 - Problem parsing Loki's Reference SmartPtr.h Impl 
	Fixed Bug 36691 - Problem parsing Loki's Reference HierarchyGenerators.h Impl 

TESTS
	Added testBug36932() to DOMTests. 
	Moved testBugFunctor758() from LokiFailures to DOMTests.
	Moved testBug36704() from DOMFailedTest to DOMTests.  
	Moved testBug36699() from DOMFailedTest to DOMTests.  
	Moved testBug36691() from DOMFailedTest to DOMTests.
This commit is contained in:
John Camelon 2003-04-27 22:53:58 +00:00
parent 4d93d6c4df
commit 1c7ed5ec08
6 changed files with 163 additions and 59 deletions

View file

@ -1,3 +1,9 @@
2003-04-27 John Camelon
Partial fix for Bug 36932 - RTS: Parser fails on "new" in ctor initializer
Fixed Bug 36704 - Problem parsing Loki's Reference Typelist.h
Fixed Bug 36699 - Problem parsing Loki's Reference SmartPtr.h Impl
Fixed Bug 36691 - Problem parsing Loki's Reference HierarchyGenerators.h Impl
2003-04-25 Andrew Niefer 2003-04-25 Andrew Niefer
Fixed bug36771 - Outline view shows include with no name Fixed bug36771 - Outline view shows include with no name
Fixed bug36714 - Parser fails on initial assignment using floating-suffix Fixed bug36714 - Parser fails on initial assignment using floating-suffix

View file

@ -861,7 +861,23 @@ c, quick);
break; break;
case Token.t_typename: case Token.t_typename:
try{ callback.simpleDeclSpecifier(decl, consume( Token.t_typename ));} catch( Exception e ) {} try{ callback.simpleDeclSpecifier(decl, consume( Token.t_typename ));} catch( Exception e ) {}
Token first = LA(1);
Token last = null;
name(); name();
if( LT(1) == Token.t_template )
{
consume( Token.t_template );
last = templateId();
try
{
callback.nameBegin( first );
callback.nameEnd( last );
}
catch( Exception e ) { }
}
try{ callback.simpleDeclSpecifierName( decl );} catch( Exception e ) {} try{ callback.simpleDeclSpecifierName( decl );} catch( Exception e ) {}
return; return;
case Token.tCOLONCOLON: case Token.tCOLONCOLON:
@ -872,6 +888,8 @@ c, quick);
// handle nested later: // handle nested later:
if ( flags.haveEncounteredRawType() ) if ( flags.haveEncounteredRawType() )
return; return;
if( parm && flags.haveEncounteredTypename() )
return;
if ( lookAheadForConstructor( flags ) ) if ( lookAheadForConstructor( flags ) )
return; return;
if ( lookAheadForDeclarator( flags ) ) if ( lookAheadForDeclarator( flags ) )
@ -962,12 +980,24 @@ c, quick);
*/ */
protected void className() throws Backtrack protected void className() throws Backtrack
{ {
Token first = LA(1);
if( LT(1) == Token.tIDENTIFIER) if( LT(1) == Token.tIDENTIFIER)
{ {
if( LT(2) == Token.tLT ) if( LT(2) == Token.tLT )
{ {
consume( Token.tIDENTIFIER ); templateId();
}
else
{
identifier();
return;
}
}
else
throw backtrack;
}
protected Token templateId() throws Backtrack, EndOfFile {
Token first = consume( Token.tIDENTIFIER );
consume( Token.tLT ); consume( Token.tLT );
// until we get all the names sorted out // until we get all the names sorted out
@ -988,15 +1018,7 @@ c, quick);
callback.nameBegin( first ); callback.nameBegin( first );
callback.nameEnd( last ); callback.nameEnd( last );
} return last;
else
{
identifier();
return;
}
}
else
throw backtrack;
} }
/** /**
@ -1055,6 +1077,9 @@ c, quick);
while (LT(1) == Token.tCOLONCOLON) { while (LT(1) == Token.tCOLONCOLON) {
last = consume(); last = consume();
if (LT(1) == Token.t_template )
consume();
if (LT(1) == Token.tCOMPL) if (LT(1) == Token.tCOMPL)
consume(); consume();
@ -2013,9 +2038,22 @@ c, quick);
case Token.tLT: case Token.tLT:
case Token.tLTEQUAL: case Token.tLTEQUAL:
case Token.tGTEQUAL: case Token.tGTEQUAL:
Token mark = mark();
Token t = consume(); Token t = consume();
Token next = LA(1);
shiftExpression(expression); shiftExpression(expression);
if( next == LA(1) )
{
// we did not consume anything
// this is most likely an error
backup( mark );
return;
}
else
{
try{ callback.expressionOperator(expression, t);} catch( Exception e ) {} try{ callback.expressionOperator(expression, t);} catch( Exception e ) {}
}
break; break;
default: default:
return; return;
@ -2195,6 +2233,21 @@ c, quick);
castExpression( expression ); castExpression( expression );
} }
/**
*
* @param expression
* @throws Backtrack
*
*
* newexpression: ::? new newplacement? newtypeid newinitializer?
* ::? new newplacement? ( typeid ) newinitializer?
* newplacement: ( expressionlist )
* newtypeid: typespecifierseq newdeclarator?
* newdeclarator: ptroperator newdeclarator? | directnewdeclarator
* directnewdeclarator: [ expression ]
* directnewdeclarator [ constantexpression ]
* newinitializer: ( expressionlist? )
*/
protected void newExpression( Object expression ) throws Backtrack { protected void newExpression( Object expression ) throws Backtrack {
if (LT(1) == Token.tCOLONCOLON) { if (LT(1) == Token.tCOLONCOLON) {
// global scope // global scope
@ -2203,7 +2256,34 @@ c, quick);
consume (Token.t_new); consume (Token.t_new);
//TODO: finish this horrible mess... // TODO: We are still not handling placement new right
// there are some ambiguities here that make it difficult to look ahead on
// we will need a better strategy in order to not do 3 or 4 backtracks
// every new expression
boolean typeIdInBrackets = false;
if( LT(1) == Token.tLPAREN )
{
consume( Token.tLPAREN );
typeIdInBrackets = true;
}
typeId();
if( typeIdInBrackets )
{
consume( Token.tRPAREN );
}
// newinitializer
if( LT(1) == Token.tLPAREN )
{
consume( Token.tLPAREN );
if( LT(1) != Token.tRPAREN )
assignmentExpression( expression );
consume( Token.tRPAREN );
}
} }
protected void unaryExpression( Object expression ) throws Backtrack { protected void unaryExpression( Object expression ) throws Backtrack {
@ -2476,7 +2556,9 @@ c, quick);
if (currToken == null) if (currToken == null)
currToken = fetchToken(); currToken = fetchToken();
if( currToken != null )
lastToken = currToken; lastToken = currToken;
currToken = currToken.getNext(); currToken = currToken.getNext();
return lastToken; return lastToken;
} }

View file

@ -1,3 +1,10 @@
2003-04-27 John Camelon
Added testBug36932() to DOMTests.
Moved testBugFunctor758() from LokiFailures to DOMTests.
Moved testBug36704() from DOMFailedTest to DOMTests.
Moved testBug36699() from DOMFailedTest to DOMTests.
Moved testBug36691() from DOMFailedTest to DOMTests.
2003-04-25 Andrew Niefer 2003-04-25 Andrew Niefer
Moved ACEFailedTest::testBug36771 to DOMTests Moved ACEFailedTest::testBug36771 to DOMTests
Moved DOMFailedTest::testBug36714 to DOMTests Moved DOMFailedTest::testBug36714 to DOMTests

View file

@ -10,9 +10,6 @@
***********************************************************************/ ***********************************************************************/
package org.eclipse.cdt.core.parser.failedTests; package org.eclipse.cdt.core.parser.failedTests;
import java.io.StringWriter;
import java.io.Writer;
import org.eclipse.cdt.core.parser.tests.BaseDOMTest; import org.eclipse.cdt.core.parser.tests.BaseDOMTest;
/** /**
@ -24,33 +21,6 @@ public class DOMFailedTest extends BaseDOMTest {
super(name); super(name);
} }
public void testBug36704() throws Exception {
failTest("template <class T, class U> struct Length< Typelist<T, U> > { enum { value = 1 + Length<U>::value };};);");
}
public void testBug36691() throws Exception {
Writer code = new StringWriter();
code.write("template <class T, class H>\n");
code.write(
"typename H::template Rebind<T>::Result& Field(H& obj)\n");
code.write("{ return obj; }\n");
failTest(code.toString());
}
public void testBug36699() throws Exception {
Writer code = new StringWriter();
code.write(
"template < template <class> class ThreadingModel = DEFAULT_THREADING,\n");
code.write("std::size_t chunkSize = DEFAULT_CHUNK_SIZE,\n");
code.write(
"std::size_t maxSmallObjectSize = MAX_SMALL_OBJECT_SIZE >\n");
code.write("class SmallObject : public ThreadingModel<\n");
code.write(
"SmallObject<ThreadingModel, chunkSize, maxSmallObjectSize> >\n");
code.write("{};\n");
failTest(code.toString());
}
public void testBug36730(){ public void testBug36730(){
failTest("FUNCTION_MACRO( 1, a );\n int i;"); failTest("FUNCTION_MACRO( 1, a );\n int i;");
} }

View file

@ -29,10 +29,6 @@ public class LokiFailures extends BaseDOMTest {
failTest("int Test::* pMember_;" ); failTest("int Test::* pMember_;" );
} }
public void testBugFunctor758() {
failTest( "template <typename Fun> Functor(Fun fun) : spImpl_(new FunctorHandler<Functor, Fun>(fun)){}" );
}
public void testBugTypeManip151() public void testBugTypeManip151()
{ {
Writer code = new StringWriter(); Writer code = new StringWriter();

View file

@ -1712,5 +1712,48 @@ public class DOMTests extends BaseDOMTest {
TranslationUnit tu = parse( code.toString() ); TranslationUnit tu = parse( code.toString() );
} }
public void testBugFunctor758() throws Exception {
TranslationUnit tu = parse( "template <typename Fun> Functor(Fun fun) : spImpl_(new FunctorHandler<Functor, Fun>(fun)){}" );
}
public void testBug36932() throws Exception
{
TranslationUnit tu = parse( "A::A(): b( new int( 5 ) ), b( new B ), c( new int ) {}" );
}
public void testBug36704() throws Exception {
Writer code = new StringWriter();
code.write( "template <class T, class U>\n" );
code.write( "struct Length< Typelist<T, U> >\n" );
code.write( "{\n" );
code.write( "enum { value = 1 + Length<U>::value };\n" );
code.write( "};\n" );
parse(code.toString());
}
public void testBug36699() throws Exception {
Writer code = new StringWriter();
code.write(
"template < template <class> class ThreadingModel = DEFAULT_THREADING,\n");
code.write("std::size_t chunkSize = DEFAULT_CHUNK_SIZE,\n");
code.write(
"std::size_t maxSmallObjectSize = MAX_SMALL_OBJECT_SIZE >\n");
code.write("class SmallObject : public ThreadingModel<\n");
code.write(
"SmallObject<ThreadingModel, chunkSize, maxSmallObjectSize> >\n");
code.write("{};\n");
parse(code.toString());
}
public void testBug36691() throws Exception {
Writer code = new StringWriter();
code.write("template <class T, class H>\n");
code.write(
"typename H::template Rebind<T>::Result& Field(H& obj)\n");
code.write("{ return obj; }\n");
parse(code.toString());
}
} }