summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSeth Cantrell <seth.cantrell@gmail.com>2012-04-13 01:00:34 +0000
committerSeth Cantrell <seth.cantrell@gmail.com>2012-04-13 01:00:34 +0000
commit10ac7205ce1801cf5f6d90eb94cf38f37f99f8f3 (patch)
tree85a6d953ea32805fcd72ea754fed0a762a12116d
parent8478d76d6482411de023455a2a5abfdbbaa0293f (diff)
downloadbcm5719-llvm-10ac7205ce1801cf5f6d90eb94cf38f37f99f8f3.tar.gz
bcm5719-llvm-10ac7205ce1801cf5f6d90eb94cf38f37f99f8f3.zip
C++11 no longer requires files to end with a newline
llvm-svn: 154643
-rw-r--r--clang/lib/Lex/Lexer.cpp3
-rw-r--r--clang/test/Lexer/newline-eof-c++11.cpp4
-rw-r--r--clang/test/Lexer/newline-eof.c4
3 files changed, 8 insertions, 3 deletions
diff --git a/clang/lib/Lex/Lexer.cpp b/clang/lib/Lex/Lexer.cpp
index c817e3f1056..f0c2c8e4f68 100644
--- a/clang/lib/Lex/Lexer.cpp
+++ b/clang/lib/Lex/Lexer.cpp
@@ -2375,7 +2375,8 @@ bool Lexer::LexEndOfFile(Token &Result, const char *CurPtr) {
// C99 5.1.1.2p2: If the file is non-empty and didn't end in a newline, issue
// a pedwarn.
- if (CurPtr != BufferStart && (CurPtr[-1] != '\n' && CurPtr[-1] != '\r'))
+ if (CurPtr != BufferStart && (CurPtr[-1] != '\n' && CurPtr[-1] != '\r')
+ && !LangOpts.CPlusPlus0x) // C++11 [lex.phases] 2.2 p2
Diag(BufferEnd, diag::ext_no_newline_eof)
<< FixItHint::CreateInsertion(getSourceLocation(BufferEnd), "\n");
diff --git a/clang/test/Lexer/newline-eof-c++11.cpp b/clang/test/Lexer/newline-eof-c++11.cpp
new file mode 100644
index 00000000000..3c45f28336f
--- /dev/null
+++ b/clang/test/Lexer/newline-eof-c++11.cpp
@@ -0,0 +1,4 @@
+// RUN: %clang_cc1 -fsyntax-only -std=c++11 -Wnewline-eof -verify %s
+
+// The following line isn't terminated, don't fix it.
+void foo() {} \ No newline at end of file
diff --git a/clang/test/Lexer/newline-eof.c b/clang/test/Lexer/newline-eof.c
index 2f95dc7593c..12087b23708 100644
--- a/clang/test/Lexer/newline-eof.c
+++ b/clang/test/Lexer/newline-eof.c
@@ -1,5 +1,5 @@
-// RUN: %clang -fsyntax-only -Wnewline-eof -verify %s
+// RUN: %clang -cc1 -fsyntax-only -Wnewline-eof -verify %s
// rdar://9133072
// The following line isn't terminated, don't fix it.
-void foo() {} // expected-warning{{No newline at end of file}} \ No newline at end of file
+void foo() {} // expected-warning{{no newline at end of file}} \ No newline at end of file
OpenPOWER on IntegriCloud