<html>
<head>
<base href="https://llvm.org/bugs/" />
</head>
<body><table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Bug ID</th>
<td><a class="bz_bug_link
bz_status_NEW "
title="NEW --- - Another clang-cl preprocessor error in expansion where VC++ works"
href="https://llvm.org/bugs/show_bug.cgi?id=27382">27382</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>Another clang-cl preprocessor error in expansion where VC++ works
</td>
</tr>
<tr>
<th>Product</th>
<td>clang
</td>
</tr>
<tr>
<th>Version</th>
<td>trunk
</td>
</tr>
<tr>
<th>Hardware</th>
<td>PC
</td>
</tr>
<tr>
<th>OS</th>
<td>Windows NT
</td>
</tr>
<tr>
<th>Status</th>
<td>NEW
</td>
</tr>
<tr>
<th>Severity</th>
<td>normal
</td>
</tr>
<tr>
<th>Priority</th>
<td>P
</td>
</tr>
<tr>
<th>Component</th>
<td>C++
</td>
</tr>
<tr>
<th>Assignee</th>
<td>unassignedclangbugs@nondot.org
</td>
</tr>
<tr>
<th>Reporter</th>
<td>eldlistmailingz@tropicsoft.com
</td>
</tr>
<tr>
<th>CC</th>
<td>dgregor@apple.com, llvm-bugs@lists.llvm.org
</td>
</tr>
<tr>
<th>Classification</th>
<td>Unclassified
</td>
</tr></table>
<p>
<div>
<pre>This bug report illustrates another clang-cl preprocessor error where VC++
compiles without any error, found when testing the Boost preprocessor library.
The code is a simplified version of the Boost PP problem when compiling with
clang-cl:
#define TEST_EXPAND(x) TEST_EXPAND_I(x)
#define TEST_EXPAND_I(x) x
#define TEST_REM(...) __VA_ARGS__
#define TEST_CAT(a, b) TEST_CAT_I(a, b)
#define TEST_CAT_I(a, b) a ## b
#define TEST_ELEM(n, ...) TEST_ELEM_I(n,__VA_ARGS__)
#define TEST_ELEM_I(n, ...) TEST_CAT(TEST_CAT(TEST_ELEM_, n)(__VA_ARGS__,),)
#define TEST_ELEM_0(e0, ...) e0
#define TEST_ELEM_1(e0, e1, ...) e1
#define TEST_MACRO(x,y) TEST_ELEM(x, TEST_EXPAND(TEST_REM y))
int main()
{
int x = TEST_MACRO(1,(1,0));
return x;
}
------------------------------------------------------------------------------
When compiled with clang-cl the result is:
test_clang2.cpp(17,29): error: too many arguments provided to function-like
macro invocation
int x = TEST_MACRO(1,(1,0));
^
test_clang2.cpp(2,9): note: macro 'TEST_EXPAND_I' defined here
#define TEST_EXPAND_I(x) x
^
test_clang2.cpp(17,32): error: expected expression
int x = TEST_MACRO(1,(1,0));
------------------------------------------------------------------------------
VC++ compiles the above without error.
The command line options for clang-cl are:
-TP /Od /Ob0 /W3 /GR /MDd /Zc:forScope /Zc:wchar_t -fmsc-version=1900 /wd4675
/EHs -fmacro-backtrace-limit=0 -Wno-invalid-token-paste -c
The command line options for the successful VC++ compile are:
/Zm800 -TP /Z7 /Od /Ob0 /W4 /GR /MDd /Zc:forScope /Zc:wchar_t /wd4675 /EHs -c</pre>
</div>
</p>
<hr>
<span>You are receiving this mail because:</span>
<ul>
<li>You are on the CC list for the bug.</li>
</ul>
</body>
</html>