p8.cpp revision 1bf9a9e6a5bdc0de7939908855dcddf46b661800
1// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s 2 3struct S { 4 constexpr int f(); 5 constexpr int g() const; 6 static constexpr int Sf(); 7}; 8 9void 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 17namespace 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