diff options
author | Richard Smith <richard-llvm@metafoo.co.uk> | 2017-04-18 21:45:04 +0000 |
---|---|---|
committer | Richard Smith <richard-llvm@metafoo.co.uk> | 2017-04-18 21:45:04 +0000 |
commit | 4c132e576bbd9ad90904ec4ca385cbd7ae06ded2 (patch) | |
tree | 02ffbd167a57cce42cee683caacdde83cbbb9173 | |
parent | 09bb760baa542aadb0712a34f5bf79c34677845b (diff) | |
download | bcm5719-llvm-4c132e576bbd9ad90904ec4ca385cbd7ae06ded2.tar.gz bcm5719-llvm-4c132e576bbd9ad90904ec4ca385cbd7ae06ded2.zip |
Do not warn about whitespace between ??/ trigraph and newline in line comments if trigraphs are disabled in the current language.
llvm-svn: 300609
-rw-r--r-- | clang/lib/Lex/Lexer.cpp | 10 | ||||
-rw-r--r-- | clang/test/Lexer/cxx1z-trigraphs.cpp | 7 |
2 files changed, 12 insertions, 5 deletions
diff --git a/clang/lib/Lex/Lexer.cpp b/clang/lib/Lex/Lexer.cpp index 5d0fe42defd..dc911ef91b6 100644 --- a/clang/lib/Lex/Lexer.cpp +++ b/clang/lib/Lex/Lexer.cpp @@ -1171,6 +1171,8 @@ const char *Lexer::SkipEscapedNewLines(const char *P) { // 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 &Result, const char *CurPtr, 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); } diff --git a/clang/test/Lexer/cxx1z-trigraphs.cpp b/clang/test/Lexer/cxx1z-trigraphs.cpp index 0ea2adbe1e0..08c45e51f83 100644 --- a/clang/test/Lexer/cxx1z-trigraphs.cpp +++ b/clang/test/Lexer/cxx1z-trigraphs.cpp @@ -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] == '#', ""); // expected-error {{failed}} expected-warnin // ??/ 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 {{}} |