[llvm-bugs] [Bug 50648] New: Clang should warn on what appear to be buggy friend declarations
via llvm-bugs
llvm-bugs at lists.llvm.org
Wed Jun 9 15:57:09 PDT 2021
https://bugs.llvm.org/show_bug.cgi?id=50648
Bug ID: 50648
Summary: Clang should warn on what appear to be buggy friend
declarations
Product: clang
Version: unspecified
Hardware: PC
OS: All
Status: NEW
Severity: enhancement
Priority: P
Component: Frontend
Assignee: unassignedclangbugs at nondot.org
Reporter: rnk at google.com
CC: llvm-bugs at lists.llvm.org, neeilans at live.com,
richard-llvm at metafoo.co.uk
Consider code like this:
https://gcc.godbolt.org/z/EEe8xWrzj
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:
https://reviews.llvm.org/D4443
See `bool FriendSawTagOutsideEnclosingNamespace` in SemaDecl.cpp.
--
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20210609/dafe9f27/attachment-0001.html>
More information about the llvm-bugs
mailing list