]> granicus.if.org Git - clang/commitdiff
ext_reserved_user_defined_literal must not default to Error in MicrosoftMode. Hence...
authorFrancois Pichet <pichet2000@gmail.com>
Sat, 7 Apr 2012 23:09:23 +0000 (23:09 +0000)
committerFrancois Pichet <pichet2000@gmail.com>
Sat, 7 Apr 2012 23:09:23 +0000 (23:09 +0000)
Fixes PR12383.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@154273 91177308-0d34-0410-b5e6-96231b3b80d8

include/clang/Basic/DiagnosticLexKinds.td
lib/Lex/Lexer.cpp
test/Lexer/ms-extensions.cpp [new file with mode: 0644]

index 26c0a20d2abf72328253b67a6ab6224ac18b4746..eb2cf10d505fb686dbb766d0e6e75a57d8da443e 100644 (file)
@@ -151,6 +151,9 @@ def warn_cxx11_compat_reserved_user_defined_literal : Warning<
 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<
index a49ab048f689f95faceccb941cbcc12041768be3..c817e3f10564c3e9daa906cd6b8fc8ef019bff67 100644 (file)
@@ -1597,7 +1597,9 @@ const char *Lexer::LexUDSuffix(Token &Result, const char *CurPtr) {
     // 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;
     }
diff --git a/test/Lexer/ms-extensions.cpp b/test/Lexer/ms-extensions.cpp
new file mode 100644 (file)
index 0000000..7e18a6c
--- /dev/null
@@ -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}} */
+}