<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 error from macro for wrong line"
href="https://bugs.llvm.org/show_bug.cgi?id=44692">44692</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>clang reports error from macro for wrong line
</td>
</tr>
<tr>
<th>Product</th>
<td>clang
</td>
</tr>
<tr>
<th>Version</th>
<td>9.0
</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>schopf.dan@gmail.com
</td>
</tr>
<tr>
<th>CC</th>
<td>htmldeveloper@gmail.com, llvm-bugs@lists.llvm.org, neeilans@live.com, richard-llvm@metafoo.co.uk
</td>
</tr></table>
<p>
<div>
<pre>Compiling the attached code produces a misleading error message because the
indicated line is wrong.
Steps to reproduce:
1. Compile this code:
#define ALL_COMMANDS \
CMD(Play) \
CMD(Stop)
struct base {
virtual int Play() = 0;
};
struct foo : public base {
#define CMD(a) \
int a() override { \
return 0; \
}
ALL_COMMANDS
};
Actual result:
test.cpp:15:2: error: only virtual member functions can be marked 'override'
ALL_COMMANDS
^
test.cpp:2:11: note: expanded from macro 'ALL_COMMANDS'
CMD(Play) \
^
test.cpp:11:11: note: expanded from macro '\
CMD'
int a() override { \
^
1 error generated.
Expected result:
The actual error comes from line 3, which is CMD(Stop), and not line 2. This
can be very misleading when trying to fix the error.
This also happens with the latest trunk: <a href="https://godbolt.org/z/DUrFwo">https://godbolt.org/z/DUrFwo</a></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>