[cfe-commits] r159513 - /cfe/trunk/test/SemaCXX/constant-expression-cxx11.cpp
Richard Smith
richard-llvm at metafoo.co.uk
Sun Jul 1 23:15:40 PDT 2012
Author: rsmith
Date: Mon Jul 2 01:15:40 2012
New Revision: 159513
URL: http://llvm.org/viewvc/llvm-project?rev=159513&view=rev
Log:
Additional testing for fixes in r158289 and r158290 to allow implicitly-declared
constructors for non-literal types to be constexpr in some circumstances.
Modified:
cfe/trunk/test/SemaCXX/constant-expression-cxx11.cpp
Modified: cfe/trunk/test/SemaCXX/constant-expression-cxx11.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/constant-expression-cxx11.cpp?rev=159513&r1=159512&r2=159513&view=diff
==============================================================================
--- cfe/trunk/test/SemaCXX/constant-expression-cxx11.cpp (original)
+++ cfe/trunk/test/SemaCXX/constant-expression-cxx11.cpp Mon Jul 2 01:15:40 2012
@@ -1270,6 +1270,31 @@
}
}
+// Constructors can be implicitly constexpr, even for a non-literal type.
+namespace ImplicitConstexpr {
+ struct Q { Q() = default; Q(const Q&) = default; Q(Q&&) = default; ~Q(); }; // expected-note 3{{here}}
+ struct R { constexpr R(); constexpr R(const R&); constexpr R(R&&); ~R(); };
+ struct S { R r; }; // expected-note 3{{here}}
+ struct T { T(const T&); T(T &&); ~T(); };
+ struct U { T t; }; // expected-note 3{{here}}
+ static_assert(!__is_literal_type(Q), "");
+ static_assert(!__is_literal_type(R), "");
+ static_assert(!__is_literal_type(S), "");
+ static_assert(!__is_literal_type(T), "");
+ static_assert(!__is_literal_type(U), "");
+ struct Test {
+ friend Q::Q() noexcept; // expected-error {{follows constexpr}}
+ friend Q::Q(Q&&) noexcept; // expected-error {{follows constexpr}}
+ friend Q::Q(const Q&) noexcept; // expected-error {{follows constexpr}}
+ friend S::S() noexcept; // expected-error {{follows constexpr}}
+ friend S::S(S&&) noexcept; // expected-error {{follows constexpr}}
+ friend S::S(const S&) noexcept; // expected-error {{follows constexpr}}
+ friend constexpr U::U() noexcept; // expected-error {{follows non-constexpr}}
+ friend constexpr U::U(U&&) noexcept; // expected-error {{follows non-constexpr}}
+ friend constexpr U::U(const U&) noexcept; // expected-error {{follows non-constexpr}}
+ };
+}
+
// Indirectly test that an implicit lvalue to xvalue conversion performed for
// an NRVO move operation isn't implemented as CK_LValueToRValue.
namespace PR12826 {
More information about the cfe-commits
mailing list