aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/CodeGen/CGDeclCXX.cpp4
-rw-r--r--test/CodeGenCXX/reference-init.cpp5
2 files changed, 7 insertions, 2 deletions
diff --git a/lib/CodeGen/CGDeclCXX.cpp b/lib/CodeGen/CGDeclCXX.cpp
index 47773a0d69..2d473de47c 100644
--- a/lib/CodeGen/CGDeclCXX.cpp
+++ b/lib/CodeGen/CGDeclCXX.cpp
@@ -80,8 +80,8 @@ void CodeGenFunction::EmitCXXGlobalVarDeclInit(const VarDecl &D,
EmitDeclInit(*this, D, DeclPtr);
return;
}
-
- ErrorUnsupported(Init, "global variable that binds to a reference");
+ RValue RV = EmitReferenceBindingToExpr(Init, T, /*IsInitializer=*/true);
+ EmitStoreOfScalar(RV.getScalarVal(), DeclPtr, false, T);
}
void
diff --git a/test/CodeGenCXX/reference-init.cpp b/test/CodeGenCXX/reference-init.cpp
index 6c2c6a3016..61ae2daffd 100644
--- a/test/CodeGenCXX/reference-init.cpp
+++ b/test/CodeGenCXX/reference-init.cpp
@@ -14,3 +14,8 @@ namespace PR5911 {
int iarr[] = { 1 };
int test() { return f(iarr); }
}
+
+// radar 7574896
+struct Foo { int foo; };
+Foo& ignoreSetMutex = *(new Foo);
+