Simplify/fix-up Sema-level struct layout

Patch per subject. This simplifies the code a bit by sharing the same
codepath for unions and structs, and fixes some bugs with some edge
cases (the edge cases addressed are in the testcases in the patch).
As far as I know, this is correct on X86 for all combinations of
bitfields, the packed attribute, and the aligned attribute in both
structs and unions. However, I haven't tested heavily. (Anyone up
for making a struct/union fuzz tester?)

At the moment, codegen for packed bit-fields is broken, but that's a
separate issue.

-Eli

tt.txt (10.1 KB)

Eli,

Patch per subject. This simplifies the code a bit by sharing the same
codepath for unions and structs, and fixes some bugs with some edge
cases (the edge cases addressed are in the testcases in the patch).
As far as I know, this is correct on X86 for all combinations of
bitfields, the packed attribute, and the aligned attribute in both
structs and unions.

cool

However, I haven't tested heavily. (Anyone up
for making a struct/union fuzz tester?)

1. Checkout llvm-gcc-42 sources. It includes gcc testsuite.
2. Put clang and ccc in your path

and do

3. runtest --srcdir /...../llvmgcc42/gcc/testsuite GCC_UNDER_TEST=ccc HOSTCC=gcc HOSTCFLAGS="-g" --tool gcc struct-layout-1.exp

If this reports all passes and zero failure then you're golden!

Mmmm... I'll have to see what I can do about that; currently, I'm
getting *no* passes. That said, it's tripping over other issues; I
think I even found a preprocessor bug.

-Eli