summaryrefslogtreecommitdiff
path: root/test/CXX
diff options
context:
space:
mode:
authorFlorian Hahn <florian.hahn@arm.com>2018-07-17 09:23:31 +0000
committerFlorian Hahn <florian.hahn@arm.com>2018-07-17 09:23:31 +0000
commit28deda3b5839098b427e528ad93bcfa434806a74 (patch)
tree806935f84eda19055950c0859e3939e21d44cb02 /test/CXX
parentde3003c4189d27f04678d5295dd6b4d4700f7d3f (diff)
downloadclang-28deda3b5839098b427e528ad93bcfa434806a74.tar.gz
Temporarily revert r337226 "Restructure checking for, and warning on, lifetime extension."
This change breaks on ARM because pointers to clang::InitializedEntity are only 4 byte aligned and do not have 3 bits to store values. A possible solution would be to change the fields in clang::InitializedEntity to enforce a bigger alignment requirement. The error message is llvm/include/llvm/ADT/PointerIntPair.h:132:3: error: static_assert failed "PointerIntPair with integer size too large for pointer" static_assert(IntBits <= PtrTraits::NumLowBitsAvailable, include/llvm/ADT/PointerIntPair.h:73:13: note: in instantiation of template class 'llvm::PointerIntPairInfo<const clang::InitializedEntity *, 3, llvm::PointerLikeTypeTraits<const clang::InitializedEntity *> >' requested here Value = Info::updateInt(Info::updatePointer(0, PtrVal), llvm/include/llvm/ADT/PointerIntPair.h:51:5: note: in instantiation of member function 'llvm::PointerIntPair<const clang::InitializedEntity *, 3, (anonymous namespace)::LifetimeKind, llvm::PointerLikeTypeTraits<const clang::InitializedEntity *>, llvm::PointerIntPairInfo<const clang::InitializedEntity *, 3, llvm::PointerLikeTypeTraits<const clang::InitializedEntity *> > >::setPointerAndInt' requested here setPointerAndInt(PtrVal, IntVal); ^ llvm/tools/clang/lib/Sema/SemaInit.cpp:6237:12: note: in instantiation of member function 'llvm::PointerIntPair<const clang::InitializedEntity *, 3, (anonymous namespace)::LifetimeKind, llvm::PointerLikeTypeTraits<const clang::InitializedEntity *>, llvm::PointerIntPairInfo<const clang::InitializedEntity *, 3, llvm::PointerLikeTypeTraits<const clang::InitializedEntity *> > >::PointerIntPair' requested here return {Entity, LK_Extended}; Full log here: http://lab.llvm.org:8011/builders/clang-cmake-armv7-global-isel/builds/1330 http://lab.llvm.org:8011/builders/clang-cmake-armv7-full/builds/1394 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@337255 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test/CXX')
-rw-r--r--test/CXX/drs/dr16xx.cpp94
-rw-r--r--test/CXX/drs/dr18xx.cpp11
-rw-r--r--test/CXX/special/class.copy/p11.0x.copy.cpp13
-rw-r--r--test/CXX/special/class.copy/p11.0x.move.cpp2
-rw-r--r--test/CXX/special/class.ctor/p5-0x.cpp6
-rw-r--r--test/CXX/temp/temp.param/p5.cpp12
6 files changed, 10 insertions, 128 deletions
diff --git a/test/CXX/drs/dr16xx.cpp b/test/CXX/drs/dr16xx.cpp
index 54648cfe96..e0af95ac39 100644
--- a/test/CXX/drs/dr16xx.cpp
+++ b/test/CXX/drs/dr16xx.cpp
@@ -9,20 +9,6 @@
#define static_assert(...) __extension__ _Static_assert(__VA_ARGS__)
#endif
-#if __cplusplus >= 201103L
-namespace std {
- typedef decltype(sizeof(int)) size_t;
-
- template<typename E> class initializer_list {
- const E *begin;
- size_t size;
-
- public:
- initializer_list();
- };
-} // std
-#endif
-
namespace dr1611 { // dr1611: dup 1658
struct A { A(int); };
struct B : virtual A { virtual void f() = 0; };
@@ -283,83 +269,3 @@ namespace dr1687 { // dr1687: 7
auto c = To<E1>() <=> To<E2>(); // expected-error {{invalid operands to binary expression ('To<dr1687::E1>' and 'To<dr1687::E2>')}}
#endif
}
-
-namespace dr1696 { // dr1696: 7
- namespace std_examples {
-#if __cplusplus >= 201402L
- extern struct A a;
- struct A {
- const A &x = { A{a, a} };
- const A &y = { A{} }; // expected-error {{default member initializer for 'y' needed within definition of enclosing class 'A' outside of member functions}} expected-note {{here}}
- };
- A a{a, a};
-#endif
- }
-
- struct A { A(); ~A(); };
-#if __cplusplus >= 201103L
- struct B {
- A &&a; // expected-note {{declared here}}
- B() : a{} {} // expected-error {{reference member 'a' binds to a temporary object whose lifetime would be shorter than the constructed object}}
- } b;
-#endif
-
- struct C {
- C();
- const A &a; // expected-note {{declared here}}
- };
- C::C() : a(A()) {} // expected-error {{reference member 'a' binds to a temporary object whose lifetime would be shorter than the constructed object}}
-
-#if __cplusplus >= 201103L
- // This is OK in C++14 onwards, per DR1815, though we don't support that yet:
- // D1 d1 = {};
- // is equivalent to
- // D1 d1 = {A()};
- // ... which lifetime-extends the A temporary.
- struct D1 {
- const A &a = A();
-#if __cplusplus < 201402L
- // expected-error@-2 {{binds to a temporary}}
- // expected-note@-4 {{here}}
-#else
- // expected-warning-re@-5 {{sorry, lifetime extension {{.*}} not supported}}
-#endif
- };
- D1 d1 = {}; // expected-note {{here}}
-
- struct D2 {
- const A &a = A(); // expected-error {{binds to a temporary}}
- D2() {} // expected-note {{used here}}
- };
-
- struct D3 { // expected-note {{used here}}
- const A &a = A(); // expected-error {{binds to a temporary}}
- };
- D3 d3; // expected-note {{first required here}}
-
- struct haslist1 {
- std::initializer_list<int> il; // expected-note {{'std::initializer_list' member}}
- haslist1(int i) : il{i, 2, 3} {} // expected-error {{backing array for 'std::initializer_list' member 'il' is a temporary object}}
- };
-
- struct haslist2 {
- std::initializer_list<int> il; // expected-note {{'std::initializer_list' member}}
- haslist2();
- };
- haslist2::haslist2() : il{1, 2} {} // expected-error {{backing array for 'std::initializer_list' member 'il' is a temporary object}}
-
- struct haslist3 {
- std::initializer_list<int> il = {1, 2, 3};
- };
-
- struct haslist4 { // expected-note {{in default member initializer}}
- std::initializer_list<int> il = {1, 2, 3}; // expected-error {{backing array for 'std::initializer_list' member 'il' is a temporary object}}
- };
- haslist4 hl4; // expected-note {{in implicit default constructor}}
-
- struct haslist5 {
- std::initializer_list<int> il = {1, 2, 3}; // expected-error {{backing array for 'std::initializer_list' member 'il' is a temporary object}}
- haslist5() {} // expected-note {{in default member initializer}}
- };
-#endif
-}
diff --git a/test/CXX/drs/dr18xx.cpp b/test/CXX/drs/dr18xx.cpp
index f6a4676bc7..a0f470ed4a 100644
--- a/test/CXX/drs/dr18xx.cpp
+++ b/test/CXX/drs/dr18xx.cpp
@@ -30,17 +30,6 @@ namespace dr1813 { // dr1813: 7
static_assert(!__is_standard_layout(U), "");
}
-namespace dr1815 { // dr1815: no
-#if __cplusplus >= 201402L
- // FIXME: needs codegen test
- struct A { int &&r = 0; }; // FIXME expected-warning {{not supported}}
- A a = {}; // expected-note {{here}}
-
- struct B { int &&r = 0; }; // expected-error {{binds to a temporary}} expected-note {{here}}
- B b; // expected-note {{here}}
-#endif
-}
-
namespace dr1881 { // dr1881: 7
struct A { int a : 4; };
struct B : A { int b : 3; };
diff --git a/test/CXX/special/class.copy/p11.0x.copy.cpp b/test/CXX/special/class.copy/p11.0x.copy.cpp
index a4d0cdcdc7..1ca0143d09 100644
--- a/test/CXX/special/class.copy/p11.0x.copy.cpp
+++ b/test/CXX/special/class.copy/p11.0x.copy.cpp
@@ -121,22 +121,13 @@ extern HasNoAccessDtorBase HNADBa;
HasNoAccessDtorBase HNADBb(HNADBa); // expected-error{{implicitly-deleted copy constructor}}
// -- a non-static data member of rvalue reference type
-int some_int;
struct RValue {
- int && ri = static_cast<int&&>(some_int); // expected-note{{copy constructor of 'RValue' is implicitly deleted because field 'ri' is of rvalue reference type 'int &&'}}
+ int && ri = 1; // expected-note{{copy constructor of 'RValue' is implicitly deleted because field 'ri' is of rvalue reference type 'int &&'}}
+ // expected-warning@-1{{binding reference member 'ri' to a temporary}} expected-note@-1 {{here}}
};
RValue RVa;
RValue RVb(RVa); // expected-error{{call to implicitly-deleted copy constructor}}
-// FIXME: The note on the class-name is attached to the location of the
-// constructor. This is not especially clear.
-struct RValueTmp { // expected-note {{used here}}
- int && ri = 1; // expected-note{{copy constructor of 'RValueTmp' is implicitly deleted because field 'ri' is of rvalue reference type 'int &&'}}
- // expected-error@-1 {{reference member 'ri' binds to a temporary}}
-};
-RValueTmp RVTa; // expected-note {{implicit default constructor for 'RValueTmp' first required here}}
-RValueTmp RVTb(RVTa); // expected-error{{call to implicitly-deleted copy constructor}}
-
namespace PR13381 {
struct S {
S(const S&);
diff --git a/test/CXX/special/class.copy/p11.0x.move.cpp b/test/CXX/special/class.copy/p11.0x.move.cpp
index 5b016836e9..ab4259548e 100644
--- a/test/CXX/special/class.copy/p11.0x.move.cpp
+++ b/test/CXX/special/class.copy/p11.0x.move.cpp
@@ -145,7 +145,7 @@ HasNoAccessDtorBase HNADBb(HNADBa); // expected-error{{implicitly-deleted copy c
// The restriction on rvalue reference members applies to only the copy
// constructor.
struct RValue {
- int &&ri = 1;
+ int &&ri = 1; // expected-warning {{binding reference member 'ri' to a temporary}} expected-note {{here}}
RValue(RValue&&);
};
RValue::RValue(RValue&&) = default;
diff --git a/test/CXX/special/class.ctor/p5-0x.cpp b/test/CXX/special/class.ctor/p5-0x.cpp
index 5558313ce7..2360345a48 100644
--- a/test/CXX/special/class.ctor/p5-0x.cpp
+++ b/test/CXX/special/class.ctor/p5-0x.cpp
@@ -43,12 +43,8 @@ class NotDeleted2a { int &a = n; };
NotDeleted2a nd2a;
class NotDeleted2b { int &a = error; }; // expected-error {{undeclared identifier}}
NotDeleted2b nd2b;
-class NotDeleted2c { int &&a = static_cast<int&&>(n); };
+class NotDeleted2c { int &&a = 0; }; // expected-warning {{binding reference member 'a' to a temporary}} expected-note {{here}}
NotDeleted2c nd2c;
-// Note: this one does not have a deleted default constructor even though the
-// implicit default constructor is ill-formed!
-class NotDeleted2d { int &&a = 0; }; // expected-error {{reference member 'a' binds to a temporary object}} expected-note {{here}}
-NotDeleted2d nd2d; // expected-note {{first required here}}
// - any non-variant non-static data member of const qualified type (or array
// thereof) with no brace-or-equal-initializer does not have a user-provided
diff --git a/test/CXX/temp/temp.param/p5.cpp b/test/CXX/temp/temp.param/p5.cpp
index de902a5e4d..aa0d7e92b9 100644
--- a/test/CXX/temp/temp.param/p5.cpp
+++ b/test/CXX/temp/temp.param/p5.cpp
@@ -1,13 +1,13 @@
// RUN: %clang_cc1 -verify %s -std=c++14
-template<const int I> struct S { // expected-note {{in default member initializer}}
+template<const int I> struct S {
decltype(I) n;
- int &&r = I; // expected-error {{reference member 'r' binds to a temporary object}}
+ int &&r = I; // expected-warning 2{{binding reference member 'r' to a temporary value}} expected-note 2{{declared here}}
};
-S<5> s; // expected-note {{implicit default constructor}}
+S<5> s; // expected-note {{instantiation}}
-template<typename T, T v> struct U { // expected-note {{in default member initializer}}
+template<typename T, T v> struct U {
decltype(v) n;
- int &&r = v; // expected-error {{reference member 'r' binds to a temporary object}}
+ int &&r = v; // expected-warning {{binding reference member 'r' to a temporary value}} expected-note {{declared here}}
};
-U<const int, 6> u; // expected-note {{implicit default constructor}}
+U<const int, 6> u; // expected-note {{instantiation}}