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: [email protected]
          Reporter: [email protected]
                CC: [email protected], [email protected],
                    [email protected]

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.
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to