diff options
author | Nico Weber <nicolasweber@gmx.de> | 2016-02-19 01:52:46 +0000 |
---|---|---|
committer | Nico Weber <nicolasweber@gmx.de> | 2016-02-19 01:52:46 +0000 |
commit | 309e7e9be3b249095885c91b0928d183bee9ef6f (patch) | |
tree | 977fae2a1c0385e718eda813a49edeb699a1df69 /test/CXX/dcl.decl | |
parent | 2acb3424b3792a7d1c5dfdbf615632937662bb93 (diff) |
Implement the likely resolution of core issue 253.
C++11 requires const objects to have a user-provided constructor, even for
classes without any fields. DR 253 relaxes this to say "If the implicit default
constructor initializes all subobjects, no initializer should be required."
clang is currently the only compiler that implements this C++11 rule, and e.g.
libstdc++ relies on something like DR 253 to compile in newer versions. This
change makes it possible to build code that says `const vector<int> v;' again
when using libstdc++5.2 and _GLIBCXX_DEBUG
(https://gcc.gnu.org/bugzilla/show_bug.cgi?id=60284).
Fixes PR23381.
http://reviews.llvm.org/D16552
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@261297 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test/CXX/dcl.decl')
-rw-r--r-- | test/CXX/dcl.decl/dcl.fct.def/dcl.fct.def.default/p2.cpp | 1 | ||||
-rw-r--r-- | test/CXX/dcl.decl/dcl.init/p6.cpp | 6 |
2 files changed, 4 insertions, 3 deletions
diff --git a/test/CXX/dcl.decl/dcl.fct.def/dcl.fct.def.default/p2.cpp b/test/CXX/dcl.decl/dcl.fct.def/dcl.fct.def.default/p2.cpp index 5cf281c185..c2f3b5a045 100644 --- a/test/CXX/dcl.decl/dcl.fct.def/dcl.fct.def.default/p2.cpp +++ b/test/CXX/dcl.decl/dcl.fct.def/dcl.fct.def.default/p2.cpp @@ -116,6 +116,7 @@ static_assert(!noexcept(e5 = e5), ""); namespace PR13492 { struct B { B() = default; + int field; }; void f() { diff --git a/test/CXX/dcl.decl/dcl.init/p6.cpp b/test/CXX/dcl.decl/dcl.init/p6.cpp index e404a1ebc1..b646ba776a 100644 --- a/test/CXX/dcl.decl/dcl.init/p6.cpp +++ b/test/CXX/dcl.decl/dcl.init/p6.cpp @@ -4,9 +4,9 @@ // If a program calls for the default initialization of an object of a // const-qualified type T, T shall be a class type with a -// user-provided default constructor. +// user-provided default constructor, except if T has no uninitialized fields. struct MakeNonPOD { MakeNonPOD(); }; -struct NoUserDefault : public MakeNonPOD { }; +struct NoUserDefault : public MakeNonPOD { int field; }; struct HasUserDefault { HasUserDefault(); }; void test_const_default_init() { @@ -16,7 +16,7 @@ void test_const_default_init() { } // rdar://8501008 -struct s0 {}; +struct s0 { int field; }; struct s1 { static const s0 foo; }; const struct s0 s1::foo; // expected-error{{default initialization of an object of const type 'const struct s0' without a user-provided default constructor}} |