[MS] Silence -Wextern-init on const selectany variables
authorReid Kleckner <rnk@google.com>
Thu, 18 Aug 2016 18:45:07 +0000 (18:45 +0000)
committerReid Kleckner <rnk@google.com>
Thu, 18 Aug 2016 18:45:07 +0000 (18:45 +0000)
commit24c86990575fd7c780f944a60d345565208067b0
tree31eb2c3910d627209462456474457296b86b514f
parent0f85498a0b6cf1e4a4c8ce3d49b2f6f1a83c361e
[MS] Silence -Wextern-init on const selectany variables

In C, 'extern' is typically used to avoid tentative definitions when
declaring variables in headers, but adding an intializer makes it a
defintion. This is somewhat confusing, so GCC and Clang both warn on it.
In C++, 'extern' is often used to give implictly static 'const'
variables external linkage, so don't warn in that case. If selectany is
present, this might be header code intended for C and C++ inclusion, so
apply the C++ rules.

llvm-svn: 279116
clang/lib/Sema/SemaDecl.cpp
clang/test/Sema/attr-selectany.c [new file with mode: 0644]