[cfe-dev] C++11 newline eof

Seth Cantrell seth.cantrell at gmail.com
Thu Apr 12 17:11:44 PDT 2012


Thanks, turns out the test I copied from (test/Lexer/newline-eof.c) wasn't working either. I'll fix it when I check this in.

Also, after reviewing the llvm developer policy I've decided that this change is minor enough that I'm just going to commit it here in a little while.

On Apr 12, 2012, at 6:47 PM, David Blaikie wrote:

> On Thu, Apr 12, 2012 at 3:40 PM, Seth Cantrell <seth.cantrell at gmail.com> wrote:
>> Please review this patch:
>> 
>>> diff --git a/lib/Lex/Lexer.cpp b/lib/Lex/Lexer.cpp
>>> index e5d26ff..f27e238 100644
>>> --- a/lib/Lex/Lexer.cpp
>>> +++ b/lib/Lex/Lexer.cpp
>>> @@ -2382,7 +2382,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");
>>> 
>>> 
>>> 
>> 
>> 
>> Also, can anyone tell me why when I run clang with -verify and -std=c++11 I get a warning "clang: warning: argument unused during compilation: '-verify'"? I've verified that my patch changes the warnings output from clang based on the -std=c++11 flag, but since -verify doesn't seen work I can't add a working test. Here's a test that should fail but doesn't for me:
> 
> -verify is a cc1 (the underlying clang binary, not the gcc-compatible
> driver) option - use %clang_cc1 instead of %clang & you should be fine
> 
>> 
>> 
>> _______________________________________________
>> cfe-dev mailing list
>> cfe-dev at cs.uiuc.edu
>> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev
>> 





More information about the cfe-dev mailing list