mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-29 19:45:01 +02:00
Support for comments before directives, bug 255318.
This commit is contained in:
parent
8e55e2392f
commit
973949d7e4
3 changed files with 38 additions and 8 deletions
|
@ -187,23 +187,48 @@ public class PreprocessorBugsTests extends PreprocessorTestsBase {
|
|||
validateProblem(0, IProblem.PREPROCESSOR_MISSING_RPAREN_PARMLIST, null);
|
||||
}
|
||||
|
||||
// #ifdef 0
|
||||
// /**/ #if 0
|
||||
// bug
|
||||
// /**/ #endif
|
||||
// passed
|
||||
//
|
||||
// /*
|
||||
// */ #if 0
|
||||
// bug
|
||||
// /**/ #endif
|
||||
// passed
|
||||
//
|
||||
// #if 0
|
||||
// /**/ #else
|
||||
// OK1
|
||||
// #endif
|
||||
// #ifdef 0
|
||||
// a /*
|
||||
//
|
||||
// #if 0
|
||||
// /*
|
||||
// */ #else
|
||||
// OK2
|
||||
// #endif
|
||||
// #ifdef 0
|
||||
//
|
||||
// #if 0
|
||||
// a /**/ #else
|
||||
// NOTOK
|
||||
// bug
|
||||
// #endif
|
||||
// passed
|
||||
//
|
||||
// #if 0
|
||||
// a /*
|
||||
// */ #else // interesting, gcc ignores this directive, we mimic the behavior
|
||||
// bug
|
||||
// #endif
|
||||
// passed
|
||||
public void testCommentBeforeDirective_Bug255318() throws Exception {
|
||||
initializeScanner();
|
||||
validateIdentifier("passed");
|
||||
validateIdentifier("passed");
|
||||
validateIdentifier("OK1");
|
||||
validateIdentifier("OK2");
|
||||
validateIdentifier("passed");
|
||||
validateIdentifier("passed");
|
||||
validateEOF();
|
||||
validateProblemCount(0);
|
||||
}
|
||||
|
|
|
@ -99,9 +99,13 @@ public abstract class PreprocessorTestsBase extends BaseTestCase {
|
|||
}
|
||||
|
||||
protected void validateToken(int tokenType, String image) throws Exception {
|
||||
IToken t= fScanner.nextToken();
|
||||
assertEquals(tokenType, t.getType());
|
||||
assertEquals(image, t.getImage());
|
||||
try {
|
||||
IToken t= fScanner.nextToken();
|
||||
assertEquals(tokenType, t.getType());
|
||||
assertEquals(image, t.getImage());
|
||||
} catch (EndOfFileException e) {
|
||||
fail("Missing token " + image);
|
||||
}
|
||||
}
|
||||
|
||||
protected void validateInteger(String expectedImage) throws Exception {
|
||||
|
|
|
@ -269,6 +269,7 @@ final public class Lexer {
|
|||
continue;
|
||||
case '*':
|
||||
blockComment(start, '*');
|
||||
haveNL= hadNL;
|
||||
continue;
|
||||
case '%':
|
||||
if (fOptions.fSupportSlashPercentComments) {
|
||||
|
|
Loading…
Add table
Reference in a new issue