aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/clang/Basic/DiagnosticKinds.def2
-rw-r--r--include/clang/Lex/Lexer.h5
-rw-r--r--lib/Lex/Lexer.cpp7
-rw-r--r--lib/Lex/TokenLexer.cpp6
4 files changed, 8 insertions, 12 deletions
diff --git a/include/clang/Basic/DiagnosticKinds.def b/include/clang/Basic/DiagnosticKinds.def
index 4e4a42f7ae..691f83e1b9 100644
--- a/include/clang/Basic/DiagnosticKinds.def
+++ b/include/clang/Basic/DiagnosticKinds.def
@@ -32,7 +32,7 @@ DIAG(null_in_char , WARNING,
"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")
diff --git a/include/clang/Lex/Lexer.h b/include/clang/Lex/Lexer.h
index 9b17377d7c..a3668dfd08 100644
--- a/include/clang/Lex/Lexer.h
+++ b/include/clang/Lex/Lexer.h
@@ -60,9 +60,8 @@ class Lexer {
/// 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;
diff --git a/lib/Lex/Lexer.cpp b/lib/Lex/Lexer.cpp
index 63bf58a12c..44a32dbe25 100644
--- a/lib/Lex/Lexer.cpp
+++ b/lib/Lex/Lexer.cpp
@@ -931,7 +931,8 @@ bool Lexer::SkipBlockComment(Token &Result, const char *CurPtr) {
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;
}
@@ -1000,10 +1001,10 @@ bool Lexer::SkipBlockComment(Token &Result, const char *CurPtr) {
// 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.
diff --git a/lib/Lex/TokenLexer.cpp b/lib/Lex/TokenLexer.cpp
index d3acaeaab5..82b2b4df0b 100644
--- a/lib/Lex/TokenLexer.cpp
+++ b/lib/Lex/TokenLexer.cpp
@@ -377,11 +377,7 @@ bool TokenLexer::PasteTokens(Token &Tok) {
// 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);