Support -Wc++98-compat-pedantic as requested:

http://lists.cs.uiuc.edu/pipermail/cfe-commits/Week-of-Mon-20120409/056126.html

llvm-svn: 154655
This commit is contained in:
Seth Cantrell 2012-04-13 03:43:23 +00:00
parent 0a465bb28e
commit e83c731cad
3 changed files with 13 additions and 4 deletions

View File

@ -48,6 +48,11 @@ def ext_bcpl_comment : Extension<
InGroup<Comment>; InGroup<Comment>;
def ext_no_newline_eof : Extension<"no newline at end of file">, def ext_no_newline_eof : Extension<"no newline at end of file">,
InGroup<DiagGroup<"newline-eof">>; InGroup<DiagGroup<"newline-eof">>;
def warn_cxx98_compat_no_newline_eof : Warning<
"C++98 requires newline at end of file">,
InGroup<CXX98CompatPedantic>, DefaultIgnore;
def ext_dollar_in_identifier : Extension<"'$' in identifier">, def ext_dollar_in_identifier : Extension<"'$' in identifier">,
InGroup<DiagGroup<"dollar-in-identifier-extension">>; InGroup<DiagGroup<"dollar-in-identifier-extension">>;
def ext_charize_microsoft : Extension<"@# is a microsoft extension">, def ext_charize_microsoft : Extension<"@# is a microsoft extension">,

View File

@ -2375,9 +2375,9 @@ 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 // C99 5.1.1.2p2: If the file is non-empty and didn't end in a newline, issue
// a pedwarn. // 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, LangOpts.CPlusPlus0x ? // C++11 [lex.phases] 2.2 p2
Diag(BufferEnd, diag::ext_no_newline_eof) diag::warn_cxx98_compat_no_newline_eof : diag::ext_no_newline_eof)
<< FixItHint::CreateInsertion(getSourceLocation(BufferEnd), "\n"); << FixItHint::CreateInsertion(getSourceLocation(BufferEnd), "\n");
BufferPtr = CurPtr; BufferPtr = CurPtr;

View File

@ -0,0 +1,4 @@
// RUN: %clang -cc1 -fsyntax-only -Wc++98-compat-pedantic -std=c++11 -verify %s
// The following line isn't terminated, don't fix it.
void foo() {} // expected-warning{{C++98 requires newline at end of file}}