dmpolukhin wrote:
@erichkeane the problem it diagnoses: for an inline namespace, Clang takes ABI
tags only from the *first* declaration and silently ignores tags added on a
reopening (GCC unions them). The realistic case is a user forward declaration
that comes before libstdc++:
```cpp
namespace std::filesystem { inline namespace __cxx11 { class path; } } // user
header, no tag
#include <filesystem> // libstdc++ declares: inline namespace __cxx11
__attribute__((__abi_tag__("cxx11")))
```
Clang then drops `cxx11` for the whole TU, so e.g. `current_path()` binds to
libstdc++'s old-ABI symbol: it links and crashes at run time. That's why the
warning is anchored at the first declaration: it's the line the user has to
fix, and the tag-adding declaration is usually in a system header where a
warning would be suppressed.
Agreed the text should say that directly. How about stating the rule and naming
the ignored tags (prototyped on the current head):
```
fwd.cpp:2:46: warning: ABI tag "cxx11" on a later declaration of inline
namespace '__cxx11' is ignored; this first declaration has no 'abi_tag'
[-Wabi-tag-redeclaration]
sys/bits/fs_fwd.h:3:41: note: later declaration of '__cxx11' is here
tags.cpp:1:36: warning: ABI tags "X", "Y" on a later declaration of inline
namespace 'v1' are ignored; only 'abi_tag("A", "B")' from this first
declaration is used [-Wabi-tag-redeclaration]
tags.cpp:2:36: note: later declaration of 'v1' is here
```
```tablegen
def warn_abi_tag_ignored : Warning<
"ABI %plural{1:tag|:tags}0 \"%1\" on a later declaration of inline namespace "
"%2 %plural{1:is|:are}0 ignored; %select{this first declaration has no "
"'abi_tag'|only 'abi_tag(\"%4\")' from this first declaration is used}3">,
InGroup<DiagGroup<"abi-tag-redeclaration">>;
def note_abi_tag_ignored_later : Note<"later declaration of %0 is here">;
```
https://github.com/llvm/llvm-project/pull/221039
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits