[all-commits] [llvm/llvm-project] 705b99: Allow weak/selectany external definitions in heade...
akrieger via All-commits
all-commits at lists.llvm.org
Wed Oct 15 19:13:08 PDT 2025
Branch: refs/heads/main
Home: https://github.com/llvm/llvm-project
Commit: 705b99607c0c1aadc75fddef8738f22be206da25
https://github.com/llvm/llvm-project/commit/705b99607c0c1aadc75fddef8738f22be206da25
Author: akrieger <andrewskrieger at gmail.com>
Date: 2025-10-16 (Thu, 16 Oct 2025)
Changed paths:
M clang/lib/Sema/SemaDecl.cpp
M clang/test/CXX/module/module.import/p6.cpp
Log Message:
-----------
Allow weak/selectany external definitions in header units. (#162713)
weak and selectany are mechanisms for allowing the linker to resolve ODR
violations. [module.import/6] states
> A header unit shall not contain a definition of a non-inline function
or variable whose name has external linkage.
But this prevents compiling any headers with such weak symbols defined.
These occur in eg. some Windows SDK headers like `DirectXMath.h`.
```
#ifndef XMGLOBALCONST
#if defined(__GNUC__) && !defined(__MINGW32__)
#define XMGLOBALCONST extern const __attribute__((weak))
#else
#define XMGLOBALCONST extern const __declspec(selectany)
#endif
#endif
XMGLOBALCONST XMVECTORF32 g_XMSinCoefficients0 = { { { -0.16666667f, +0.0083333310f, -0.00019840874f, +2.7525562e-06f } } };
```
Proposed solution: Do not emit `diag::err_extern_def_in_header_unit` if
the `FD` or `VDecl` have either `SelectAnyAttr` or `WeakAttr`.
To unsubscribe from these emails, change your notification settings at https://github.com/llvm/llvm-project/settings/notifications
More information about the All-commits
mailing list