Description
Bugzilla Link | 12845 |
Resolution | FIXED |
Resolved on | May 17, 2018 09:16 |
Version | trunk |
OS | Windows NT |
Blocks | llvm/llvm-bugzilla-archive#13707 |
Reporter | LLVM Bugzilla Contributor |
CC | @DougGregor,@efriedma-quic,@tritao,@nico |
Extended Description
When passing a single argument to a macro which defines a function with a variable arguments list as its' second argument, Clang will incorrectly preprocess such code, leaving the unnecessary comma after the first argument, thus making the resulting code uncompilable. Consider the example:
bool MsgAlert(bool yes_no, int Style, const char* format, ...)
{return true;}
#define PanicAlert(format, ...) MsgAlert(false, 1, format, VA_ARGS)
void func()
{PanicAlert("text");}
Clang preprocessor (the -E flag, in MS compatibility mode) will generate the following (note the excessive comma after "text"):
void func()
{MsgAlert(false, 1, "text", );}
In comparison, the MSVC preprocessor (cl.exe) will generate the correct code:
void func()
{MsgAlert(false, 1, "text" );}