[libcxx-commits] [PATCH] D65900: [libc++] Use [[nodiscard]] for lock_guard, as an extension
    Louis Dionne via Phabricator via libcxx-commits 
    libcxx-commits at lists.llvm.org
       
    Thu Aug  8 13:03:57 PDT 2019
    
    
  
ldionne marked an inline comment as done.
ldionne added inline comments.
================
Comment at: libcxx/include/__config:1016
+   // Standard specifies the constructor as [[nodiscard]]
+#  define _LIBCPP_NODISCARD_CTOR _LIBCPP_NODISCARD
+
----------------
xbolva00 wrote:
> EricWF wrote:
> > What happens when we apply this attribute to a constructor with a compiler that doesn't yet support it?
> > 
> > Does the warning escape the system header?
> If compiler returns >= 201907L, it have to support nodiscard on ctors.
> 
> Hopefully no compiler just bumps it to 201907L and does not support it.
> What happens when we apply this attribute to a constructor with a compiler that doesn't yet support it?
```
<stdin>:2:14: warning: attribute 'nodiscard' cannot be applied to functions without return value [-Wignored-attributes]
```
> Does the warning escape the system header?
No, which means we could just use `_LIBCPP_NODISCARD`/`_LIBCPP_NODISCARD_EXT` on the constructor and let the warning be captured inside the system header. That's what you had in mind to avoid introducing another macro, right? Would you prefer that?
Repository:
  rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D65900/new/
https://reviews.llvm.org/D65900
    
    
More information about the libcxx-commits
mailing list