Skip to content

Commit b43c26d

Browse files
committed
Restore GNU , ## __VA_ARGS__ behavior in MSVC mode
As noted in D91913, MSVC implements the GNU behavior for , ## __VA_ARGS__ as well. Do the same when `-fms-compatibility` is used. Reviewed By: rsmith Differential Revision: https://reviews.llvm.org/D95392
1 parent 1fba217 commit b43c26d

File tree

2 files changed

+4
-1
lines changed

2 files changed

+4
-1
lines changed

clang/lib/Lex/TokenLexer.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,8 @@ bool TokenLexer::MaybeRemoveCommaBeforeVaArgs(
152152
// named arguments, where it remains. With GNU extensions, it is removed
153153
// regardless of named arguments.
154154
// Microsoft also appears to support this extension, unofficially.
155-
if (!PP.getLangOpts().GNUMode && Macro->getNumParams() < 2)
155+
if (!PP.getLangOpts().GNUMode && !PP.getLangOpts().MSVCCompat &&
156+
Macro->getNumParams() < 2)
156157
return false;
157158

158159
// Is a comma available to be removed?

clang/test/Preprocessor/macro_fn_comma_swallow2.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@
99
// RUN: %clang_cc1 -E -x c++ -std=c++11 %s | FileCheck -check-prefix=C99 -strict-whitespace %s
1010
// RUN: %clang_cc1 -E -std=gnu99 %s | FileCheck -check-prefix=GCC -strict-whitespace %s
1111
// RUN: %clang_cc1 -E -fms-compatibility %s | FileCheck -check-prefix=MS -strict-whitespace %s
12+
// RUN: %clang_cc1 -E -x c++ -fms-compatibility %s | FileCheck -check-prefix=MS -strict-whitespace %s
13+
// RUN: %clang_cc1 -E -x c++ -std=c++11 -fms-compatibility %s | FileCheck -check-prefix=MS -strict-whitespace %s
1214
// RUN: %clang_cc1 -E -DNAMED %s | FileCheck -check-prefix=GCC -strict-whitespace %s
1315
// RUN: %clang_cc1 -E -std=c99 -DNAMED %s | FileCheck -check-prefix=C99 -strict-whitespace %s
1416

0 commit comments

Comments
 (0)