[cfe-commits] r66010 - /cfe/trunk/lib/CodeGen/CGDecl.cpp

Eli Friedman eli.friedman at gmail.com
Sun Mar 15 05:51:20 PDT 2009


On Sat, Mar 14, 2009 at 11:18 PM, Daniel Dunbar <daniel at zuster.org> wrote:
> I still don't completely get this. Can you show me an example?

Something like the following forces the issue:

union x {struct {int* a; char b;} __attribute((packed)) x; struct
{char c; int* d} __attribute((packed)) y;};
void a(void) {
static int r;
static union x c = {.x = {&r, 10}}, d = {.y = {10, &r}};
union x* cp = &c, *dp = &d;
}

Emitted LLVM for globals:
@a.c = internal global %0 <{ %struct.anon <{ i32* @a.r, i8 10 }> }>
@a.d = internal global %1 <{ %2 <{ i8 10, i32* @a.r }> }>

There isn't any other way to emit these globals with LLVM currently.

> I haven't
> looked closely, but where are we accomodating for the mismatch when we
> lookup the global decl, and it doesn't have the type which matches the
> global type? Or does this just not matter in the cases where we do this?

It gets handled later in the same function.

-Eli



More information about the cfe-commits mailing list