<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 should warn on what appear to be buggy friend declarations"
href="https://bugs.llvm.org/show_bug.cgi?id=50648">50648</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>Clang should warn on what appear to be buggy friend declarations
</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>Frontend
</td>
</tr>
<tr>
<th>Assignee</th>
<td>unassignedclangbugs@nondot.org
</td>
</tr>
<tr>
<th>Reporter</th>
<td>rnk@google.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>Consider code like this:
<a href="https://gcc.godbolt.org/z/EEe8xWrzj">https://gcc.godbolt.org/z/EEe8xWrzj</a>
class Bar;
namespace foo {
class Foo {
friend class Bar; // forward declares ::foo::Bar
Foo();
int x;
};
}
class Bar {
Bar() {}
foo::Foo m; // error
};
It seems like clang should be able to warn and say, "hey, you probably say
`friend class ::Bar;`".
We accept this code in MSVC mode with a warning, so it shouldn't be too hard to
detect when we would do that and provide a warning in that case:
<a href="https://reviews.llvm.org/D4443">https://reviews.llvm.org/D4443</a>
See `bool FriendSawTagOutsideEnclosingNamespace` in SemaDecl.cpp.</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>