Home | History | Annotate | Download | only in dcl.constexpr
      1 // RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s
      2 
      3 struct S {
      4   constexpr int f();
      5   constexpr int g() const;
      6   static constexpr int Sf();
      7 };
      8 
      9 void f(const S &s) {
     10   s.f();
     11   s.g();
     12 
     13   int (*f)() = &S::Sf;
     14   int (S::*g)() const = &S::g;
     15 }
     16 
     17 namespace std_example {
     18 
     19   class debug_flag { // expected-note {{not an aggregate and has no constexpr constructors}}
     20   public:
     21     explicit debug_flag(bool);
     22     constexpr bool is_on(); // expected-error {{non-literal type 'std_example::debug_flag' cannot have constexpr members}}
     23   private:
     24     bool flag;
     25   };
     26 
     27   constexpr int bar(int x, int y) // expected-note {{here}}
     28     { return x + y + x*y; }
     29   int bar(int x, int y) // expected-error {{non-constexpr declaration of 'bar' follows constexpr declaration}}
     30     { return x * 2 + 3 * y; }
     31 
     32 }
     33 
     34 // The constexpr specifier is allowed for static member functions of non-literal types.
     35 class NonLiteralClass {
     36   NonLiteralClass(bool);
     37   static constexpr bool isDebugFlag();
     38 };
     39