[cfe-commits] r154273 - in /cfe/trunk: include/clang/Basic/DiagnosticLexKinds.td lib/Lex/Lexer.cpp test/Lexer/ms-extensions.cpp

Jordan Rose jediknil at belkadan.com
Tue Apr 10 07:48:09 PDT 2012


Sorry, I wasn't trying to distinguish MSVC from the MicrosoftMode flag. I just meant that if we're relaxing the C++11 standard, maybe it's better to only relax it for system headers, and leave it as an error for user files. However, if it's a documented feature that users can write any user-defined literal they want, then we're stuck.


On Apr 10, 2012, at 10:42, Francois Pichet wrote:

> MicrosoftMode is a MSVC mode, I don't see why we would want a special
> case for system headers, it would be just complicated for nothing.
> 
> On Sat, Apr 7, 2012 at 8:01 PM, Jordan Rose <jediknil at belkadan.com> wrote:
>> Is this true about all MicrosoftMode files, or just an exception for MSVC? If the latter, it might be better just to limit it to system headers.
>> 
>> 
>> On Apr 7, 2012, at 19:09, Francois Pichet wrote:
>> 
>>> Author: fpichet
>>> Date: Sat Apr  7 18:09:23 2012
>>> New Revision: 154273
>>> 
>>> URL: http://llvm.org/viewvc/llvm-project?rev=154273&view=rev
>>> Log:
>>> ext_reserved_user_defined_literal must not default to Error in MicrosoftMode. Hence create ext_ms_reserved_user_defined_literal that doesn't default to Error; otherwise MSVC headers won't parse.
>>> 
>>> Fixes PR12383.
>>> 
>>> Added:
>>>    cfe/trunk/test/Lexer/ms-extensions.cpp
>>> Modified:
>>>    cfe/trunk/include/clang/Basic/DiagnosticLexKinds.td
>>>    cfe/trunk/lib/Lex/Lexer.cpp
>>> 
>>> Modified: cfe/trunk/include/clang/Basic/DiagnosticLexKinds.td
>>> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticLexKinds.td?rev=154273&r1=154272&r2=154273&view=diff
>>> ==============================================================================
>>> --- cfe/trunk/include/clang/Basic/DiagnosticLexKinds.td (original)
>>> +++ cfe/trunk/include/clang/Basic/DiagnosticLexKinds.td Sat Apr  7 18:09:23 2012
>>> @@ -151,6 +151,9 @@
>>> def ext_reserved_user_defined_literal : ExtWarn<
>>>   "invalid suffix on literal; C++11 requires a space between literal and "
>>>   "identifier">, InGroup<ReservedUserDefinedLiteral>, DefaultError;
>>> +def ext_ms_reserved_user_defined_literal : ExtWarn<
>>> +  "invalid suffix on literal; C++11 requires a space between literal and "
>>> +  "identifier">, InGroup<ReservedUserDefinedLiteral>;
>>> def err_unsupported_string_concat : Error<
>>>   "unsupported non-standard concatenation of string literals">;
>>> def err_string_concat_mixed_suffix : Error<
>>> 
>>> Modified: cfe/trunk/lib/Lex/Lexer.cpp
>>> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Lex/Lexer.cpp?rev=154273&r1=154272&r2=154273&view=diff
>>> ==============================================================================
>>> --- cfe/trunk/lib/Lex/Lexer.cpp (original)
>>> +++ cfe/trunk/lib/Lex/Lexer.cpp Sat Apr  7 18:09:23 2012
>>> @@ -1597,7 +1597,9 @@
>>>     // them.
>>>     if (C != '_') {
>>>       if (!isLexingRawMode())
>>> -        Diag(CurPtr, diag::ext_reserved_user_defined_literal)
>>> +        Diag(CurPtr, getLangOpts().MicrosoftMode ?
>>> +            diag::ext_ms_reserved_user_defined_literal :
>>> +            diag::ext_reserved_user_defined_literal)
>>>           << FixItHint::CreateInsertion(getSourceLocation(CurPtr), " ");
>>>       return CurPtr;
>>>     }
>>> 
>>> Added: cfe/trunk/test/Lexer/ms-extensions.cpp
>>> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Lexer/ms-extensions.cpp?rev=154273&view=auto
>>> ==============================================================================
>>> --- cfe/trunk/test/Lexer/ms-extensions.cpp (added)
>>> +++ cfe/trunk/test/Lexer/ms-extensions.cpp Sat Apr  7 18:09:23 2012
>>> @@ -0,0 +1,6 @@
>>> +// RUN: %clang_cc1 -fsyntax-only -verify -Wreserved-user-defined-literal -fms-extensions -fms-compatibility %s
>>> +
>>> +#define bar(x) #x
>>> +const char * f() {
>>> +  return "foo"bar("bar")"baz";    /*expected-warning {{identifier after literal will be treated as a reserved user-defined literal suffix in C++11}} */
>>> +}
>>> 
>>> 
>>> _______________________________________________
>>> cfe-commits mailing list
>>> cfe-commits at cs.uiuc.edu
>>> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits
>> 





More information about the cfe-commits mailing list