Commit Graph

12 Commits

Author SHA1 Message Date
Douglas Gregor aef040a28e When handling "the rest" of a designated array subobject, maybe sure
to tell it that it wasn't (directly) designated. This way, we unwind
back to the explicit initializer list properly rather than getting
stuck in the wrong subobject. Fixes llvm.org/PR3519

llvm-svn: 64155
2009-02-09 19:45:19 +00:00
Douglas Gregor bf7207a11f Make CodeGen produce an error if we come across a non-constant initializer list that involves the GNU array-range designator extension
llvm-svn: 63327
2009-01-29 19:42:23 +00:00
Douglas Gregor 35a52fabf4 Add another devilish testcase for designated initializers
llvm-svn: 63262
2009-01-29 01:10:11 +00:00
Douglas Gregor f6d2752f12 Eliminate infinite looping in a wacky case with designated initializers. Simplifies (somewhat) the actually checking of the initializer expression following the designators
llvm-svn: 63257
2009-01-29 00:39:20 +00:00
Douglas Gregor 17bd094a6b Improvements to code-generation and semantic analysis of designated
initializers.

  - We now initialize unions properly when a member other than the
    first is named by a designated initializer.
  - We now provide proper semantic analysis and code generation for
    GNU array-range designators *except* that side effects will occur
    more than once. We warn about this.

llvm-svn: 63253
2009-01-28 23:36:17 +00:00
Douglas Gregor 347f7eabb9 Code generation support for C99 designated initializers.
The approach I've taken in this patch is relatively straightforward,
although the code itself is non-trivial. Essentially, as we process
an initializer list we build up a fully-explicit representation of the
initializer list, where each of the subobject initializations occurs
in order. Designators serve to "fill in" subobject initializations in
a non-linear way. The fully-explicit representation makes initializer
lists (both with and without designators) easy to grok for codegen and
later semantic analyses. We keep the syntactic form of the initializer
list linked into the AST for those clients interested in exactly what
the user wrote.

Known limitations:
  - Designating a member of a union that isn't the first member may
    result in bogus initialization (we warn about this)
  - GNU array-range designators are not supported (we warn about this)

llvm-svn: 63242
2009-01-28 21:54:33 +00:00
Douglas Gregor 7a95b08fce More APSInt appeasement
llvm-svn: 62884
2009-01-23 22:22:29 +00:00
Douglas Gregor 51650d380b Hopefully the last of the APSInt signedness issues with initializers. Fixes PR clang/3378
llvm-svn: 62876
2009-01-23 21:04:18 +00:00
Douglas Gregor 583cf0ac57 Make sure all of the isUnsigned flags line up when comparing initializer values, to really really fix PR clang/3377
llvm-svn: 62858
2009-01-23 18:58:42 +00:00
Douglas Gregor 033d1257ca Properly manage the bit-widths of APInts/APSInts in array initialization.
Fixes PR clang/3377

llvm-svn: 62851
2009-01-23 16:54:12 +00:00
Douglas Gregor d7fb85e8ad Reimplement the handling of the "current object" in designator
initializers, so that we are within the appropriate subobject after
we've processed a multi-designator designation. We're matching GCC and
EDG's behavior on all examples I've found thus far.

*Huge* thanks to Eli Friedman for pointing out my fundamental
misunderstanding of "current object" in the C99 spec.

llvm-svn: 62812
2009-01-22 23:26:18 +00:00
Douglas Gregor e4a0bb7a20 Initial implementation of semantic analysis and ASTs for C99
designated initializers. This implementation should cover all of the
constraints in C99 6.7.8, including long, complex designations and
computing the size of incomplete array types initialized with a
designated initializer. Please see the new test-case and holler if you
find cases where this doesn't work.

There are still some wrinkles with GNU's anonymous structs and
anonymous unions (it isn't clear how these should work; we'll just
follow GCC's lead) and with designated initializers for the members of a
union. I'll tackle those very soon.

CodeGen is still nonexistent, and there's some leftover code in the
parser's representation of designators that I'll also need to clean up.

llvm-svn: 62737
2009-01-22 00:58:24 +00:00