]> granicus.if.org Git - clang/commitdiff
Ignore indirect field declarations. Fixes PR9570.
authorJohn McCall <rjmccall@apple.com>
Tue, 12 Apr 2011 01:01:22 +0000 (01:01 +0000)
committerJohn McCall <rjmccall@apple.com>
Tue, 12 Apr 2011 01:01:22 +0000 (01:01 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@129337 91177308-0d34-0410-b5e6-96231b3b80d8

lib/CodeGen/CodeGenModule.cpp
test/CodeGenCXX/global-init.cpp

index 944b24cbd38949a06543e0a75b1c9609ea99f809..d22991db041da994ac8bb7602f7cc56a17015582 100644 (file)
@@ -2034,6 +2034,11 @@ void CodeGenModule::EmitTopLevelDecl(Decl *D) {
     EmitGlobal(cast<VarDecl>(D));
     break;
 
+  // Indirect fields from global anonymous structs and unions can be
+  // ignored; only the actual variable requires IR gen support.
+  case Decl::IndirectField:
+    break;
+
   // C++ Decls
   case Decl::Namespace:
     EmitNamespace(cast<NamespaceDecl>(D));
index 6003270816814d714ee7ef2d5f15c6a1f54728fe..752223bc7b803b256b8e4863b4ef0ae98d0ada28 100644 (file)
@@ -90,6 +90,13 @@ namespace PR5974 {
 // CHECK-NEXT:   sub
 // CHECK-NEXT:   store i32 {{.*}}, i32* @_ZN5test1L1yE
 
+// PR9570: the indirect field shouldn't crash IR gen.
+namespace test5 {
+  union {
+    unsigned bar[4096] __attribute__((aligned(128)));
+  };
+}
+
 // At the end of the file, we check that y is initialized before z.
 
 // CHECK: define internal void @_GLOBAL__I_a() section "__TEXT,__StaticInit,regular,pure_instructions" {