<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 - Poor diagnostics when accidentally using an #include in a macro"
href="https://bugs.llvm.org/show_bug.cgi?id=40713">40713</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>Poor diagnostics when accidentally using an #include in a macro
</td>
</tr>
<tr>
<th>Product</th>
<td>clang
</td>
</tr>
<tr>
<th>Version</th>
<td>unspecified
</td>
</tr>
<tr>
<th>Hardware</th>
<td>PC
</td>
</tr>
<tr>
<th>OS</th>
<td>All
</td>
</tr>
<tr>
<th>Status</th>
<td>NEW
</td>
</tr>
<tr>
<th>Severity</th>
<td>enhancement
</td>
</tr>
<tr>
<th>Priority</th>
<td>P
</td>
</tr>
<tr>
<th>Component</th>
<td>C++
</td>
</tr>
<tr>
<th>Assignee</th>
<td>unassignedclangbugs@nondot.org
</td>
</tr>
<tr>
<th>Reporter</th>
<td>nicolasweber@gmx.de
</td>
</tr>
<tr>
<th>CC</th>
<td>blitzrakete@gmail.com, dgregor@apple.com, erik.pilkington@gmail.com, llvm-bugs@lists.llvm.org, richard-llvm@metafoo.co.uk
</td>
</tr></table>
<p>
<div>
<pre>I ran into this problem today:
$ cat test.cc
#define DECLARE_CONTEXTUAL_VARIABLE(a, b) /* ... */
DECLARE_CONTEXTUAL_VARIABLE(a, 1; // Missing a ')'!
DECLARE_CONTEXTUAL_VARIABLE(b, 1);
DECLARE_CONTEXTUAL_VARIABLE(c, 1);
DECLARE_CONTEXTUAL_VARIABLE(d, 1);
#include "a.h"
#include "b.h"
#include "c.h"
#include "d.h"
#include "e.h"
#include "f.h"
#include "g.h"
#include "h.h"
#include "i.h"
#include "j.h"
#include "k.h"
#include "l.h"
#include "m.h"
#include "n.h"
#include "o.h"
#include "p.h"
#include "q.h"
#include "r.h"
#include "s.h"
Nicos-MacBook-Pro:llvm-project thakis$ clang -c test.cc
test.cc:9:2: error: embedding a #include directive within macro arguments is
not supported
#include "a.h"
^
test.cc:10:2: error: embedding a #include directive within macro arguments is
not supported
#include "b.h"
^
test.cc:11:2: error: embedding a #include directive within macro arguments is
not supported
#include "c.h"
^
test.cc:12:2: error: embedding a #include directive within macro arguments is
not supported
#include "d.h"
^
test.cc:13:2: error: embedding a #include directive within macro arguments is
not supported
#include "e.h"
^
test.cc:14:2: error: embedding a #include directive within macro arguments is
not supported
#include "f.h"
^
test.cc:15:2: error: embedding a #include directive within macro arguments is
not supported
#include "g.h"
^
test.cc:16:2: error: embedding a #include directive within macro arguments is
not supported
#include "h.h"
^
test.cc:17:2: error: embedding a #include directive within macro arguments is
not supported
#include "i.h"
^
test.cc:18:2: error: embedding a #include directive within macro arguments is
not supported
#include "j.h"
^
test.cc:19:2: error: embedding a #include directive within macro arguments is
not supported
#include "k.h"
^
test.cc:20:2: error: embedding a #include directive within macro arguments is
not supported
#include "l.h"
^
test.cc:21:2: error: embedding a #include directive within macro arguments is
not supported
#include "m.h"
^
test.cc:22:2: error: embedding a #include directive within macro arguments is
not supported
#include "n.h"
^
test.cc:23:2: error: embedding a #include directive within macro arguments is
not supported
#include "o.h"
^
test.cc:24:2: error: embedding a #include directive within macro arguments is
not supported
#include "p.h"
^
test.cc:25:2: error: embedding a #include directive within macro arguments is
not supported
#include "q.h"
^
test.cc:26:2: error: embedding a #include directive within macro arguments is
not supported
#include "r.h"
^
test.cc:27:2: error: embedding a #include directive within macro arguments is
not supported
#include "s.h"
^
fatal error: too many errors emitted, stopping now [-ferror-limit=]
20 errors generated.
This was in a large file and from the errors it was not at all clear where the
missing ) was. I ended up locally patching up clang, since I didn't think of
increasing -ferror-limit to an astronomical number (now that I know what the
problem was I realize that eventually a
test.cc:4:1: error: unterminated function-like macro invocation
DECLARE_CONTEXTUAL_VARIABLE(a, 1; // Missing a ')'!
^
test.cc:1:9: note: macro 'DECLARE_CONTEXTUAL_VARIABLE' defined here
#define DECLARE_CONTEXTUAL_VARIABLE(a, b) /* ... */
diag will appear, but that was cut off in my case.)
I think it'd be good if clang could print a note pointing to the active macro
call with the "embedding..." diag. I'll make a patch for that.</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>