> On Jan 3, 2021, at 11:33 PM, Hao Sun > <github.com+16932759+shqk...@openjdk.java.net> wrote: > > On Mon, 4 Jan 2021 01:18:47 GMT, Hao Sun > <github.com+16932759+shqk...@openjdk.org> wrote: > >>>> _Mailing list message from [Kim Barrett](mailto:kim.barr...@oracle.com) on >>>> [build-dev](mailto:build-dev@openjdk.java.net):_ >> >> It appears that either clang is different from gcc for -felide-constructors >> (which seems unlikely), or clang (clang-10) is doing the deprecation warning >> at a different point from gcc (quite plausible). That is, clang could be >> checking for the deprecated case before eliding the call, while gcc is >> checking for the deprecated case after copy elision has been applied. > > Thanks for your reply. > I checked the source code of clang-10 and gcc-9 and found that: > > 1) for clang-10, > 'Wdeprecated-copy' is implemented at the 'Sema' module of clang. See > https://github.com/llvm/llvm-project/blob/release/10.x/clang/lib/Sema/SemaDeclCXX.cpp#L13585 > > Flag 'felide-constructors' would enable 'felide_constructors' and flag > 'fno-elide-constructors' would enables 'fno_elide_constructors'. (See > https://github.com/llvm/llvm-project/blob/release/10.x/clang/include/clang/Driver/Options.td). > Then 'ElideConstructors' will be set (See > https://github.com/llvm/llvm-project/blob/release/10.x/clang/lib/Frontend/CompilerInvocation.cpp#L2863) > Finally, constructors might be elided in several spots in 'CodeGen' module. > See: > https://github.com/llvm/llvm-project/blob/release/10.x/clang/lib/CodeGen/CGStmt.cpp#L1094 > https://github.com/llvm/llvm-project/blob/release/10.x/clang/lib/CodeGen/CGExprCXX.cpp#L611 > https://github.com/llvm/llvm-project/blob/release/10.x/clang/lib/CodeGen/CGDecl.cpp#L1405 > > As far as I know, 'Sema' module is conducted to check semantics errors before > 'CodeGen' module. > That verified your conjecture, i.e. 'clang could be checking for the > derepcated case before eliding the call'. > > 2) for gcc-9, > 'felide-constructors' and 'Wdeprecated-copy' are implemented in a number of > spots in gcc. I currently didn't figure out their execution order clearly. > > But in one of the use points at function build_over_call(), > 'flag_elide_constructors' (See > https://github.com/gcc-mirror/gcc/blob/releases/gcc-9/gcc/cp/call.c#L8538) is > handled **before** 'warn_deprecated_copy' (See > https://github.com/gcc-mirror/gcc/blob/releases/gcc-9/gcc/cp/call.c#L8608 and > https://github.com/gcc-mirror/gcc/blob/releases/gcc-9/gcc/cp/call.c#L8679) > > Hope that my finding is helpful. Thanks.
Yes, that would explain the different warning behaviors. Thanks for digging through that.