Lines Matching full:constexpr
12 struct NonLiteral { // expected-note 3{{no constexpr constructors}}
17 constexpr Literal() {}
28 // The definition of a constexpr function shall satisfy the following
31 constexpr T();
32 constexpr int f() const;
35 virtual constexpr int ExplicitlyVirtual() const { return 0; } // expected-error {{virtual function cannot be constexpr}}
37 constexpr int ImplicitlyVirtual() const { return 0; } // expected-error {{virtual function cannot be constexpr}}
39 virtual constexpr int OutOfLineVirtual() const; // expected-error {{virtual function cannot be constexpr}}
42 constexpr NonLiteral NonLiteralReturn() const { return {}; } // expected-error {{constexpr function's return type 'NonLiteral' is not a literal type}}
43 constexpr void VoidReturn() const { return; }
45 // expected-error@-2 {{constexpr function's return type 'void' is not a literal type}}
47 constexpr ~T(); // expected-error {{destructor cannot be marked constexpr}}
49 constexpr F NonLiteralReturn2; // ok until definition
52 constexpr int NonLiteralParam(NonLiteral) const { return 0; } // expected-error {{constexpr function's 1st parameter type 'NonLiteral' is not a literal type}}
54 constexpr G NonLiteralParam2; // ok until definition
57 constexpr int Deleted() const = delete;
61 // destructor can be defaulted. Destructors can't be constexpr since they
63 // constexpr since they can't be const.
64 constexpr T &operator=(const T&) = default;
66 // expected-error@-2 {{an explicitly-defaulted copy assignment operator may not have 'const', 'constexpr' or 'volatile' qualifiers}}
69 // expected-error@-5 {{defaulted definition of copy assignment operator is not constexpr}}
73 constexpr int T::OutOfLineVirtual() const { return 0; }
77 constexpr T2 &operator=(const T2&) = default; // ok
80 constexpr T3 &operator=(const T3&) const = default;
85 constexpr U SelfReturn() const;
86 constexpr int SelfParam(U) const;
90 constexpr int F() const { return 0; } // expected-error {{constexpr member function not allowed in struct with virtual base class}}
94 constexpr int AllowedStmtsCXX11() {
121 constexpr int DisallowedStmtsCXX1Y_1() {
123 asm("int3"); // expected-error {{statement not allowed in constexpr function}}
126 constexpr int DisallowedStmtsCXX1Y_2() {
128 goto x; // expected-error {{statement not allowed in constexpr function}}
132 constexpr int DisallowedStmtsCXX1Y_3() {
134 try {} catch (...) {} // expected-error {{statement not allowed in constexpr function}}
137 constexpr int DisallowedStmtsCXX1Y_4() {
139 NonLiteral nl; // expected-error {{variable of non-literal type 'NonLiteral' cannot be defined in a constexpr function}}
142 constexpr int DisallowedStmtsCXX1Y_5() {
144 static constexpr int n = 123; // expected-error {{static variable not permitted in a constexpr function}}
147 constexpr int DisallowedStmtsCXX1Y_6() {
149 thread_local constexpr int n = 123; // expected-error {{thread_local variable not permitted in a constexpr function}}
152 constexpr int DisallowedStmtsCXX1Y_7() {
154 int n; // expected-error {{variables defined in a constexpr function must be initialized}}
158 constexpr int ForStmt() {
161 // expected-error@-2 {{statement not allowed in constexpr function}}
165 constexpr int VarDecl() {
168 // expected-error@-2 {{variable declaration in a constexpr function is a C++14 extension}}
172 constexpr int ConstexprVarDecl() {
173 constexpr int a = 0;
175 // expected-error@-2 {{variable declaration in a constexpr function is a C++14 extension}}
179 constexpr int VarWithCtorDecl() {
182 // expected-error@-2 {{variable declaration in a constexpr function is a C++14 extension}}
187 constexpr NonLiteral &ExternNonLiteralVarDecl() {
190 // expected-error@-2 {{variable declaration in a constexpr function is a C++14 extension}}
195 constexpr int FuncDecl() {
196 constexpr int ForwardDecl(int);
198 // expected-error@-2 {{use of this statement in a constexpr function is a C++14 extension}}
202 constexpr int ClassDecl1() {
205 // expected-error@-2 {{type definition in a constexpr function is a C++14 extension}}
209 constexpr int ClassDecl2() {
212 // expected-error@-2 {{type definition in a constexpr function is a C++14 extension}}
216 constexpr int ClassDecl3() {
219 // expected-error@-2 {{type definition in a constexpr function is a C++14 extension}}
223 constexpr int NoReturn() {} // expected-error {{no return statement in constexpr function}}
224 constexpr int MultiReturn() {
228 // expected-error@-2 {{multiple return statements in constexpr function}}
238 // a constexpr function must be able to produce a constant expression.
240 constexpr int f(int k) {
245 constexpr int f() { // expected-error {{constexpr function never produces a constant expression}}
267 constexpr int square(int x) {
270 constexpr long long_max() {
273 constexpr int abs(int x) {
281 constexpr int first(int n) {
285 constexpr int uninit() {
289 constexpr int prev(int x) {
296 constexpr int g(int x, int n) {