From 222e2a7620e6520ffaf4fc4e69d79c18da31542e Mon Sep 17 00:00:00 2001 From: "Zancanaro; Carlo" Date: Mon, 24 Sep 2012 09:58:17 +1000 Subject: Add the clang library to the repo (with some of my changes, too). --- .../test/CXX/dcl.dcl/dcl.spec/dcl.constexpr/p8.cpp | 38 ++++++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 clang/test/CXX/dcl.dcl/dcl.spec/dcl.constexpr/p8.cpp (limited to 'clang/test/CXX/dcl.dcl/dcl.spec/dcl.constexpr/p8.cpp') diff --git a/clang/test/CXX/dcl.dcl/dcl.spec/dcl.constexpr/p8.cpp b/clang/test/CXX/dcl.dcl/dcl.spec/dcl.constexpr/p8.cpp new file mode 100644 index 0000000..c4935b3 --- /dev/null +++ b/clang/test/CXX/dcl.dcl/dcl.spec/dcl.constexpr/p8.cpp @@ -0,0 +1,38 @@ +// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s + +struct S { + constexpr int f(); + constexpr int g() const; + static constexpr int Sf(); +}; + +void f(const S &s) { + s.f(); + s.g(); + + int (*f)() = &S::Sf; + int (S::*g)() const = &S::g; +} + +namespace std_example { + + class debug_flag { // expected-note {{not an aggregate and has no constexpr constructors}} + public: + explicit debug_flag(bool); + constexpr bool is_on(); // expected-error {{non-literal type 'std_example::debug_flag' cannot have constexpr members}} + private: + bool flag; + }; + + constexpr int bar(int x, int y) // expected-note {{here}} + { return x + y + x*y; } + int bar(int x, int y) // expected-error {{non-constexpr declaration of 'bar' follows constexpr declaration}} + { return x * 2 + 3 * y; } + +} + +// The constexpr specifier is allowed for static member functions of non-literal types. +class NonLiteralClass { + NonLiteralClass(bool); + static constexpr bool isDebugFlag(); +}; -- cgit v1.2.3