1 // RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s
3 using size_t = decltype(sizeof(int));
6 constexpr int f(); // expected-warning {{C++14}}
7 constexpr int g() const;
8 constexpr int h(); // expected-warning {{C++14}}
10 static constexpr int Sf();
11 /*static*/ constexpr void *operator new(size_t) noexcept
;
12 template<typename T
> constexpr T
tm(); // expected-warning {{C++14}}
13 template<typename T
> static constexpr T
ts();
21 int (S::*f
)() const = &S::f
;
22 int (S::*g
)() const = &S::g
;
23 void *(*opNew
)(size_t) = &S::operator new;
24 int (S::*tm
)() const = &S::tm
;
28 constexpr int S::f() const { return 0; }
29 constexpr int S::g() { return 1; } // expected-warning {{C++14}}
30 constexpr int S::h() { return 0; } // expected-warning {{C++14}}
31 int S::h() { return 0; }
32 constexpr int S::Sf() { return 2; }
33 constexpr void *S::operator new(size_t) noexcept
{ return 0; }
34 template<typename T
> constexpr T
S::tm() { return T(); } // expected-warning {{C++14}}
35 template<typename T
> constexpr T
S::ts() { return T(); }
37 namespace std_example
{
41 explicit debug_flag(bool);
42 constexpr bool is_on() const; // ok (dr1684)
47 constexpr int bar(int x
, int y
) // expected-note {{here}}
48 { return x
+ y
+ x
*y
; }
49 int bar(int x
, int y
) // expected-error {{non-constexpr declaration of 'bar' follows constexpr declaration}}
50 { return x
* 2 + 3 * y
; }
54 // The constexpr specifier is allowed for static member functions of non-literal types.
55 class NonLiteralClass
{
56 NonLiteralClass(bool);
57 static constexpr bool isDebugFlag();