<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 --- - Incorrect macro substitution sequence (1st part of the issue) and strange behaviour (2nd part of the issue)."
href="https://llvm.org/bugs/show_bug.cgi?id=25052">25052</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>Incorrect macro substitution sequence (1st part of the issue) and strange behaviour (2nd part of the issue).
</td>
</tr>
<tr>
<th>Product</th>
<td>clang
</td>
</tr>
<tr>
<th>Version</th>
<td>3.7
</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>Frontend
</td>
</tr>
<tr>
<th>Assignee</th>
<td>unassignedclangbugs@nondot.org
</td>
</tr>
<tr>
<th>Reporter</th>
<td>anton.kochkov@gmail.com
</td>
</tr>
<tr>
<th>CC</th>
<td>llvm-bugs@lists.llvm.org
</td>
</tr>
<tr>
<th>Classification</th>
<td>Unclassified
</td>
</tr></table>
<p>
<div>
<pre>CLang is used as a toolset under MSVC2012, name of the toolset is
"LLVM-vs2012".
Code is compiled under MSVC2012 native toolset ("Visual Studio 2012 (v110)")
perfectly and without an error or a warning.
**** COMMAND LINE: clang-cl.exe
/RTCc /Yu"PCH.h" /GS /analyze- /W4 /Gy /Zc:wchar_t /ZI /Gm /Od
/Fd"[...]/LibCPP.lib\vc110.pdb" /fp:precise /D "WIN32" /D "_DEBUG" /D "_LIB" /D
"_MBCS" /errorReport:prompt /GF /WX- /Zc:forScope /RTC1 /GR /Gd /Oy- /MDd
/Fa"[...]/LibCPP.lib\" /EHsc /nologo /Fo"[...]/LibCPP.lib\"
/Fp"[...]/LibCPP.lib\LibCPP.lib.pch"
**** ERROR MESSAGE (1):
In file included from [..]/BitMap.cxx:3:
In file included from [..]/Main.h:4:
In file included from [..]/LibCPP.h:37:
[..]/TPair.hxx(26,55): error : too many arguments provided to function-like
macro invocation
{ DBG_METHOD_CONSTRUCTOR( LibCPP::TPair<T1 COMMA T2>, TPair );
^
[..]/Defs.h(288,61) : note: expanded from macro 'DBG_METHOD_CONSTRUCTOR'
#define DBG_METHOD_CONSTRUCTOR(cls, fn)
DBG_METHOD(cls, fn)
^
[..]/Defs.h(274,10) : note: macro 'DBG_METHOD' defined here
# define DBG_METHOD(cls, fn) \
^
**** RELATED DEFINITIONS (1):
#define COMMA COMMA1
#define COMMA1 COMMA2
#define COMMA2 COMMA3
#define COMMA3 ,
# define _DbgPerfMonStatisticsDeclaration( cls, fn ) \
LibCPP::PerfMonInvocationPause __invk_pause_fn__;\
static LibCPP::PerfMonFunction __fn__( /*__FUNCTION_SIGNATURE__*/#cls,
#fn );
# define DBG_METHOD(cls, fn) \
_DbgPerfMonStatisticsDeclaration( cls, fn );\
DEBUG_MEM_CHECK();\
DBG_ASSERT( nullptr != this );\
DBG_PRINT_FUNCTION_NAME( "In " #cls "." #fn );\
_DbgPerfMonStatistics()
#define DBG_METHOD_CONSTRUCTOR(cls, fn) \
DBG_METHOD(cls, fn)
template<typename T1, typename T2>
inline
LibCPP::TPair<T1, T2>::TPair()
{ DBG_METHOD_CONSTRUCTOR( LibCPP::TPair<T1 COMMA T2>, TPair );
}
**** ISSUE (continued)
OK, let's follow the message and replace the DBG_METHOD_CONSTRUCTOR macro
(taking two arguments) with DBG_METHOD_CONSTRUCTOR2 macro (taking three
arguments). However, this doesn't help. When the DBG_METHOD_CONSTRUCTOR macro
is replaced with DBG_METHOD_CONSTRUCTOR2 macro, the exactly contrary error is
generated (previously there were too many arguments, now it's too few). It's
not clear how the compiler processes the COMMA macro invocation and how does
the compiler substitute it inside the macro argument list.
It would be preferrable to have the compiler translate the macro invocations in
such a way that only one set of DBG_METHOD is used, with no need in
DBG_METHOD2, 3, 4, etc.
**** ERROR MESSAGE (2):
In file included from [...]/BitMap.cxx:3:
In file included from [...]/Main.h:4:
In file included from [...]/LibCPP.h:37:
[...]/TPair.hxx(26,62): error : too few arguments provided to function-like
macro invocation
{ DBG_METHOD_CONSTRUCTOR2( LibCPP::TPair<T1 COMMA T2>, TPair );
^
[...]/Defs.h(289,9) : note: macro 'DBG_METHOD_CONSTRUCTOR2' defined here
#define DBG_METHOD_CONSTRUCTOR2(cls1, cls2, fn)
DBG_METHOD2(cls1, cls2, fn)
^
**** RELATED DEFINITIONS (2):
#define COMMA COMMA1
#define COMMA1 COMMA2
#define COMMA2 COMMA3
#define COMMA3 ,
# define _DbgPerfMonStatisticsDeclaration2( cls1, cls2, fn ) \
LibCPP::PerfMonInvocationPause __invk_pause_fn__;\
static LibCPP::PerfMonFunction __fn__( /*__FUNCTION_SIGNATURE__*/#cls1
"," #cls2, #fn );
# define DBG_METHOD2(cls1, cls2, fn) \
_DbgPerfMonStatisticsDeclaration2( cls1, cls2, fn );\
DEBUG_MEM_CHECK();\
DBG_ASSERT( nullptr != this );\
DBG_PRINT_FUNCTION_NAME( "In " #cls1 "," #cls2 "." #fn );\
_DbgPerfMonStatistics()
#define DBG_METHOD_CONSTRUCTOR2(cls1, cls2, fn) DBG_METHOD2(cls1,
cls2, fn)
template<typename T1, typename T2>
inline
LibCPP::TPair<T1, T2>::TPair()
{ DBG_METHOD_CONSTRUCTOR2( LibCPP::TPair<T1 COMMA T2>, TPair );
}
**** EBD OF MESSAGE</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>