if (!Init) {
if (!getLangOpts().CPlusPlus)
CGM.ErrorUnsupported(D.getInit(), "constant l-value expression");
- else if (Builder.GetInsertBlock()) {
+ else if (HaveInsertPoint()) {
// Since we have a static initializer, this global variable can't
// be constant.
GV->setConstant(false);
GV->setConstant(CGM.isTypeConstant(D.getType(), true));
GV->setInitializer(Init);
- if (hasNontrivialDestruction(D.getType())) {
+ if (hasNontrivialDestruction(D.getType()) && HaveInsertPoint()) {
// We have a constant initializer, but a nontrivial destructor. We still
// need to perform a guarded "initialization" in order to register the
// destructor.
--- /dev/null
+// RUN: %clang_cc1 -triple x86_64-unknown-unknown -emit-llvm -o - %s | FileCheck %s
+
+struct A { ~A(); };
+void func() {
+ return;
+ static A k;
+}
+
+// Test that we did not crash, by checking whether function was created.
+// CHECK-LABEL: define void @_Z4funcv() #0 {
+// CHECK: ret void
+// CHECK: }