same we we do an unterminated string or character literal. This makes
it so we can guarantee that the lexer never calls into the
preprocessor (which would be suicide for a raw lexer).
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@57395
91177308-0d34-0410-b5e6-
96231b3b80d8
"null character(s) preserved in character literal")
DIAG(null_in_file , WARNING,
"null character ignored")
-DIAG(nested_block_comment, WARNING,
+DIAG(warn_nested_block_comment, WARNING,
"\"/*\" within block comment")
DIAG(escaped_newline_block_comment_end, WARNING,
"escaped newline between */ characters at block comment end")
/// effect of this, implicit macro expansion is naturally disabled.
/// 3. "#" tokens at the start of a line are treated as normal tokens, not
/// implicitly transformed by the lexer.
- /// 4. All diagnostic messages are disabled, except for unterminated /*.
- /// 5. The only callback made into the preprocessor is to report a hard error
- /// on an unterminated '/*' comment.
+ /// 4. All diagnostic messages are disabled.
+ /// 5. No callbacks are made into the preprocessor.
///
/// Note that in raw mode that the PP pointer may be null.
bool LexingRawMode;
unsigned char C = getCharAndSize(CurPtr, CharSize);
CurPtr += CharSize;
if (C == 0 && CurPtr == BufferEnd+1) {
- Diag(BufferPtr, diag::err_unterminated_block_comment);
+ if (!LexingRawMode)
+ Diag(BufferPtr, diag::err_unterminated_block_comment);
BufferPtr = CurPtr-1;
return true;
}
// If this is a /* inside of the comment, emit a warning. Don't do this
// if this is a /*/, which will end the comment. This misses cases with
// embedded escaped newlines, but oh well.
- Diag(CurPtr-1, diag::nested_block_comment);
+ Diag(CurPtr-1, diag::warn_nested_block_comment);
}
} else if (C == 0 && CurPtr == BufferEnd+1) {
- Diag(BufferPtr, diag::err_unterminated_block_comment);
+ if (!LexingRawMode) Diag(BufferPtr, diag::err_unterminated_block_comment);
// Note: the user probably forgot a */. We could continue immediately
// after the /*, but this would involve lexing a lot of what really is the
// comment, which surely would confuse the parser.
// Lex the resultant pasted token into Result.
Token Result;
- // Avoid testing /*, as the lexer would think it is the start of a comment
- // and emit an error that it is unterminated.
- if (Tok.is(tok::slash) && RHS.is(tok::star)) {
- isInvalid = true;
- } else if (Tok.is(tok::identifier) && RHS.is(tok::identifier)) {
+ if (Tok.is(tok::identifier) && RHS.is(tok::identifier)) {
// Common paste case: identifier+identifier = identifier. Avoid creating
// a lexer and other overhead.
PP.IncrementPasteCounter(true);