diff options
Diffstat (limited to 'clang')
-rw-r--r-- | clang/lib/CodeGen/CodeGenModule.cpp | 5 | ||||
-rw-r--r-- | clang/test/CodeGenCXX/global-init.cpp | 7 |
2 files changed, 12 insertions, 0 deletions
diff --git a/clang/lib/CodeGen/CodeGenModule.cpp b/clang/lib/CodeGen/CodeGenModule.cpp index 944b24cbd38..d22991db041 100644 --- a/clang/lib/CodeGen/CodeGenModule.cpp +++ b/clang/lib/CodeGen/CodeGenModule.cpp @@ -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)); diff --git a/clang/test/CodeGenCXX/global-init.cpp b/clang/test/CodeGenCXX/global-init.cpp index 60032708168..752223bc7b8 100644 --- a/clang/test/CodeGenCXX/global-init.cpp +++ b/clang/test/CodeGenCXX/global-init.cpp @@ -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" { |