Emit a warning when list-initializing a std::initializer_list member.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@150933 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Sema/SemaDeclCXX.cpp b/lib/Sema/SemaDeclCXX.cpp
index 0b785f3..48dc911 100644
--- a/lib/Sema/SemaDeclCXX.cpp
+++ b/lib/Sema/SemaDeclCXX.cpp
@@ -1643,6 +1643,10 @@
 
   ExprResult Init = InitExpr;
   if (!FD->getType()->isDependentType() && !InitExpr->isTypeDependent()) {
+    if (isa<InitListExpr>(InitExpr) && isStdInitializerList(FD->getType(), 0)) {
+    Diag(FD->getLocation(), diag::warn_dangling_std_initializer_list)
+        << /*at end of ctor*/1 << InitExpr->getSourceRange();
+    }
     // FIXME: if there is no EqualLoc, this is list-initialization.
     Init = PerformCopyInitialization(
       InitializedEntity::InitializeMember(FD), EqualLoc, InitExpr);
@@ -2112,6 +2116,11 @@
       InitList = true;
       Args = &Init;
       NumArgs = 1;
+
+      if (isStdInitializerList(Member->getType(), 0)) {
+        Diag(IdLoc, diag::warn_dangling_std_initializer_list)
+            << /*at end of ctor*/1 << InitRange;
+      }
     }
 
     // Initialize the member.