[llvm-bugs] [Bug 25052] New: Incorrect macro substitution sequence (1st part of the issue) and strange behaviour (2nd part of the issue).
via llvm-bugs
llvm-bugs at lists.llvm.org
Mon Oct 5 05:26:44 PDT 2015
https://llvm.org/bugs/show_bug.cgi?id=25052
Bug ID: 25052
Summary: Incorrect macro substitution sequence (1st part of the
issue) and strange behaviour (2nd part of the issue).
Product: clang
Version: 3.7
Hardware: PC
OS: Windows NT
Status: NEW
Severity: normal
Priority: P
Component: Frontend
Assignee: unassignedclangbugs at nondot.org
Reporter: anton.kochkov at gmail.com
CC: llvm-bugs at lists.llvm.org
Classification: Unclassified
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
--
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20151005/6cef108a/attachment-0001.html>
More information about the llvm-bugs
mailing list