<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 --- - macro string concatenation does not generate the expected result in an assembly macro"
href="https://llvm.org/bugs/show_bug.cgi?id=25506">25506</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>macro string concatenation does not generate the expected result in an assembly macro
</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>Linux
</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>-New Bugs
</td>
</tr>
<tr>
<th>Assignee</th>
<td>unassignedclangbugs@nondot.org
</td>
</tr>
<tr>
<th>Reporter</th>
<td>olivier@labapart.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>When the macro '#define CONCAT(a, b) CONCAT2(a, b)' is declared, Clang inserts
the space between ',' and 'b' in the result when this macro is used in an
assembly macro definition (ie: '.macro').
For instance the call CONCAT(a, b) in an assembly macro would generate the
string 'a b' instead of 'ab'.
This use case is actually present in newlib source code
(<a href="https://sourceware.org/newlib/">https://sourceware.org/newlib/</a>). GCC produces the expected result.
If I replace '#define CONCAT(a, b) CONCAT2(a, b)' by '#define CONCAT(a, b)
CONCAT2(a,b)' then the expected result is generated.
Here is the example:
----- hello.S -----
/* ANSI concatenation macros. */
#define CONCAT(a, b) CONCAT2(a, b)
#define CONCAT2(a, b) a##b
#ifndef __USER_LABEL_PREFIX__
#error __USER_LABEL_PREFIX__ not defined
#endif
#define SYM(x) CONCAT (__USER_LABEL_PREFIX__, x)
.text
.align
bl SYM(setjmp)
.macro FUNC_START name
.text
.align 2
.globl SYM (\name)
SYM (\name):
.endm
FUNC_START setjmp
bx lr
----------------------
$ clang-3.8 -target arm-none-eabi -c hello.S
<instantiation>:3:18: error: unexpected token in directive
.globl _ setjmp
^
hello.S:22:2: note: while in macro instantiation
FUNC_START setjmp
^
<instantiation>:4:9: error: unexpected token in argument list
_ setjmp:
^
hello.S:22:2: note: while in macro instantiation
FUNC_START setjmp
^</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>