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

Francois Pichet pichet2000 at gmail.com
Sat Apr 7 16:09:23 PDT 2012


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}} */
+}





More information about the cfe-commits mailing list