aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFrancois Pichet <pichet2000@gmail.com>2012-04-07 23:09:23 +0000
committerFrancois Pichet <pichet2000@gmail.com>2012-04-07 23:09:23 +0000
commitb0afd5df3c427c329f6c5e00fe264c5bada3bf36 (patch)
tree839ff13c6195beba21911d5515a76bd3445f7c02
parent073a780f7cb863cd382d1c966ef11d05c6fad075 (diff)
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. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@154273 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--include/clang/Basic/DiagnosticLexKinds.td3
-rw-r--r--lib/Lex/Lexer.cpp4
-rw-r--r--test/Lexer/ms-extensions.cpp6
3 files changed, 12 insertions, 1 deletions
diff --git a/include/clang/Basic/DiagnosticLexKinds.td b/include/clang/Basic/DiagnosticLexKinds.td
index 26c0a20d2a..eb2cf10d50 100644
--- a/include/clang/Basic/DiagnosticLexKinds.td
+++ b/include/clang/Basic/DiagnosticLexKinds.td
@@ -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<
diff --git a/lib/Lex/Lexer.cpp b/lib/Lex/Lexer.cpp
index a49ab048f6..c817e3f105 100644
--- a/lib/Lex/Lexer.cpp
+++ b/lib/Lex/Lexer.cpp
@@ -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
index 0000000000..7e18a6cb2b
--- /dev/null
+++ b/test/Lexer/ms-extensions.cpp
@@ -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}} */
+}