Explicitly defaulted constructors cannot be used for default initialization.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@161088 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Sema/SemaInit.cpp b/lib/Sema/SemaInit.cpp
index cab7661..27d58b2 100644
--- a/lib/Sema/SemaInit.cpp
+++ b/lib/Sema/SemaInit.cpp
@@ -2906,7 +2906,7 @@
   //   user-provided default constructor.
   if (Kind.getKind() == InitializationKind::IK_Default &&
       Entity.getType().isConstQualified() &&
-      cast<CXXConstructorDecl>(Best->Function)->isImplicit()) {
+      !cast<CXXConstructorDecl>(Best->Function)->isUserProvided()) {
     Sequence.SetFailed(InitializationSequence::FK_DefaultInitOfConst);
     return;
   }
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 a4dffda..783aba1 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
@@ -27,7 +27,7 @@
 //   -- it is implicitly considered to be constexpr if the implicit declaration
 //      would be
 struct S3 {
-  S3() = default; // expected-note {{here}}
+  S3() = default;
   S3(const S3&) = default;
   S3(S3&&) = default;
   constexpr S3(int n) : n(n) {}
@@ -36,7 +36,7 @@
 constexpr S3 s3a = S3(0);
 constexpr S3 s3b = s3a;
 constexpr S3 s3c = S3();
-constexpr S3 s3d; // expected-error {{constant expression}} expected-note {{non-constexpr constructor}}
+constexpr S3 s3d; // expected-error {{default initialization of an object of const type 'const S3' requires a user-provided default constructor}}
 
 struct S4 {
   S4() = default;
@@ -44,7 +44,7 @@
   S4(S4&&) = default; // expected-note {{here}}
   NoCopyMove ncm;
 };
-constexpr S4 s4a; // ok
+constexpr S4 s4a{}; // ok
 constexpr S4 s4b = S4(); // expected-error {{constant expression}} expected-note {{non-constexpr constructor}}
 constexpr S4 s4c = s4a; // expected-error {{constant expression}} expected-note {{non-constexpr constructor}}
 
@@ -112,3 +112,13 @@
 static_assert(!noexcept(E5(e5)), "");
 static_assert(!noexcept(e5 = E5()), "");
 static_assert(!noexcept(e5 = e5), "");
+
+namespace PR13492 {
+  struct B {
+    B() = default;
+  };
+
+  void f() {
+    const B b; // expected-error {{default initialization of an object of const type 'const PR13492::B' requires a user-provided default constructor}}
+  }
+}
diff --git a/test/SemaCXX/cxx0x-cursory-default-delete.cpp b/test/SemaCXX/cxx0x-cursory-default-delete.cpp
index f002973..641760e 100644
--- a/test/SemaCXX/cxx0x-cursory-default-delete.cpp
+++ b/test/SemaCXX/cxx0x-cursory-default-delete.cpp
@@ -24,7 +24,8 @@
   non_const_copy ncc;
   non_const_copy ncc2 = ncc;
   ncc = ncc2;
-  const non_const_copy cncc;
+  const non_const_copy cncc{};
+  const non_const_copy cncc1; // expected-error {{default initialization of an object of const type 'const non_const_copy' requires a user-provided default constructor}}
   non_const_copy ncc3 = cncc; // expected-error {{no matching}}
   ncc = cncc; // expected-error {{no viable overloaded}}
 };
@@ -69,7 +70,7 @@
 };
 struct except_spec_d_match : except_spec_a, except_spec_b {
   except_spec_d_match() throw(A, B) = default;
-};  
+};
 
 // gcc-compatibility: allow attributes on default definitions
 // (but not normal definitions)