[mlir][acc] Introduce MappableType interface (#122146)
[llvm-project.git] / clang / test / CXX / dcl.dcl / dcl.spec / dcl.constexpr / p8.cpp
blob428fd50b270faab178261e2b0f15171275413a5b
1 // RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s
3 using size_t = decltype(sizeof(int));
5 struct S {
6 constexpr int f(); // expected-warning {{C++14}}
7 constexpr int g() const;
8 constexpr int h(); // expected-warning {{C++14}}
9 int h();
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();
16 void f(const S &s) {
17 s.f();
18 s.g();
20 int (*Sf)() = &S::Sf;
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;
25 int (*ts)() = &S::ts;
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 {
39 class debug_flag {
40 public:
41 explicit debug_flag(bool);
42 constexpr bool is_on() const; // ok (dr1684)
43 private:
44 bool flag;
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();