[PATCH] Sema: When merging typedefs, handle records before merging attributes

Justin Bogner mail at justinbogner.com
Mon Oct 7 15:09:02 PDT 2013


Richard Smith <richard at metafoo.co.uk> writes:
> This doesn't look right in the case where the attribute is on a typedef
> defined inside a class in C++. Instead, I think we should only perform the
> merging if Old was a TypedefNameDecl.

I think you meant to say "if old was a CXXRecordDecl"? This would mean I
should put the [dcl.typedef] logic back where it was before and handle
this separately. I think you're right.

In fact, I probably need to be more explicit about this in general. In
particular, we need to handle cases like:

    typedef struct __attribute__((...)) X {
      ...
    } X __attribute((...));

I guess in this case we should go ahead and do the merge. The case where
we should skip the merge is only the special case where there are no
attributes on the struct, as they're all described on the typedef. Make
sense?

> Please also add to your testcase:
>
> struct TDS tds2; // no warning, attribute only applies to the typedef.
>
> ... and for good measure:
>
> typedef struct S { char c; } S __attribute__((aligned(8)));
> S a;
> struct S b;
> static_assert(alignof(a) == 8, "");
> static_assert(alignof(b) == 1, "");

Will do.



More information about the cfe-commits mailing list