<html>
<head>
<base href="https://bugs.llvm.org/">
</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 reports an wrong message when using a builtin function with address space"
href="https://bugs.llvm.org/show_bug.cgi?id=51289">51289</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>clang reports an wrong message when using a builtin function with address space
</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>Frontend
</td>
</tr>
<tr>
<th>Assignee</th>
<td>unassignedclangbugs@nondot.org
</td>
</tr>
<tr>
<th>Reporter</th>
<td>roninjiang@tencent.com
</td>
</tr>
<tr>
<th>CC</th>
<td>llvm-bugs@lists.llvm.org, neeilans@live.com, richard-llvm@metafoo.co.uk
</td>
</tr></table>
<p>
<div>
<pre>The address space is rarely used in other targets
so please add the following definition to include/clang/Basic/Builtins.def to
reproduce
BUILTIN(__builtin_copy_h2c, "vi*2i*1i*", "nc")
After compilation then we can run the following test:
#define AS1 __attribute__((address_space(1)))
#define AS2 __attribute__((address_space(2)))
void test(AS2 int* a, AS1 int* b) {
__builtin_copy_h2c(a, b, a);
}
with the command:
clang bug.cpp -fsyntax-only
The output of clang:
error: too many arguments to function call, expected 1, have 3; did you mean
'::__builtin_copy_h2c'?
bug.cpp:5:3: note: '::__builtin_copy_h2c' declared here
__builtin_copy_h2c(a, b, a);
^
1 error generated.
I think this message is not correct, because this builtin should expect 3
arguments.
I debuged this problem and found the root cause should be a bug in
clang/lib/Sema/SemaExpr.cpp around line 6266 (lastest main branch, in function
"rewriteBuiltinFunctionDecl").
6264 QualType PointeeType = ParamType->getPointeeType();
6265 if (PointeeType.hasAddressSpace())
6266 continue;
6267
I believe here missed a push_back before "continue", i.e.:
OverloadParams.push_back(ParamType);
Please help to confirm this bug.</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>