r300609 - Do not warn about whitespace between ??/ trigraph and newline in line comments if trigraphs are disabled in the current language.
Richard Smith via cfe-commits
cfe-commits at lists.llvm.org
Tue Apr 18 14:45:04 PDT 2017
Author: rsmith
Date: Tue Apr 18 16:45:04 2017
New Revision: 300609
URL: http://llvm.org/viewvc/llvm-project?rev=300609&view=rev
Log:
Do not warn about whitespace between ??/ trigraph and newline in line comments if trigraphs are disabled in the current language.
Modified:
cfe/trunk/lib/Lex/Lexer.cpp
cfe/trunk/test/Lexer/cxx1z-trigraphs.cpp
Modified: cfe/trunk/lib/Lex/Lexer.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Lex/Lexer.cpp?rev=300609&r1=300608&r2=300609&view=diff
==============================================================================
--- cfe/trunk/lib/Lex/Lexer.cpp (original)
+++ cfe/trunk/lib/Lex/Lexer.cpp Tue Apr 18 16:45:04 2017
@@ -1171,6 +1171,8 @@ const char *Lexer::SkipEscapedNewLines(c
// If not a trigraph for escape, bail out.
if (P[1] != '?' || P[2] != '/')
return P;
+ // FIXME: Take LangOpts into account; the language might not
+ // support trigraphs.
AfterEscape = P+3;
} else {
return P;
@@ -2079,17 +2081,17 @@ bool Lexer::SkipLineComment(Token &Resul
HasSpace = true;
}
- if (*EscapePtr == '\\') // Escaped newline.
+ if (*EscapePtr == '\\')
+ // Escaped newline.
CurPtr = EscapePtr;
else if (EscapePtr[0] == '/' && EscapePtr[-1] == '?' &&
- EscapePtr[-2] == '?') // Trigraph-escaped newline.
+ EscapePtr[-2] == '?' && LangOpts.Trigraphs)
+ // Trigraph-escaped newline.
CurPtr = EscapePtr-2;
else
break; // This is a newline, we're done.
// If there was space between the backslash and newline, warn about it.
- // FIXME: This warning is bogus if trigraphs are disabled and the line
- // ended with '?' '?' '\\' '\n'.
if (HasSpace && !isLexingRawMode())
Diag(EscapePtr, diag::backslash_newline_space);
}
Modified: cfe/trunk/test/Lexer/cxx1z-trigraphs.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Lexer/cxx1z-trigraphs.cpp?rev=300609&r1=300608&r2=300609&view=diff
==============================================================================
--- cfe/trunk/test/Lexer/cxx1z-trigraphs.cpp (original)
+++ cfe/trunk/test/Lexer/cxx1z-trigraphs.cpp Tue Apr 18 16:45:04 2017
@@ -1,5 +1,5 @@
// RUN: %clang_cc1 -std=c++1z %s -verify
-// RUN: %clang_cc1 -std=c++1z %s -ftrigraphs -fsyntax-only
+// RUN: %clang_cc1 -std=c++1z %s -ftrigraphs -fsyntax-only 2>&1 | FileCheck --check-prefix=TRIGRAPHS %s
??= define foo ; // expected-error {{}} expected-warning {{trigraph ignored}}
@@ -7,3 +7,8 @@ static_assert("??="[0] == '#', ""); // e
// ??/
error here; // expected-error {{}}
+
+// Note, there is intentionally trailing whitespace two lines below.
+// TRIGRAPHS: :[[@LINE+1]]:{{.*}} backslash and newline separated by space
+// ??/
+error here; // expected-error {{}}
More information about the cfe-commits
mailing list