[PATCH] D95392: Restore GNU , ## __VA_ARGS__ behavior in MSVC mode too
Harald van Dijk via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Mon Jan 25 13:49:27 PST 2021
hvdijk created this revision.
hvdijk added a reviewer: rsmith.
hvdijk added a project: LLVM.
hvdijk requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.
As noted in D91913 <https://reviews.llvm.org/D91913>, MSVC implements the GNU behavior for , ## __VA_ARGS__ as well. Do the same when `-fms-compatibility` is used.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D95392
Files:
clang/lib/Lex/TokenLexer.cpp
clang/test/Preprocessor/macro_fn_comma_swallow2.c
Index: clang/test/Preprocessor/macro_fn_comma_swallow2.c
===================================================================
--- clang/test/Preprocessor/macro_fn_comma_swallow2.c
+++ clang/test/Preprocessor/macro_fn_comma_swallow2.c
@@ -9,6 +9,8 @@
// RUN: %clang_cc1 -E -x c++ -std=c++11 %s | FileCheck -check-prefix=C99 -strict-whitespace %s
// RUN: %clang_cc1 -E -std=gnu99 %s | FileCheck -check-prefix=GCC -strict-whitespace %s
// RUN: %clang_cc1 -E -fms-compatibility %s | FileCheck -check-prefix=MS -strict-whitespace %s
+// RUN: %clang_cc1 -E -x c++ -fms-compatibility %s | FileCheck -check-prefix=MS -strict-whitespace %s
+// RUN: %clang_cc1 -E -x c++ -std=c++11 -fms-compatibility %s | FileCheck -check-prefix=MS -strict-whitespace %s
// RUN: %clang_cc1 -E -DNAMED %s | FileCheck -check-prefix=GCC -strict-whitespace %s
// RUN: %clang_cc1 -E -std=c99 -DNAMED %s | FileCheck -check-prefix=C99 -strict-whitespace %s
Index: clang/lib/Lex/TokenLexer.cpp
===================================================================
--- clang/lib/Lex/TokenLexer.cpp
+++ clang/lib/Lex/TokenLexer.cpp
@@ -152,7 +152,8 @@
// named arguments, where it remains. With GNU extensions, it is removed
// regardless of named arguments.
// Microsoft also appears to support this extension, unofficially.
- if (!PP.getLangOpts().GNUMode && Macro->getNumParams() < 2)
+ if (!PP.getLangOpts().GNUMode && !PP.getLangOpts().MSVCCompat &&
+ Macro->getNumParams() < 2)
return false;
// Is a comma available to be removed?
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D95392.319103.patch
Type: text/x-patch
Size: 1532 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20210125/62d9a9f3/attachment.bin>
More information about the cfe-commits
mailing list