mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-09-10 03:53:21 +02:00
Fixed Bug 75858 - [Parser] [Ambiguity] Relational expression parsed as template-id
This commit is contained in:
parent
f19c9e9061
commit
9dc5a7dffd
2 changed files with 19 additions and 3 deletions
|
@ -102,6 +102,19 @@ import org.eclipse.cdt.internal.core.parser.ParserException;
|
|||
|
||||
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 {
|
||||
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 );
|
||||
|
|
|
@ -420,8 +420,6 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser {
|
|||
protected IToken consumeTemplateArguments(IToken last,
|
||||
TemplateParameterManager argumentList) throws EndOfFileException,
|
||||
BacktrackException {
|
||||
// if (language != ParserLanguage.CPP)
|
||||
// return last;
|
||||
if (LT(1) == IToken.tLT) {
|
||||
IToken secondMark = mark();
|
||||
consume(IToken.tLT);
|
||||
|
@ -432,6 +430,11 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser {
|
|||
case IToken.tGT:
|
||||
case IToken.tEOC:
|
||||
last = consume();
|
||||
if( LT(1) == IToken.tINTEGER || LT(1) == IToken.tFLOATINGPT )
|
||||
{
|
||||
backup( secondMark );
|
||||
return last;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
throw backtrack;
|
||||
|
@ -5153,7 +5156,7 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser {
|
|||
consume(IToken.tLPAREN);
|
||||
IASTNode condition = null;
|
||||
try {
|
||||
condition = cppStyleCondition(); // TODO should be while
|
||||
condition = cppStyleCondition();
|
||||
// condition
|
||||
if (LT(1) == IToken.tEOC) {
|
||||
// Completing in the condition
|
||||
|
|
Loading…
Add table
Reference in a new issue