From: Francois Pichet Date: Sat, 7 Apr 2012 23:09:23 +0000 (+0000) Subject: ext_reserved_user_defined_literal must not default to Error in MicrosoftMode. Hence... X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=b0afd5df3c427c329f6c5e00fe264c5bada3bf36;p=clang 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 --- 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, DefaultError; +def ext_ms_reserved_user_defined_literal : ExtWarn< + "invalid suffix on literal; C++11 requires a space between literal and " + "identifier">, InGroup; 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}} */ +}