1 // RUN: %clang_cc1 -fsyntax-only -verify -std=c++2a %s -fexceptions -fcxx-exceptions -Wno-unevaluated-expression
3 void f(); // expected-note {{possible target for call}}
4 void f(int); // expected-note {{possible target for call}}
7 bool b
= noexcept(f
); // expected-error {{reference to overloaded function could not be resolved; did you mean to call it with no arguments?}}
8 bool b2
= noexcept(f(0));
12 void g(); // expected-note {{possible target for call}}
13 void g(int); // expected-note {{possible target for call}}
16 bool b
= noexcept(this->g
); // expected-error {{reference to non-static member function must be called; did you mean to call it with no arguments?}}
17 bool b2
= noexcept(this->g(0));
22 static_assert(noexcept(({ 0; })));
24 static_assert(!noexcept(({ throw 0; })));
26 static_assert(noexcept(({
34 static_assert(!noexcept(({
43 static_assert(!noexcept(({
51 static_assert(!noexcept(({
55 static_assert(noexcept(({
56 if constexpr (false) throw 0;
59 static_assert(!noexcept(({
60 if constexpr (false) throw 0; else throw 1;
63 static_assert(noexcept(({
64 if constexpr (true) 0; else throw 1;
69 static_assert(noexcept(static_cast<int(*)[true ? 41 : 42]>(0)), "");
70 // FIXME: This can't actually throw, but we conservatively assume any VLA
71 // type can throw for now.
72 static_assert(!noexcept(static_cast<int(*)[b
? 41 : 42]>(0)), "");
73 static_assert(!noexcept(static_cast<int(*)[b
? throw : 42]>(0)), "");
74 static_assert(!noexcept(reinterpret_cast<int(*)[b
? throw : 42]>(0)), "");
75 static_assert(!noexcept((int(*)[b
? throw : 42])0), "");
76 static_assert(!noexcept((int(*)[b
? throw : 42]){0}), "");
80 // expected-error@+1{{value of type 'void' is not implicitly convertible to 'bool'}}
81 void foo(void) const &noexcept(f());
85 const int *ptr
= nullptr;
86 void f() noexcept(sizeof(char[2])); // expected-error {{noexcept specifier argument evaluates to 2, which cannot be narrowed to type 'bool'}}
87 void g() noexcept(sizeof(char));
88 void h() noexcept(ptr
); // expected-error {{conversion from 'const int *' to 'bool' is not allowed in a converted constant expression}}
89 void i() noexcept(nullptr); // expected-error {{conversion from 'std::nullptr_t' to 'bool' is not allowed in a converted constant expression}}
92 void l() noexcept(2); // expected-error {{noexcept specifier argument evaluates to 2, which cannot be narrowed to type 'bool'}}