HomePhabricator

Improve diagnostics if friend function redefines file-level function.

Description

Improve diagnostics if friend function redefines file-level function.

Clang makes check for function redefinition after it merged the new
declaration with the existing one. As a result, it produces poor
diagnostics in the case of a friend function defined inline, as in
the code:

void func() {}
class C { friend void func() {} };

Error message in this case states that `inline declaration of 'func'
follows non-inline definition`, which is misleading, as func does
not have explicit inline specifier.

With this changes compiler reports function redefinition if the new
function is a friend defined inline and it does not have explicit
inline specifier.

Differential Revision: https://reviews.llvm.org/D26065

Details