<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 --- - clang-cl preprocessor error where VC++ works"
href="https://llvm.org/bugs/show_bug.cgi?id=27380">27380</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>clang-cl preprocessor error 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>The following code compiles without error using VC++ 14 but gives errors using
the latest clang-cl from the 'trunk':
#define TEST_MACRO(x,y) TEST_EXPAND(2, 0, TEST_SOMETHING(x,y,1))
#define TEST_SOMETHING(x,y,z) 2
#define TEST_EXPAND(...) TEST_EXPAND_I(TEST_OVR(TEST_NAME, __VA_ARGS__),
(__VA_ARGS__))
#define TEST_OVR(name,...) TEST_SOMENAME
#define TEST_EXPAND_I(m, args) TEST_EXPAND_II(m, args)
#define TEST_EXPAND_II(m, args) TEST_CAT(m ## args,)
#define TEST_SOMENAME(x,y,z) ;
#define TEST_CAT(a, b) TEST_CAT_I(a, b)
#define TEST_CAT_I(a, b) TEST_CAT_II(~, a ## b)
#define TEST_CAT_II(p, res) res
int main()
{
TEST_MACRO(1,2)
}
---------------------------------------------------------------------------
The clang errors are:
test_clang.cpp(17,2): error: pasting formed 'TEST_SOMENAME(', an invalid
preprocessing token [-Winvalid-token-paste]
TEST_MACRO(1,2)
^
test_clang.cpp(2,25): note: expanded from macro 'TEST_MACRO'
#define TEST_MACRO(x,y) TEST_EXPAND(2, 0, TEST_SOMETHING(x,y,1))
^
test_clang.cpp(5,26): note: expanded from macro 'TEST_EXPAND'
#define TEST_EXPAND(...) TEST_EXPAND_I(TEST_OVR(TEST_NAME, __VA_ARGS__),
(__VA_ARGS__))
^
test_clang.cpp(7,32): note: expanded from macro 'TEST_EXPAND_I'
#define TEST_EXPAND_I(m, args) TEST_EXPAND_II(m, args)
^
test_clang.cpp(8,44): note: expanded from macro 'TEST_EXPAND_II'
#define TEST_EXPAND_II(m, args) TEST_CAT(m ## args,)
----------------------------------------------------------------------------
The clang-cl options are:
-TP /Od /Ob0 /W3 /GR /MDd /Zc:forScope /Zc:wchar_t -fmsc-version=1900 /wd4675
/EHs -fmacro-backtrace-limit=0 -c
-----------------------------------------------------------------------------
The VC++14 options when compiling successfully are:
/Zm800 -TP /Z7 /Od /Ob0 /W4 /GR /MDd /Zc:forScope /Zc:wchar_t /wd4675 /EHs -c
---------------------------------------------------------------------------
This example is a simplified version of a failure which occurs when running the
Boost Preprocessor library tests with clang-cl, where the Boost Preprocessor
library is setup to use the exact same workarounds for clang-cl as it does for
VC++, since neither is a C++ standard conforming preprocessor.
A possible fix for this problem is not a change in the code above, even if some
specific change in the code will get clang-cl to work. If clang-cl is truly
emulating the non-standard VC++ preprocessor it must be able to compile
preprocessor code which VC++ also compiles without errors. Thus I am reporting
this problem here.</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>