Hi,

Please could someone review the attached patch for me before I commit it.

This patch fixes the rules surrounding the removal of a leading comma where a __VA_ARGS__ expansion is empty.

GCC has the extension, implemented already in clang for...

#define M(...) call(a, ## __VA_ARGS__)

This will expand to "call(a)" for "M()", removing the comma. However, under -std=c99, this behaviour changes so that the comma is not removed. The attached patch follows this behaviour when in c99 mode in clang. In gnu99 mode, it behaves as before, and similarly for pre-c99 dialects and for c++ (all checked against gcc's behaviour).

Also, Microsoft has a slight variation where "##" can (optionally) be omitted:

#define M(...) call(a, __VA_ARGS__)

The patch also implements this when using Microsoft-compatibility mode. Details on Microsoft's implementation is at http://msdn.microsoft.com/en-us/library/ms177415(v=vs.80).aspx. I believe this also closes out PR12845, which I came across after putting this patch together.

Thanks
Andy




Attachment: fix.diff
Description: Binary data

_______________________________________________
cfe-commits mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits

Reply via email to