1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-04-29 19:45:01 +02:00

Patch for Victor Mozgin.

Fixed PR 39537 : Parser fails if template parameters contain '>' or
'<'  characters.
This commit is contained in:
John Camelon 2003-07-28 14:18:39 +00:00
parent de98fe1839
commit 9b571cb993
5 changed files with 40 additions and 10 deletions

View file

@ -1,3 +1,6 @@
2003-07-28 Victor Mozgin
Moved testBug39537() from ASTFailedTests.java to QuickParseASTTests.java.
2003-07-27 John Camelon
Fixed failedTests::testBug40714() to fail properly.

View file

@ -107,10 +107,6 @@ public class ASTFailedTests extends BaseASTTest
{
assertCodeFailsParse("template<class E> class X { inline X<E>(int); };");
}
public void testBug39537() throws Exception
{
assertCodeFailsParse("typedef foo<(U::id > 0)> foobar;");
}
public void testBug39538() throws Exception
{
assertCodeFailsParse("template C::operator int<float> ();");

View file

@ -1709,4 +1709,10 @@ public class QuickParseASTTests extends BaseASTTest
parse("#define COMP_INC \"foobar.h\" \n" + "#include COMP_INC");
assertTrue( quickParseCallback.getInclusions().hasNext() );
}
public void testBug39537() throws Exception
{
parse("typedef foo<(U::id > 0)> foobar;");
assertTrue( quickParseCallback.getCompilationUnit().getDeclarations().hasNext() );
}
}

View file

@ -1,3 +1,6 @@
2003-07-28 Victor Mozgin
Fixed PR 39537 : Parser fails if template parameters contain '>' or '<' characters.
2003-07-25 Victor Mozgin
Fixed PR 39553 : Macros are not expanded in #include statements.

View file

@ -12,6 +12,7 @@ package org.eclipse.cdt.internal.core.parser;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.Stack;
import org.eclipse.cdt.core.parser.Backtrack;
import org.eclipse.cdt.core.parser.EndOfFile;
@ -1496,17 +1497,38 @@ public class Parser implements IParser
{
last = consume(IToken.tLT);
// until we get all the names sorted out
int depth = 1;
while (depth > 0)
Stack scopes = new Stack();
scopes.push(new Integer(IToken.tLT));
while (!scopes.empty())
{
int top;
last = consume();
switch (last.getType())
{
switch (last.getType()) {
case IToken.tGT :
--depth;
if (((Integer)scopes.peek()).intValue() == IToken.tLT) {
scopes.pop();
}
break;
case IToken.tRBRACKET :
do {
top = ((Integer)scopes.pop()).intValue();
} while (!scopes.empty() && (top == IToken.tGT || top == IToken.tLT));
if (top != IToken.tLBRACKET) throw backtrack;
break;
case IToken.tRPAREN :
do {
top = ((Integer)scopes.pop()).intValue();
} while (!scopes.empty() && (top == IToken.tGT || top == IToken.tLT));
if (top != IToken.tLPAREN) throw backtrack;
break;
case IToken.tLT :
++depth;
case IToken.tLBRACKET:
case IToken.tLPAREN:
scopes.push(new Integer(last.getType()));
break;
}
}