1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-09-10 12:03:16 +02:00

Fixed Bug 75858 - [Parser] [Ambiguity] Relational expression parsed as template-id

This commit is contained in:
John Camelon 2005-06-01 15:53:48 +00:00
parent f19c9e9061
commit 9dc5a7dffd
2 changed files with 19 additions and 3 deletions

View file

@ -102,6 +102,19 @@ import org.eclipse.cdt.internal.core.parser.ParserException;
public class AST2CPPTests extends AST2BaseTest { public class AST2CPPTests extends AST2BaseTest {
public void testBug75858() throws Exception {
StringBuffer buffer = new StringBuffer();
buffer.append( "bool f() {\n" );
buffer.append( " int first, last;\n" );
buffer.append( "if(first < 1 || last > 99 )\n" );
buffer.append( "return false;\n" );
buffer.append( "}\n" );
IASTTranslationUnit tu = parse( buffer.toString(), ParserLanguage.CPP );
CPPNameCollector col = new CPPNameCollector();
tu.accept(col);
assertNoProblemBindings( col );
}
public void testBug95424() throws Exception { public void testBug95424() throws Exception {
IASTTranslationUnit tu = parse( "void f(){ traits_type::copy(__r->_M_refdata(), __buf, __i); }", ParserLanguage.CPP, true, true ); IASTTranslationUnit tu = parse( "void f(){ traits_type::copy(__r->_M_refdata(), __buf, __i); }", ParserLanguage.CPP, true, true );
tu = parse( "void f(){ traits_type::copy(__r->_M_refdata(), __buf, __i); }", ParserLanguage.CPP, false, true ); tu = parse( "void f(){ traits_type::copy(__r->_M_refdata(), __buf, __i); }", ParserLanguage.CPP, false, true );

View file

@ -420,8 +420,6 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser {
protected IToken consumeTemplateArguments(IToken last, protected IToken consumeTemplateArguments(IToken last,
TemplateParameterManager argumentList) throws EndOfFileException, TemplateParameterManager argumentList) throws EndOfFileException,
BacktrackException { BacktrackException {
// if (language != ParserLanguage.CPP)
// return last;
if (LT(1) == IToken.tLT) { if (LT(1) == IToken.tLT) {
IToken secondMark = mark(); IToken secondMark = mark();
consume(IToken.tLT); consume(IToken.tLT);
@ -432,6 +430,11 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser {
case IToken.tGT: case IToken.tGT:
case IToken.tEOC: case IToken.tEOC:
last = consume(); last = consume();
if( LT(1) == IToken.tINTEGER || LT(1) == IToken.tFLOATINGPT )
{
backup( secondMark );
return last;
}
break; break;
default: default:
throw backtrack; throw backtrack;
@ -5153,7 +5156,7 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser {
consume(IToken.tLPAREN); consume(IToken.tLPAREN);
IASTNode condition = null; IASTNode condition = null;
try { try {
condition = cppStyleCondition(); // TODO should be while condition = cppStyleCondition();
// condition // condition
if (LT(1) == IToken.tEOC) { if (LT(1) == IToken.tEOC) {
// Completing in the condition // Completing in the condition