]> granicus.if.org Git - clang/commit
Improve diagnostics if friend function redefines file-level function.
authorSerge Pavlov <sepavloff@gmail.com>
Thu, 8 Jun 2017 06:07:07 +0000 (06:07 +0000)
committerSerge Pavlov <sepavloff@gmail.com>
Thu, 8 Jun 2017 06:07:07 +0000 (06:07 +0000)
commit14318c6aa40d7c68c4341f43fbc3d0980f6d21a8
treef98d7810f8a68958e0beb977114940b73f245f9f
parent72683c83729e4da8e27a3dfa0526bf4aaad48418
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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@304964 91177308-0d34-0410-b5e6-96231b3b80d8
lib/Sema/SemaDeclCXX.cpp
test/CXX/dcl.dcl/dcl.spec/dcl.fct.spec/p4.cpp