[cfe-commits] [PATCH][Review request] - IndirectField + designated initializers.

Francois Pichet pichet2000 at gmail.com
Sun Dec 12 19:23:43 PST 2010

More IndirectFieldDecl refactoring.

This patch deals with a dark corner of clang: anonymous field
initialized with designated-initializers (C99 feature)
This is C++ mixing with C99.. not sure why clang supports that but it does.


struct Test {
  union {
      int a;
      char b;

struct Test  var = { .a = 4 };

Some explaining: currently designated anonymous fields are found via
name look. Normal fields are found by iterating all the fields. This
patch uses the fact that IndirectFieldDecl declarations will follow an
anonymous implicit field to remove the special case of name lookup for
anonymous field. With this patch there is no need to calculate the
anonymous field position afterward. Clear enough?

I also removed RecordDecl::getAnonymousStructOrUnionObject
clang doesn't use it anymore since all anonymous fields handling is
now done thought IndirectFieldDecl.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: anon-designated-initializers.patch
Type: application/octet-stream
Size: 8773 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20101212/a2a95c7a/attachment.obj>

More information about the cfe-commits mailing list