Initial sema support for C++ static initializers.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@55166 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Sema/SemaDecl.cpp b/lib/Sema/SemaDecl.cpp
index 021673b..d8d77b0 100644
--- a/lib/Sema/SemaDecl.cpp
+++ b/lib/Sema/SemaDecl.cpp
@@ -1325,8 +1325,12 @@
     } else if (!VDecl->isInvalidDecl()) {
       if (CheckInitializerTypes(Init, DclT))
         VDecl->setInvalidDecl();
-      if (SC == VarDecl::Static) // C99 6.7.8p4.
-        CheckForConstantInitializer(Init, DclT);
+      
+      // C++ 3.6.2p2, allow dynamic initialization of static initializers.
+      if (!getLangOptions().CPlusPlus) {
+        if (SC == VarDecl::Static) // C99 6.7.8p4.
+          CheckForConstantInitializer(Init, DclT);
+      }
     }
   } else if (VDecl->isFileVarDecl()) {
     if (VDecl->getStorageClass() == VarDecl::Extern)
@@ -1335,8 +1339,11 @@
       if (CheckInitializerTypes(Init, DclT))
         VDecl->setInvalidDecl();
     
-    // C99 6.7.8p4. All file scoped initializers need to be constant.
-    CheckForConstantInitializer(Init, DclT);
+    // C++ 3.6.2p2, allow dynamic initialization of static initializers.
+    if (!getLangOptions().CPlusPlus) {
+      // C99 6.7.8p4. All file scoped initializers need to be constant.
+      CheckForConstantInitializer(Init, DclT);
+    }
   }
   // If the type changed, it means we had an incomplete type that was
   // completed by the initializer. For example: