This is an archive of the discontinued LLVM Phabricator instance.

[MSVC Compat] Warn when suppressing a trailing comma in macro args
Needs ReviewPublic

Authored by ehsan on Jan 22 2016, 7:47 PM.

Details

Reviewers
thakis
Summary

MSVC suppresses a trailing comma if no arguments are passed in place of
a variadic argument[1]. This patch adds a -Wmicrosoft warning when
accepting such code.

[1] https://msdn.microsoft.com/en-us/library/ms177415.aspx

Diff Detail

Event Timeline

ehsan updated this revision to Diff 45786.Jan 22 2016, 7:47 PM
ehsan retitled this revision from to [MSVC Compat] Warn when suppressing a trailing comma in macro args.
ehsan updated this object.
ehsan added a reviewer: thakis.
ehsan added a subscriber: cfe-commits.
thakis edited edge metadata.Feb 2 2016, 1:11 PM

Sorry for the slow response. I was reading http://reviews.llvm.org/D15670 to understand this patch, and I couldn't find anything in that patch that enables this extension only in Microsoft mode. Trying suppressed-comma-msextension.cpp locally, it seems to pass without -fms-compatibility too. Am I missing something, or does http://reviews.llvm.org/D15670 lack a check for MicrosoftExt?

Sorry for the slow response. I was reading http://reviews.llvm.org/D15670 to understand this patch, and I couldn't find anything in that patch that enables this extension only in Microsoft mode. Trying suppressed-comma-msextension.cpp locally, it seems to pass without -fms-compatibility too. Am I missing something, or does http://reviews.llvm.org/D15670 lack a check for MicrosoftExt?

Hmm, is the PP.getLangOpts().MSVCCompat check earlier in MaybeRemoveCommaBeforeVaArgs() insufficient?

(Note that this whole thing mostly builds on top of r167613 which was done by Andy, so it's possible that I needed to do something extra and I forgot that...)