1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-07-31 12:55:40 +02:00

Support for comments before directives, bug 255318.

This commit is contained in:
Markus Schorn 2008-11-14 10:34:10 +00:00
parent 8e55e2392f
commit 973949d7e4
3 changed files with 38 additions and 8 deletions

View file

@ -187,23 +187,48 @@ public class PreprocessorBugsTests extends PreprocessorTestsBase {
validateProblem(0, IProblem.PREPROCESSOR_MISSING_RPAREN_PARMLIST, null); validateProblem(0, IProblem.PREPROCESSOR_MISSING_RPAREN_PARMLIST, null);
} }
// #ifdef 0 // /**/ #if 0
// bug
// /**/ #endif
// passed
//
// /*
// */ #if 0
// bug
// /**/ #endif
// passed
//
// #if 0
// /**/ #else // /**/ #else
// OK1 // OK1
// #endif // #endif
// #ifdef 0 //
// a /* // #if 0
// /*
// */ #else // */ #else
// OK2 // OK2
// #endif // #endif
// #ifdef 0 //
// #if 0
// a /**/ #else // a /**/ #else
// NOTOK // bug
// #endif // #endif
// passed
//
// #if 0
// a /*
// */ #else // interesting, gcc ignores this directive, we mimic the behavior
// bug
// #endif
// passed
public void testCommentBeforeDirective_Bug255318() throws Exception { public void testCommentBeforeDirective_Bug255318() throws Exception {
initializeScanner(); initializeScanner();
validateIdentifier("passed");
validateIdentifier("passed");
validateIdentifier("OK1"); validateIdentifier("OK1");
validateIdentifier("OK2"); validateIdentifier("OK2");
validateIdentifier("passed");
validateIdentifier("passed");
validateEOF(); validateEOF();
validateProblemCount(0); validateProblemCount(0);
} }

View file

@ -99,9 +99,13 @@ public abstract class PreprocessorTestsBase extends BaseTestCase {
} }
protected void validateToken(int tokenType, String image) throws Exception { protected void validateToken(int tokenType, String image) throws Exception {
IToken t= fScanner.nextToken(); try {
assertEquals(tokenType, t.getType()); IToken t= fScanner.nextToken();
assertEquals(image, t.getImage()); assertEquals(tokenType, t.getType());
assertEquals(image, t.getImage());
} catch (EndOfFileException e) {
fail("Missing token " + image);
}
} }
protected void validateInteger(String expectedImage) throws Exception { protected void validateInteger(String expectedImage) throws Exception {

View file

@ -269,6 +269,7 @@ final public class Lexer {
continue; continue;
case '*': case '*':
blockComment(start, '*'); blockComment(start, '*');
haveNL= hadNL;
continue; continue;
case '%': case '%':
if (fOptions.fSupportSlashPercentComments) { if (fOptions.fSupportSlashPercentComments) {