[cfe-commits] r104743 - in /cfe/trunk: lib/CodeGen/CGDecl.cpp test/CodeGenCXX/static-local-in-local-class.cpp
Fariborz Jahanian
fjahanian at apple.com
Wed May 26 14:45:50 PDT 2010
Author: fjahanian
Date: Wed May 26 16:45:50 2010
New Revision: 104743
URL: http://llvm.org/viewvc/llvm-project?rev=104743&view=rev
Log:
Patch to fix a irgen crash accessing an initialized local static
variable in a local function. Fixes pr7101.
Modified:
cfe/trunk/lib/CodeGen/CGDecl.cpp
cfe/trunk/test/CodeGenCXX/static-local-in-local-class.cpp
Modified: cfe/trunk/lib/CodeGen/CGDecl.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDecl.cpp?rev=104743&r1=104742&r2=104743&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGDecl.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGDecl.cpp Wed May 26 16:45:50 2010
@@ -239,8 +239,6 @@
// Store into LocalDeclMap before generating initializer to handle
// circular references.
DMEntry = GV;
- if (getContext().getLangOptions().CPlusPlus)
- CGM.setStaticLocalDeclAddress(&D, GV);
// We can't have a VLA here, but we can have a pointer to a VLA,
// even though that doesn't really make any sense.
@@ -269,6 +267,9 @@
if (D.hasAttr<UsedAttr>())
CGM.AddUsedGlobal(GV);
+ if (getContext().getLangOptions().CPlusPlus)
+ CGM.setStaticLocalDeclAddress(&D, GV);
+
// We may have to cast the constant because of the initializer
// mismatch above.
//
Modified: cfe/trunk/test/CodeGenCXX/static-local-in-local-class.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/static-local-in-local-class.cpp?rev=104743&r1=104742&r2=104743&view=diff
==============================================================================
--- cfe/trunk/test/CodeGenCXX/static-local-in-local-class.cpp (original)
+++ cfe/trunk/test/CodeGenCXX/static-local-in-local-class.cpp Wed May 26 16:45:50 2010
@@ -19,3 +19,15 @@
}
(void)i;
}
+
+// pr7101
+void foo() {
+ static int n = 0;
+ struct Helper {
+ static void Execute() {
+ n++;
+ }
+ };
+ Helper::Execute();
+}
+
More information about the cfe-commits
mailing list