1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-07-24 09:25:31 +02:00

Patch for Devin Steffler

Fixed 77281 - Unable to parse assignment statements
	Fixed 77921 - Syntax Error on initializer with floats
	Fixed 76763 - Problem for #error has extra characters
This commit is contained in:
John Camelon 2004-11-18 20:30:27 +00:00
parent 2b21f4f108
commit 76d22e0f05
2 changed files with 52 additions and 5 deletions

View file

@ -2268,12 +2268,12 @@ public class CompleteParseASTTest extends CompleteParseBaseTest
Object ipo = probs.next();
assertTrue( ipo instanceof IProblem );
IProblem ip = (IProblem)ipo;
assertTrue(ip.getArguments().indexOf("This was equal, but not for the eclipse") > 0); //$NON-NLS-1$
assertTrue(ip.getArguments().indexOf("This was equal, but not for the eclipse") >= 0); //$NON-NLS-1$
assertTrue( probs.hasNext() );
ipo = probs.next();
assertTrue( ipo instanceof IProblem );
ip = (IProblem)ipo;
assertTrue(ip.getArguments().indexOf("octal test") > 0); //$NON-NLS-1$
assertTrue(ip.getArguments().indexOf("octal test") >= 0); //$NON-NLS-1$
}
}
@ -2352,5 +2352,40 @@ public class CompleteParseASTTest extends CompleteParseBaseTest
IASTParameterDeclaration blank = (IASTParameterDeclaration)parms.next();
assertEquals( ASTUtil.getType( (IASTAbstractDeclaration)blank ), "volatile int&" ); //$NON-NLS-1$
}
public void testBug77281() throws Exception {
Writer writer = new StringWriter();
writer.write("void fun2(float a, float b) {}\n"); //$NON-NLS-1$
writer.write("int main() { fun2(0.24f, 0.25f); }\n"); //$NON-NLS-1$
parse(writer.toString());
}
public void testBug77921() throws Exception {
Writer writer = new StringWriter();
writer.write("void f()\n{\n"); //$NON-NLS-1$
writer.write("static float v0[] = { -1.0f, -1.0f, 1.0f };\n}\n"); //$NON-NLS-1$
parse(writer.toString());
}
public void testBug76763() throws Exception
{
Writer writer = new StringWriter();
writer.write("#error oops!"); //$NON-NLS-1$
try {
parse(writer.toString());
} catch (ParserException pe) {
// expected IProblem
} finally {
Iterator i = callback.getProblems();
assertTrue( i.hasNext() );
Object ipo = i.next();
assertTrue( ipo instanceof IProblem );
IProblem ip = (IProblem)ipo;
assertTrue(new String(ip.getArguments()).equals("oops!")); //$NON-NLS-1$
assertFalse( i.hasNext() );
}
}
}

View file

@ -1327,7 +1327,11 @@ public class Scanner2 implements IScanner, IScannerData {
// must be float suffix
++bufferPos[bufferStackPos];
continue;
if (buffer[bufferPos[bufferStackPos]] == 'i')
continue; // handle GCC extension 5.10 Complex Numbers
break; // fix for 77281 (used to be continue)
case 'p':
case 'P':
@ -1531,7 +1535,8 @@ public class Scanner2 implements IScanner, IScannerData {
handleInvalidCompletion();
return;
case ppError:
start = bufferPos[bufferStackPos];
skipOverWhiteSpace();
start = bufferPos[bufferStackPos] + 1;
skipToNewLine();
len = bufferPos[bufferStackPos] - start;
handleProblem( IProblem.PREPROCESSOR_POUND_ERROR, start, CharArrayUtils.extract( buffer, start, len ));
@ -2533,7 +2538,14 @@ public class Scanner2 implements IScanner, IScannerData {
break;
}
return;
case '\r':
if (escaped && bufferPos[bufferStackPos] < limit && buffer[bufferPos[bufferStackPos] + 1] == '\n') {
escaped = false;
break;
} else if (!escaped && bufferPos[bufferStackPos] < limit && buffer[bufferPos[bufferStackPos] + 1] == '\n') {
return;
}
break;
}
escaped = false;
}