[libcxx-commits] [libcxx] r356632 - [libcxx] [test] Add (void) casts to operator new calls, to suppress warnings generated by [[nodiscard]].

Marshall Clow via libcxx-commits libcxx-commits at lists.llvm.org
Wed Mar 20 20:08:04 PDT 2019


On Wed, Mar 20, 2019 at 8:05 PM Billy Robert O'Neal III via libcxx-commits <
libcxx-commits at lists.llvm.org> wrote:

> Author: bion
> Date: Wed Mar 20 16:58:46 2019
> New Revision: 356632
>
> URL: http://llvm.org/viewvc/llvm-project?rev=356632&view=rev
> Log:
> [libcxx] [test] Add (void) casts to operator new calls, to suppress
> warnings generated by [[nodiscard]].
>
> This allows these tests to pass when compiled by MSVC++.
>
> Modified:
>
> libcxx/trunk/test/std/language.support/support.dynamic/new.delete/new.delete.array/new_size.sh.cpp
>
> libcxx/trunk/test/std/language.support/support.dynamic/new.delete/new.delete.array/new_size_align.sh.cpp
>
> libcxx/trunk/test/std/language.support/support.dynamic/new.delete/new.delete.array/new_size_align_nothrow.sh.cpp
>
> libcxx/trunk/test/std/language.support/support.dynamic/new.delete/new.delete.array/new_size_nothrow.sh.cpp
>
> libcxx/trunk/test/std/language.support/support.dynamic/new.delete/new.delete.single/new_size_align.sh.cpp
>
> libcxx/trunk/test/std/language.support/support.dynamic/new.delete/new.delete.single/new_size_align_nothrow.sh.cpp
>
> Modified:
> libcxx/trunk/test/std/language.support/support.dynamic/new.delete/new.delete.array/new_size.sh.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/language.support/support.dynamic/new.delete/new.delete.array/new_size.sh.cpp?rev=356632&r1=356631&r2=356632&view=diff
>
> ==============================================================================
> ---
> libcxx/trunk/test/std/language.support/support.dynamic/new.delete/new.delete.array/new_size.sh.cpp
> (original)
> +++
> libcxx/trunk/test/std/language.support/support.dynamic/new.delete/new.delete.array/new_size.sh.cpp
> Wed Mar 20 16:58:46 2019
> @@ -21,7 +21,7 @@
>
>  int main(int, char**)
>  {
> -    ::operator new[](4);  // expected-warning {{ignoring return value of
> function declared with 'nodiscard' attribute}}
> +    (void)::operator new[](4);
>

This is not an improvement.
Now these tests will pass whether or not the operator new has the
'nodiscard' attribute.
That was the point of this test.

-- Marshall
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/libcxx-commits/attachments/20190320/2c849f78/attachment.html>


More information about the libcxx-commits mailing list