nss: upgrade to release 3.73
[LibreOffice.git] / compilerplugins / clang / test / noexceptmove.cxx
blobfda58deae403bbc3f86859eee54467a6aab7744a
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; fill-column: 100 -*- */
2 /*
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 */
9 #include "config_clang.h"
11 // clang before V9 does not have API to report exception spec type
12 #if CLANG_VERSION >= 90000
14 namespace test1
16 class Mapping
18 char* m_pMapping;
20 // expected-error@+1 {{move constructor can be noexcept [loplugin:noexceptmove]}}
21 Mapping(Mapping&& other)
22 : m_pMapping(other.m_pMapping)
24 other.m_pMapping = nullptr;
27 // expected-error@+1 {{move operator= can be noexcept [loplugin:noexceptmove]}}
28 Mapping& operator=(Mapping&& other)
30 m_pMapping = other.m_pMapping;
31 other.m_pMapping = nullptr;
32 return *this;
37 // No warning expected, because calling throwing function.
38 namespace test2
40 void foo() noexcept(false);
42 class Bar
44 Bar(Bar&&) { foo(); }
48 // no warning expected, because calling throwing constructor
49 namespace test3
51 struct Foo
53 Foo() noexcept(false);
55 class Bar
57 Bar(Bar&&) { Foo aFoo; }
60 class Bar2
62 Foo m_foo;
64 Bar2(Bar2&&) {}
68 // No warning expected, because calling throwing destructor.
69 namespace test4
71 struct Foo
73 ~Foo() noexcept(false);
76 class Bar
78 Bar(Bar&&) { Foo aFoo; }
82 // Check for calls to defaulted constructors.
83 namespace test5
85 struct Foo
87 Foo() = default; // non-throwing
89 class Bar
91 Bar(Bar&&) // expected-error {{move constructor can be noexcept [loplugin:noexceptmove]}}
93 Foo aFoo;
94 (void)aFoo;
99 #else
100 // expected-no-diagnostics
101 #endif // CLANG_VERSION
102 /* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */