Index: include/clang/Basic/DiagnosticGroups.td =================================================================== --- include/clang/Basic/DiagnosticGroups.td +++ include/clang/Basic/DiagnosticGroups.td @@ -769,6 +769,7 @@ def MicrosoftAnonTag : DiagGroup<"microsoft-anon-tag">; def MicrosoftCommentPaste : DiagGroup<"microsoft-comment-paste">; def MicrosoftEndOfFile : DiagGroup<"microsoft-end-of-file">; +def MicrosoftElidedMacroArgument : DiagGroup<"microsoft-elided-macro-argument">; // Aliases. def : DiagGroup<"msvc-include", [MicrosoftInclude]>; // -Wmsvc-include = -Wmicrosoft-include @@ -783,7 +784,7 @@ MicrosoftRedeclareStatic, MicrosoftEnumForwardReference, MicrosoftGoto, MicrosoftFlexibleArray, MicrosoftExtraQualification, MicrosoftCast, MicrosoftConstInit, MicrosoftVoidPseudoDtor, MicrosoftAnonTag, - MicrosoftCommentPaste, MicrosoftEndOfFile]>; + MicrosoftCommentPaste, MicrosoftEndOfFile, MicrosoftElidedMacroArgument]>; def ObjCNonUnifiedException : DiagGroup<"objc-nonunified-exceptions">; Index: include/clang/Basic/DiagnosticLexKinds.td =================================================================== --- include/clang/Basic/DiagnosticLexKinds.td +++ include/clang/Basic/DiagnosticLexKinds.td @@ -65,6 +65,10 @@ def ext_ctrl_z_eof_microsoft : Extension< "treating Ctrl-Z as end-of-file is a Microsoft extension">, InGroup; +def ext_elided_macro_argument_microsoft: Extension< + "suppressing trailing comma when not specifying any macro variadic " + "arguments is a Microsoft extension">, + InGroup; def ext_token_used : Extension<"extension used">, InGroup>; Index: lib/Lex/TokenLexer.cpp =================================================================== --- lib/Lex/TokenLexer.cpp +++ lib/Lex/TokenLexer.cpp @@ -150,6 +150,9 @@ // Issue an extension diagnostic for the paste operator. if (HasPasteOperator) PP.Diag(ResultToks.back().getLocation(), diag::ext_paste_comma); + else + // Issue an extension diagnostic for the suppressed trailing comma. + PP.Diag(ResultToks.back().getLocation(), diag::ext_elided_macro_argument_microsoft); // Remove the comma. ResultToks.pop_back(); Index: test/Preprocessor/microsoft-ext.c =================================================================== --- test/Preprocessor/microsoft-ext.c +++ test/Preprocessor/microsoft-ext.c @@ -34,12 +34,3 @@ MAKE_FUNC(MAK, ER, int a, _COMMA, int b); // CHECK: void func(int a , int b) {} - -#define macro(a, b) (a - b) -void function(int a); -#define COMMA_ELIDER(...) \ - macro(x, __VA_ARGS__); \ - function(x, __VA_ARGS__); -COMMA_ELIDER(); -// CHECK: (x - ); -// CHECK: function(x); Index: test/Preprocessor/suppressed-comma-msextension.cpp =================================================================== --- /dev/null +++ test/Preprocessor/suppressed-comma-msextension.cpp @@ -0,0 +1,15 @@ +// RUN: %clang_cc1 -verify -fms-compatibility -Wmicrosoft %s +// RUN: %clang_cc1 -P -E -fms-compatibility %s | FileCheck %s + +void function(int a); +#define macro(a, b) function(b - a) +#define COMMA_ELIDER(...) \ + macro(x, __VA_ARGS__); \ + function(x, __VA_ARGS__); +// expected-warning@-2 {{suppressing trailing comma when not specifying any macro variadic arguments is a Microsoft extension}} +// expected-warning@-2 {{suppressing trailing comma when not specifying any macro variadic arguments is a Microsoft extension}} +void func() { +int x; +COMMA_ELIDER() +// CHECK: function( - x); function(x); +}