aboutsummaryrefslogtreecommitdiff
path: root/test/SemaCXX
diff options
context:
space:
mode:
authorRichard Smith <richard-llvm@metafoo.co.uk>2012-07-05 08:39:21 +0000
committerRichard Smith <richard-llvm@metafoo.co.uk>2012-07-05 08:39:21 +0000
commitf4bb8d06c4f1665f89a9e9ddd61f2a2d26904da0 (patch)
treed0ff432696864702c52b6353671386a07ffc4b10 /test/SemaCXX
parente07c5f897e8da88959c93a9d98f1b441da649eb6 (diff)
PR13273: When performing list-initialization with an empty initializer list,
actually perform value initialization rather than trying to fake it with a call to the default constructor. Fixes various bugs related to the previously-missing zero-initialization in this case. I've also moved this and the other list initialization 'special case' from TryConstructorInitialization into TryListInitialization where they belong. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@159733 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test/SemaCXX')
-rw-r--r--test/SemaCXX/constant-expression-cxx11.cpp16
-rw-r--r--test/SemaCXX/cxx0x-initializer-constructor.cpp23
2 files changed, 39 insertions, 0 deletions
diff --git a/test/SemaCXX/constant-expression-cxx11.cpp b/test/SemaCXX/constant-expression-cxx11.cpp
index d1f1f924c6..facd4375b0 100644
--- a/test/SemaCXX/constant-expression-cxx11.cpp
+++ b/test/SemaCXX/constant-expression-cxx11.cpp
@@ -1302,3 +1302,19 @@ namespace PR12826 {
constexpr Foo id(Foo x) { return x; }
constexpr Foo res(id(Foo()));
}
+
+namespace PR13273 {
+ struct U {
+ int t;
+ U() = default;
+ };
+
+ struct S : U {
+ S() = default;
+ };
+
+ // S's default constructor isn't constexpr, because U's default constructor
+ // doesn't initialize 't', but it's trivial, so value-initialization doesn't
+ // actually call it.
+ static_assert(S{}.t == 0, "");
+}
diff --git a/test/SemaCXX/cxx0x-initializer-constructor.cpp b/test/SemaCXX/cxx0x-initializer-constructor.cpp
index 09aca24b70..223e140ffc 100644
--- a/test/SemaCXX/cxx0x-initializer-constructor.cpp
+++ b/test/SemaCXX/cxx0x-initializer-constructor.cpp
@@ -279,5 +279,28 @@ namespace PR12498 {
{
c->foo({ nullptr, 1 }); // expected-error{{initialization of incomplete type 'const PR12498::ArrayRef'}}
}
+}
+
+namespace explicit_default {
+ struct A {
+ explicit A(); // expected-note{{here}}
+ };
+ A a {}; // ok
+ // This is copy-list-initialization, and we choose an explicit constructor
+ // (even though we do so via value-initialization), so the initialization is
+ // ill-formed.
+ A b = {}; // expected-error{{chosen constructor is explicit}}
+}
+namespace init_list_default {
+ struct A {
+ A(std::initializer_list<int>);
+ };
+ A a {}; // calls initializer list constructor
+
+ struct B {
+ B();
+ B(std::initializer_list<int>) = delete;
+ };
+ B b {}; // calls default constructor
}