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:
parent
de98fe1839
commit
9b571cb993
5 changed files with 40 additions and 10 deletions
|
@ -1,3 +1,6 @@
|
||||||
|
2003-07-28 Victor Mozgin
|
||||||
|
Moved testBug39537() from ASTFailedTests.java to QuickParseASTTests.java.
|
||||||
|
|
||||||
2003-07-27 John Camelon
|
2003-07-27 John Camelon
|
||||||
Fixed failedTests::testBug40714() to fail properly.
|
Fixed failedTests::testBug40714() to fail properly.
|
||||||
|
|
||||||
|
|
|
@ -107,10 +107,6 @@ public class ASTFailedTests extends BaseASTTest
|
||||||
{
|
{
|
||||||
assertCodeFailsParse("template<class E> class X { inline X<E>(int); };");
|
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
|
public void testBug39538() throws Exception
|
||||||
{
|
{
|
||||||
assertCodeFailsParse("template C::operator int<float> ();");
|
assertCodeFailsParse("template C::operator int<float> ();");
|
||||||
|
|
|
@ -1709,4 +1709,10 @@ public class QuickParseASTTests extends BaseASTTest
|
||||||
parse("#define COMP_INC \"foobar.h\" \n" + "#include COMP_INC");
|
parse("#define COMP_INC \"foobar.h\" \n" + "#include COMP_INC");
|
||||||
assertTrue( quickParseCallback.getInclusions().hasNext() );
|
assertTrue( quickParseCallback.getInclusions().hasNext() );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void testBug39537() throws Exception
|
||||||
|
{
|
||||||
|
parse("typedef foo<(U::id > 0)> foobar;");
|
||||||
|
assertTrue( quickParseCallback.getCompilationUnit().getDeclarations().hasNext() );
|
||||||
|
}
|
||||||
}
|
}
|
|
@ -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
|
2003-07-25 Victor Mozgin
|
||||||
Fixed PR 39553 : Macros are not expanded in #include statements.
|
Fixed PR 39553 : Macros are not expanded in #include statements.
|
||||||
|
|
||||||
|
|
|
@ -12,6 +12,7 @@ package org.eclipse.cdt.internal.core.parser;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Stack;
|
||||||
|
|
||||||
import org.eclipse.cdt.core.parser.Backtrack;
|
import org.eclipse.cdt.core.parser.Backtrack;
|
||||||
import org.eclipse.cdt.core.parser.EndOfFile;
|
import org.eclipse.cdt.core.parser.EndOfFile;
|
||||||
|
@ -1496,17 +1497,38 @@ public class Parser implements IParser
|
||||||
{
|
{
|
||||||
last = consume(IToken.tLT);
|
last = consume(IToken.tLT);
|
||||||
// until we get all the names sorted out
|
// until we get all the names sorted out
|
||||||
int depth = 1;
|
Stack scopes = new Stack();
|
||||||
while (depth > 0)
|
scopes.push(new Integer(IToken.tLT));
|
||||||
|
|
||||||
|
while (!scopes.empty())
|
||||||
{
|
{
|
||||||
|
int top;
|
||||||
last = consume();
|
last = consume();
|
||||||
switch (last.getType())
|
|
||||||
{
|
switch (last.getType()) {
|
||||||
case IToken.tGT :
|
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;
|
break;
|
||||||
case IToken.tLT :
|
case IToken.tLT :
|
||||||
++depth;
|
case IToken.tLBRACKET:
|
||||||
|
case IToken.tLPAREN:
|
||||||
|
scopes.push(new Integer(last.getType()));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue