1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-06-06 17:26:01 +02:00

Patch for Devin Steffler

Fixed 79471 - [Parser] Syntax Errors: Problems with handling float value in the preprocessor statements
This commit is contained in:
John Camelon 2004-11-30 18:21:37 +00:00
parent 3dd222fb35
commit 1e56204749
2 changed files with 19 additions and 1 deletions

View file

@ -2480,5 +2480,23 @@ public class CompleteParseASTTest extends CompleteParseBaseTest
IASTVariable pBase = (IASTVariable)i.next();
assertEquals(pBase.getStartingLine(), 19);
}
public void testBug79471() throws Exception {
Writer writer = new StringWriter();
writer.write("void testFloatAccess(float * fp) {\n"); //$NON-NLS-1$
writer.write("#define VAL 2.0f\n"); //$NON-NLS-1$
writer.write("if(*fp > VAL) { /* Syntax error is here */\n}\n}\n"); //$NON-NLS-1$
parse(writer.toString());
writer = new StringWriter();
writer.write("void testFloatAccess(float * fp) {\n"); //$NON-NLS-1$
writer.write("#define VAL 2.0l\n"); //$NON-NLS-1$
writer.write("if(*fp > VAL) { /* Syntax error is here */\n}\n}\n"); //$NON-NLS-1$
parse(writer.toString());
writer = new StringWriter();
writer.write("void testFloatAccess(float * fp) {\n"); //$NON-NLS-1$
writer.write("#define VAL 2.0f\n"); //$NON-NLS-1$
writer.write("if(VAL > VAL) { /* Syntax error is here */\n}\n}\n"); //$NON-NLS-1$
parse(writer.toString());
}
}

View file

@ -1328,7 +1328,7 @@ public class Scanner2 implements IScanner, IScannerData {
// must be float suffix
++bufferPos[bufferStackPos];
if (buffer[bufferPos[bufferStackPos]] == 'i')
if (bufferPos[bufferStackPos] < buffer.length && buffer[bufferPos[bufferStackPos]] == 'i')
continue; // handle GCC extension 5.10 Complex Numbers
break; // fix for 77281 (used to be continue)