[cfe-commits] r154643 - in /cfe/trunk: lib/Lex/Lexer.cpp test/Lexer/newline-eof-c++11.cpp test/Lexer/newline-eof.c

Seth Cantrell seth.cantrell at gmail.com
Thu Apr 12 18:00:34 PDT 2012


Author: socantre
Date: Thu Apr 12 20:00:34 2012
New Revision: 154643

URL: http://llvm.org/viewvc/llvm-project?rev=154643&view=rev
Log:
C++11 no longer requires files to end with a newline

Added:
    cfe/trunk/test/Lexer/newline-eof-c++11.cpp
Modified:
    cfe/trunk/lib/Lex/Lexer.cpp
    cfe/trunk/test/Lexer/newline-eof.c

Modified: cfe/trunk/lib/Lex/Lexer.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Lex/Lexer.cpp?rev=154643&r1=154642&r2=154643&view=diff
==============================================================================
--- cfe/trunk/lib/Lex/Lexer.cpp (original)
+++ cfe/trunk/lib/Lex/Lexer.cpp Thu Apr 12 20:00:34 2012
@@ -2375,7 +2375,8 @@
 
   // 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");
 

Added: cfe/trunk/test/Lexer/newline-eof-c++11.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Lexer/newline-eof-c%2B%2B11.cpp?rev=154643&view=auto
==============================================================================
--- cfe/trunk/test/Lexer/newline-eof-c++11.cpp (added)
+++ cfe/trunk/test/Lexer/newline-eof-c++11.cpp Thu Apr 12 20:00:34 2012
@@ -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

Modified: cfe/trunk/test/Lexer/newline-eof.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Lexer/newline-eof.c?rev=154643&r1=154642&r2=154643&view=diff
==============================================================================
--- cfe/trunk/test/Lexer/newline-eof.c (original)
+++ cfe/trunk/test/Lexer/newline-eof.c Thu Apr 12 20:00:34 2012
@@ -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





More information about the cfe-commits mailing list