Deal with a horrible C++11 special case. If a non-literal type has a constexpr
constructor, and that constructor is used to initialize an object of static
storage duration such that all members and bases are initialized by constant
expressions, constant initialization is performed. In this case, the object
can still have a non-trivial destructor, and if it does, we must emit a dynamic
initializer which performs no initialization and instead simply registers that
destructor.

llvm-svn: 150419
diff --git a/clang/lib/Sema/SemaDecl.cpp b/clang/lib/Sema/SemaDecl.cpp
index 3c73f68..de9fecc 100644
--- a/clang/lib/Sema/SemaDecl.cpp
+++ b/clang/lib/Sema/SemaDecl.cpp
@@ -3991,15 +3991,8 @@
                                            TemplateParamLists.release());
     }
 
-    if (D.getDeclSpec().isConstexprSpecified()) {
+    if (D.getDeclSpec().isConstexprSpecified())
       NewVD->setConstexpr(true);
-      SourceLocation ConstexprLoc = D.getDeclSpec().getConstexprSpecLoc();
-      if (!NewVD->isInvalidDecl() && !R->isDependentType() &&
-          RequireLiteralType(NewVD->getLocation(), R,
-                             PDiag(diag::err_constexpr_var_non_literal)
-                               << SourceRange(ConstexprLoc)))
-        NewVD->setInvalidDecl();
-    }
   }
 
   // Set the lexical context. If the declarator has a C++ scope specifier, the
@@ -4347,6 +4340,13 @@
     return false;
   }
 
+  if (NewVD->isConstexpr() && !T->isDependentType() &&
+      RequireLiteralType(NewVD->getLocation(), T,
+                         PDiag(diag::err_constexpr_var_non_literal))) {
+    NewVD->setInvalidDecl();
+    return false;
+  }
+
   if (!Previous.empty()) {
     MergeVarDecl(NewVD, Previous);
     return true;