[cfe-commits] r91027 - in /cfe/trunk: lib/CodeGen/CGDeclCXX.cpp test/CodeGenCXX/static-init.cpp
Eli Friedman
eli.friedman at gmail.com
Wed Dec 9 17:53:32 PST 2009
On Wed, Dec 9, 2009 at 5:05 PM, Anders Carlsson <andersca at mac.com> wrote:
> --- cfe/trunk/lib/CodeGen/CGDeclCXX.cpp (original)
> +++ cfe/trunk/lib/CodeGen/CGDeclCXX.cpp Wed Dec 9 19:05:11 2009
> @@ -193,7 +193,10 @@
> EmitBlock(InitBlock);
>
> if (D.getType()->isReferenceType()) {
> - ErrorUnsupported(D.getInit(), "static variable that binds to a reference");
> + // We don't want to pass true for IsInitializer here, because a static
> + // reference to a temporary does not extend its lifetime.
> + EmitReferenceBindingToExpr(D.getInit(), D.getType(),
> + /*IsInitializer=*/false);
> } else
> EmitDeclInit(*this, D, GV);
I think you're missing a rather important step here.
-Eli
More information about the cfe-commits
mailing list