[libc-commits] [libc] [libc] Add _Returns_twice to C++ code (PR #153602)
William Huynh via libc-commits
libc-commits at lists.llvm.org
Fri Aug 15 02:10:00 PDT 2025
================
@@ -47,6 +47,9 @@
#define __NOEXCEPT throw()
#endif
+#undef _Returns_twice
+#define _Returns_twice [[gnu::returns_twice]]
+
----------------
saturn691 wrote:
1. `returns_twice` needs to be namespaced (https://en.cppreference.com/w/cpp/language/attributes.html)
```
❯ clang test.c
test.c:3:3: warning: unknown attribute 'returns_twice' ignored [-Wunknown-attributes]
3 | [[returns_twice]] int f() {
| ^~~~~~~~~~~~~
1 warning generated.
```
2. `[[attribute]]` syntax is only supported in C++11. It seems to compile for older versions and this has even been back-ported to C code in clang. I'll push an update to unify this.
https://github.com/llvm/llvm-project/pull/153602
More information about the libc-commits
mailing list